僵尸不会用防具雷艇产卵

np8igboo  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(420)

我试图在eclipse上编写一个minecraft插件,所有僵尸都会使用max-armor和max-swill生成。但它们不会用盔甲和剑繁殖。我看了youtube教程。服务器日志显示插件已启用,未显示任何错误。救命啊?这是我的密码。

public class ChargedCreepersIrZombiaiSuArmor extends JavaPlugin implements Listener {
        @Override
        public void onEnable() {
            this.getServer().getPluginManager().registerEvents(this, this);
        }
        @EventHandler
        public void lol(CreatureSpawnEvent e) {
            if(e.getEntityType() == EntityType.CREEPER) {

            Creeper creeper = (Creeper) e.getEntity();
            creeper.setPowered(true);
        }
            Zombie zombie = (Zombie) e.getEntity();
        if(e.getEntityType() == EntityType.ZOMBIE) {
            ItemStack maxkardas = new ItemStack(Material.DIAMOND_SWORD);
            ItemStack maxcap = new ItemStack(Material.DIAMOND_HELMET);
            ItemStack maxleg = new ItemStack(Material.DIAMOND_LEGGINGS);
            ItemStack maxboots = new ItemStack(Material.DIAMOND_BOOTS);
            ItemStack maxchest = new  ItemStack(Material.DIAMOND_CHESTPLATE);
            maxkardas.addEnchantment(Enchantment.FIRE_ASPECT, 3); 
            maxkardas.addEnchantment(Enchantment.DAMAGE_ALL, 3); 
            maxkardas.addEnchantment(Enchantment.DURABILITY, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_FALL, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_FIRE, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
            maxchest.addEnchantment(Enchantment.DURABILITY, 3);
            maxchest.addEnchantment(Enchantment.THORNS, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_FALL, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3);
            maxcap.addEnchantment(Enchantment.DURABILITY, 3);
            maxcap.addEnchantment(Enchantment.THORNS, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_FIRE, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_FALL, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3);
            maxleg.addEnchantment(Enchantment.THORNS, 3);
            maxleg.addEnchantment(Enchantment.DURABILITY, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_FIRE, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
            maxboots.addEnchantment(Enchantment.PROTECTION_FALL, 3);
            maxboots.addEnchantment(Enchantment.DURABILITY, 3);
            maxboots.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3);
            maxboots.addEnchantment(Enchantment.PROTECTION_FIRE, 3);
            maxboots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
            maxboots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3);
            maxboots.addEnchantment(Enchantment.THORNS, 3);
            zombie.getEquipment().setItemInHand(maxkardas);
            zombie.getEquipment().setHelmet(maxcap);
            zombie.getEquipment().setChestplate(maxchest);
            zombie.getEquipment().setLeggings(maxleg);
            zombie.getEquipment().setBoots(maxboots);

    }
    }
    }
bvk5enib

bvk5enib1#

我想这个问题可能是按照你说的顺序 Zombie zombie = (Zombie) e.getEntity(); 因为你做得太大了 if 对于僵尸来说,你可能是在强迫一个暴徒成为一种类型 Zombie 可能会引起一些问题。
我搬走了 Zombie zombie = (Zombie) e.getEntity(); 内部 if 对于僵尸。类似于你的 if 对于爬行动物。
请尝试以下操作:

public class ChargedCreepersIrZombiaiSuArmor extends JavaPlugin implements Listener {
    @Override
    public void onEnable() {
        this.getServer().getPluginManager().registerEvents(this, this);
    }
    @EventHandler
    public void lol(CreatureSpawnEvent e) {
        System.out.println(e.getEntityType());
        if(e.getEntityType() == EntityType.CREEPER) {
            Creeper creeper = (Creeper) e.getEntity();
            creeper.setPowered(true);
        }

        if(e.getEntityType() == EntityType.ZOMBIE) {
            Zombie zombie = (Zombie) e.getEntity();
            ItemStack maxkardas = new ItemStack(Material.DIAMOND_SWORD);
            ItemStack maxcap = new ItemStack(Material.DIAMOND_HELMET);
            ItemStack maxleg = new ItemStack(Material.DIAMOND_LEGGINGS);
            ItemStack maxboots = new ItemStack(Material.DIAMOND_BOOTS);
            ItemStack maxchest = new  ItemStack(Material.DIAMOND_CHESTPLATE);
            maxkardas.addEnchantment(Enchantment.FIRE_ASPECT, 3); 
            maxkardas.addEnchantment(Enchantment.DAMAGE_ALL, 3); 
            maxkardas.addEnchantment(Enchantment.DURABILITY, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_FALL, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_FIRE, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
            maxchest.addEnchantment(Enchantment.DURABILITY, 3);
            maxchest.addEnchantment(Enchantment.THORNS, 3);
            maxchest.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_FALL, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3);
            maxcap.addEnchantment(Enchantment.DURABILITY, 3);
            maxcap.addEnchantment(Enchantment.THORNS, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_FIRE, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
            maxcap.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_FALL, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3);
            maxleg.addEnchantment(Enchantment.THORNS, 3);
            maxleg.addEnchantment(Enchantment.DURABILITY, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_FIRE, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
            maxleg.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2);
            maxboots.addEnchantment(Enchantment.PROTECTION_FALL, 3);
            maxboots.addEnchantment(Enchantment.DURABILITY, 3);
            maxboots.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3);
            maxboots.addEnchantment(Enchantment.PROTECTION_FIRE, 3);
            maxboots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
            maxboots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3);
            maxboots.addEnchantment(Enchantment.THORNS, 3);
            zombie.getEquipment().setItemInHand(maxkardas);
            zombie.getEquipment().setHelmet(maxcap);
            zombie.getEquipment().setChestplate(maxchest);
            zombie.getEquipment().setLeggings(maxleg);
            zombie.getEquipment().setBoots(maxboots);
        }
    }
}

如果这能解决你的问题,请告诉我。如果没有,让我知道发生了什么,我可以尝试再次帮助。

相关问题