Crigo 发表于 2023-11-9 20:20:26

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

代码:
java
importnet.minecraft.block.Block;
importnet.minecraft.block.BlockState;
importnet.minecraft.entity.Entity;
importnet.minecraft.entity.boss.BossEntity;
importnet.minecraft.entity.player.PlayerEntity;
importnet.minecraft.particle.ParticleEffect;
importnet.minecraft.particle.ParticleType;
importnet.minecraft.server.command.ServerCommandSource;
importnet.minecraft.util.math.BlockPos;
importnet.minecraft.world.World;
publicclassBossBattleCommand{
   publicstaticvoidexecute(ServerCommandSourcesource,String[]args){
         //获取玩家
         PlayerEntityplayer=source.getPlayer();
         if(player==null){
             return;
         }
         //获取世界
         Worldworld=player.world;
         if(world==null){
             return;
         }
         //生成BOSS
         generateBoss(world,player);
   }
   privatestaticvoidgenerateBoss(Worldworld,PlayerEntityplayer){
         //在玩家所在的区块内随机一格生成大量白色粒子效果
         intx=player.getBlockX();
         inty=player.getBlockY();
         intz=player.getBlockZ();
         BlockPosbossSpawnPos=newBlockPos(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(inti=0;i<20;i++){
             world.setBlockState(newBlockPos(x+random.nextInt(16),y+random.nextInt(16),z+random.nextInt(16)),BlockState.fromRawData(0x1C000000,0));
         }
         //玩家通知
         player.sendMessage(newTextComponentString("BOSS已经苏醒!!!"));
         //战斗开始
         //...
         //战斗结束
         //...
   }
}





这BOSS开场着实有些像凋灵了(

Crigo 发表于 2023-11-9 20:21:08

我不知道这些代码能不能有用()

RSR 发表于 2023-11-9 22:29:27

本帖最后由 RSR 于 2023-11-9 22:30 编辑

够ai 的,特别是这一部分经典

根本没理解你想做什么
所以,这段代码不能用

页: [1]
查看完整版本: 使用我在ai写JAVA版BOSS战代码(只是整活 而且示例)