Hello!
I tried to add an effect when i wear my armor so i try some line of codes:
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack item)
{
if(player.inventory.armorItemInSlot(0) != null &&
player.inventory.armorItemInSlot(1) != null &&
player.inventory.armorItemInSlot(2) != null &&
player.inventory.armorItemInSlot(3) != null)
{
if(player.inventory.armorItemInSlot(0).getItem() == ModItems.WULFENITE_BOOTS &&
player.inventory.armorItemInSlot(1).getItem() == ModItems.WULFENITE_LEGGINGS &&
player.inventory.armorItemInSlot(2).getItem() == ModItems.WULFENITE_CHESTPLATE &&
player.inventory.armorItemInSlot(3).getItem() == ModItems.WULFENITE_HELMET)
{
player.addPotionEffect(new PotionEffect(Potion.getPotionById(16), 20, 0));
}
}
}
Or
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
if (player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() == ModItems.WULFENITE_HELMET
&& player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(2).getItem() == ModItems.WULFENITE_CHESTPLATE
&& player.inventory.armorItemInSlot(1) != null && player.inventory.armorItemInSlot(1).getItem() == ModItems.WULFENITE_LEGGINGS
&& player.inventory.armorItemInSlot(0) != null && player.inventory.armorItemInSlot(0).getItem() == ModItems.WULFENITE_BOOTS) {
player.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 40, 4, false, false));
}
}
They work perfectly in Solo,
but when i join my SpongeForge server 1.12.2 with my mod, and i wear my armor i get disconnect with the message "Internal Server Error"
In the console, there's this error:
net.minecraft.util.ReportedException: Ticking player
at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:459) ~[oq.class:?]
at net.minecraft.network.NetHandlerPlayServer.redirect$onPlayerTick$zjb000(NetHandlerPlayServer.java:2056) ~[pa.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_73660_a(NetHandlerPlayServer.java:173) ~[pa.class:?]
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.func_73660_a(NetworkDispatcher.java:209) ~[NetworkDispatcher$1.class:?]
at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:285) ~[gw.class:?]
at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:180) [oz.class:?]
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:790) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397) [nz.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: java.lang.NoSuchMethodError: net.minecraft.entity.player.InventoryPlayer.func_70440_f(I)Lnet/minecraft/item/ItemStack;
at fr.mrsawz.sawzmod.items.armor.ArmorBase.onArmorTick(ArmorBase.java:71) ~[ArmorBase.class:?]
at net.minecraft.entity.player.InventoryPlayer.func_70429_k(InventoryPlayer.java:371) ~[aec.class:?]
at net.minecraft.entity.player.EntityPlayer.func_70636_d(EntityPlayer.java:511) ~[aed.class:?]
at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:2179) ~[vp.class:?]
at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:234) ~[aed.class:?]
at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:382) ~[oq.class:?]
... 10 more
[11:08:16]: [NetHandlerPlayServer] MrSawZ lost connection: Internal server error
I don't know why and i didn't found any pieces of information on the internet.
Can you help me, please?