Не пропадают эффекты зелий!

Версия Minecraft
1.12+
586
32
136
Приветствую, сделал я заготовку для меча, КОД НА КОСТЫЛЯХ(тест)
Код:
package zarak.DarkKnowladge.common.items.tools;


import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import zarak.DarkKnowladge.Materials;
import zarak.DarkKnowladge.Tabs;

import javax.annotation.Nullable;
import java.util.List;

public class ItemDarkSwordNoSleep extends ItemSword {
 private String name = "dark_sword_no_sleep";

 public ItemDarkSwordNoSleep() {
 super(Materials.DarkSwordMAT);
 setUnlocalizedName(name);
 setRegistryName(name);
 setFull3D();
 setCreativeTab(Tabs.DK_TAB);
 }


 @Override
 public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
 if(worldIn.isRemote){
 ItemStack stack = player.getHeldItem(handIn);
 ItemStack boots = player.inventory.armorInventory.get(0);
 ItemStack leggins = player.inventory.armorInventory.get(1);
 ItemStack chest = player.inventory.armorInventory.get(2);
 ItemStack helmet = player.inventory.armorInventory.get(3);
 if(stack.getTagCompound().getBoolean("dk:ON") == true){
 stack.getTagCompound().setBoolean("dk:Boots",false);
 stack.getTagCompound().setBoolean("dk:Leggings",false);
 stack.getTagCompound().setBoolean("dk:Chest",false);
 stack.getTagCompound().setBoolean("dk:Helmet",false);
 stack.getTagCompound().setBoolean("dk:ON",true);
 stack.getTagCompound().setBoolean("dk:ON",false);
 }else {
 if(boots.getItem() == Items.DIAMOND_BOOTS){
 stack.getTagCompound().setBoolean("dk:Boots",true);
 }
 if(leggins.getItem() == Items.DIAMOND_LEGGINGS){
 stack.getTagCompound().setBoolean("dk:Leggings",true);
 }
 if(chest.getItem() == Items.DIAMOND_CHESTPLATE){
 stack.getTagCompound().setBoolean("dk:Chest",true);
 }
 if(helmet.getItem() == Items.DIAMOND_HELMET){
 stack.getTagCompound().setBoolean("dk:Helmet",true);
 }
 stack.getTagCompound().setBoolean("dk:ON",true);
 }
 }return super.onItemRightClick(worldIn, player, handIn);}

 @SideOnly(Side.CLIENT)
 @Override
 public void addInformation(ItemStack stack, @Nullable World playerIn, List<String> tooltip, ITooltipFlag advanced) {
 if(!stack.hasTagCompound())return;
 if(stack.getTagCompound().getBoolean("dk:ON")){
 tooltip.add(I18n.format("darkSword.ON"));
 }
 else{
 tooltip.add(I18n.format("darkSword.OFF"));
 }
 }

 @Override
 public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
 super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
 if(!(entityIn instanceof EntityPlayer))return;
 EntityPlayer player = (EntityPlayer)entityIn;
 if(!stack.hasTagCompound()){
 stack.setTagCompound(new NBTTagCompound());
   }
 ItemStack boots = player.inventory.armorInventory.get(0);
 ItemStack leggins = player.inventory.armorInventory.get(1);
 ItemStack chest = player.inventory.armorInventory.get(2);
 ItemStack helmet = player.inventory.armorInventory.get(3);
 if(boots.getItem() == Items.DIAMOND_BOOTS){
 stack.getTagCompound().setBoolean("dk:Boots",true);
 }
 else {
 stack.getTagCompound().setBoolean("dk:Boots",false);
 }

 if(leggins.getItem() == Items.DIAMOND_LEGGINGS){
 stack.getTagCompound().setBoolean("dk:Leggings",true);
 }
 else {
 stack.getTagCompound().setBoolean("dk:Leggings",false);
 }

 if(chest.getItem() == Items.DIAMOND_CHESTPLATE){
 stack.getTagCompound().setBoolean("dk:Chest",true);
 }
 else {
 stack.getTagCompound().setBoolean("dk:Chest",false);
 }

 if(helmet.getItem() == Items.DIAMOND_HELMET){
 stack.getTagCompound().setBoolean("dk:Helmet",true);
 }
 else {
 stack.getTagCompound().setBoolean("dk:Helmet",false);
 }

   if(stack.getTagCompound().getBoolean("dk:ON") == true){
   player.addPotionEffect(new PotionEffect(MobEffects.HUNGER,35,1));
   player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH,35,1));
 if(stack.getTagCompound().getBoolean("dk:Boots") == true){
 player.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST,35,2));
 }
 if(stack.getTagCompound().getBoolean("dk:Leggings") == true){
 player.addPotionEffect(new PotionEffect(MobEffects.SPEED,35,2));
 }
 if(stack.getTagCompound().getBoolean("dk:Chest") == true){
 player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE,35,1));
 }
 if(stack.getTagCompound().getBoolean("dk:Helmet") == true){
 player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION,35));
 }
   }
 }
}

Всё хорошо работает, но когда код доходит до зелий, они как-бы пропали но нет, таймеры ровны 0:00, при перезаходе, пропадают.
 

Вложения

  • Screenshot_2.png
    Screenshot_2.png
    40.5 KB · Просмотры: 5
3,005
192
592
Замени
if(worldIn.isRemote)
На
if(!worldIn.isRemote)
В update попробуй добавить
if(!worldIn.isRemote) и туда код.
 
Сверху