开启辅助访问     
收藏本站

站内搜索

搜索

Minecraft(我的世界)苦力怕论坛

[其他] 使用我在ai写JAVA版BOSS战代码(只是整活 而且示例)

 发表于 2023-11-9 20:20:26 来自手机|显示全部楼层|阅读模式 IP:浙江省
代码:
java
import  net.minecraft.block.Block;
import  net.minecraft.block.BlockState;
import  net.minecraft.entity.Entity;
import  net.minecraft.entity.boss.BossEntity;
import  net.minecraft.entity.player.PlayerEntity;
import  net.minecraft.particle.ParticleEffect;
import  net.minecraft.particle.ParticleType;
import  net.minecraft.server.command.ServerCommandSource;
import  net.minecraft.util.math.BlockPos;
import  net.minecraft.world.World;
public  class  BossBattleCommand  {
     public  static  void  execute(ServerCommandSource  source,String[]  args)  {
         //  获取玩家
         PlayerEntity  player  =  source.getPlayer();
         if  (player  ==  null)  {
             return;
         }
         //  获取世界
         World  world  =  player.world;
         if  (world  ==  null)  {
             return;
         }
         //  生成BOSS
         generateBoss(world,player);
     }
     private  static  void  generateBoss(World  world,PlayerEntity  player)  {
         //  在玩家所在的区块内随机一格生成大量白色粒子效果
         int  x  =  player.getBlockX();
         int  y  =  player.getBlockY();
         int  z  =  player.getBlockZ();
         BlockPos  bossSpawnPos  =  new  BlockPos(x  +  random.nextInt(16),  y  +  random.nextInt(16),  z  +  random.nextInt(16));
         world.spawnParticle(ParticleType.WHITE_DOTS,bossSpawnPos.getX(),  bossSpawnPos.getY(),  bossSpawnPos.getZ(),  10,0.1);
         //  等待三秒后产生爆炸并用黑曜石方块填充该区块的地面
         world.explode(bossSpawnPos,3F);
         for  (int  i  =  0;i  <  20;i++)  {
             world.setBlockState(new  BlockPos(x  +  random.nextInt(16),  y  +  random.nextInt(16),  z  +  random.nextInt(16)),  BlockState.fromRawData(0x1C000000,0));
         }
         //  玩家通知
         player.sendMessage(new  TextComponentString("BOSS已经苏醒!!!"));
         //  战斗开始
         //  ...
         //  战斗结束
         //  ...
     }
}





这BOSS开场着实有些像凋灵了(
Screenshot_2023-11-09-20-20-00-618_com.chat.qsai.png
苦力怕论坛,感谢有您~
 楼主|  发表于 2023-11-9 20:21:08 来自手机|显示全部楼层 IP:浙江省
评论复审中...编号:9621808
2#2023-11-9 20:21:08回复收起回复
苦力怕论坛,感谢有您~
 发表于 2023-11-9 22:29:27|显示全部楼层 IP:江苏省
评论复审中...编号:9622918
3#2023-11-9 22:29:27收起回复
Crigo2023-11-10 19:47IP:浙江省
回复举报
啊这样吗。。。我自己不懂JAVA程序语言,所以找ai整个活。。。
我去试试看能不能让ai把这段代码的错误修复掉
夙S溯2023-11-12 00:50IP:安徽省
回复举报
真试过的发现ai根本不能写我的世界的代码,甭管java还是基岩,甭管ai怎么说,反正要让它写的代码能跑起来,挺难
Crigo回复夙S溯2023-11-12 16:32IP:浙江省
回复举报
我记得破站上面有个up实现过啊
Crigo回复夙S溯2023-11-12 16:33IP:浙江省
回复举报
虽然但是,很耗时间
苦力怕论坛,感谢有您~

本版积分规则

本站
关于我们
联系我们
坛史纲要
官方
哔哩哔哩
技术博客
下载
网易版
安卓版
JAVA
反馈
意见建议
教程中心
更多
捐助本站
QQ群
QQ群

QQ群

访问手机版

访问手机版

手机版|小黑屋|系统状态|klpbbs.com

| 由 木韩网络 提供支持 | GMT+8, 2026-6-23 17:23

声明:本站与Mojang以及微软公司没有从属关系

Powered by Discuz! X3.4