Jump to content

[1.14.2] Step height change not removed when removing armor piece


kwpugh

Recommended Posts

Hi All,

 

I'm having some trouble with an armor class.   When the player remove the boots, the change in step height does not go away.   Is there a different way I should be implementing this or am I missing something important?

 

Any guidance would help.

 

Thank you.

 

package com.kwpugh.gobber2.items.armor;

import com.kwpugh.gobber2.lists.ItemList;
import com.kwpugh.gobber2.util.SpecialAbilities;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.IArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effect;
import net.minecraft.world.World;

public class ItemCustomArmor extends ArmorItem
{
	public ItemCustomArmor(IArmorMaterial materialIn, EquipmentSlotType slots, Properties builder)
	{
		super(materialIn, slots, builder);
	}
	
	
	public void onArmorTick(final ItemStack stack, final World world, final PlayerEntity player)
	{
		if(player instanceof PlayerEntity)
		{	
			ItemStack head = player.getItemStackFromSlot(EquipmentSlotType.HEAD);
			ItemStack chest = player.getItemStackFromSlot(EquipmentSlotType.CHEST);
			ItemStack legs = player.getItemStackFromSlot(EquipmentSlotType.LEGS);
		    ItemStack feet = player.getItemStackFromSlot(EquipmentSlotType.FEET);	
		 
		    //Full Set

	    	if(head != null && head.getItem() == ItemList.gobber2_helmet && 
	    			chest != null && chest.getItem() == ItemList.gobber2_chestplate && 
	    			legs != null && legs.getItem() == ItemList.gobber2_leggings && 
	    			feet != null && feet.getItem() == ItemList.gobber2_boots)
	    	{
	    		((LivingEntity) player).removePotionEffect(Effect.get(19)); //Poison
	    	}	
		    
		    //Helmet
		    if(head.getItem() == ItemList.gobber2_helmet)
			{
				int newfoodlevel = 1;
				float newsatlevel = 0.0F;
				SpecialAbilities.giveRegenffect(world, player, stack, newfoodlevel, newsatlevel);			
			}
			else
			{
				
			}
		    
		    //Chestplate
		    if(chest.getItem() == ItemList.gobber2_chestplate)
			{
		 		if(player.isInWater())
		 		{
		 			SpecialAbilities.giveBreathing(world, player, chest);
		 		}
			}
		    
		    //Leggings
		    if(legs.getItem() == ItemList.gobber2_leggings)
			{
				player.fallDistance = 0.0F;
			}
			else
			{
				player.fallDistance = 1.0F;
			}	
		    
		    //Boots
		    if(feet.getItem() == ItemList.gobber2_boots)
			{
				player.stepHeight = 2.1F;
				
				if(!player.onGround)
				{
					//player.jumpMovementFactor += 0.09F;
				}
		    }
			else
		    {
				player.stepHeight = 0.0F;
		    }		 	
		}
	}
	
	@Override
	public boolean isBookEnchantable(ItemStack stack, ItemStack book)
	{
		return true;
	}

	@Override
	public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
	{
		return repair.getItem() == ItemList.gobber2_armor_repair;
	}
}

 

Link to comment
Share on other sites

30 minutes ago, kwpugh said:

if(head != null ...

ItemStacks can't be null.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

So, this seems to work.   Is this a proper way to do it?

 

package com.kwpugh.gobber2.items.armor;

import com.kwpugh.gobber2.lists.ItemList;
import com.kwpugh.gobber2.util.SpecialAbilities;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.IArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effects;
import net.minecraft.world.World;
import net.minecraftforge.registries.ForgeRegistries;

public class ItemCustomArmor extends ArmorItem
{
	public ItemCustomArmor(IArmorMaterial materialIn, EquipmentSlotType slots, Properties builder)
	{
		super(materialIn, slots, builder);
	}	
	
	public void onArmorTick(final ItemStack stack, final World world, final PlayerEntity player)
	{
		if(player instanceof PlayerEntity)
		{	
		    
			ItemStack head = player.getItemStackFromSlot(EquipmentSlotType.HEAD);
			ItemStack chest = player.getItemStackFromSlot(EquipmentSlotType.CHEST);
			ItemStack legs = player.getItemStackFromSlot(EquipmentSlotType.LEGS);
		    ItemStack feet = player.getItemStackFromSlot(EquipmentSlotType.FEET);
		    
		    //Full Set
	    	if(head.getItem() == ItemList.gobber2_helmet && 
	    			chest.getItem() == ItemList.gobber2_chestplate && 
	    			legs.getItem() == ItemList.gobber2_leggings && 
	    			feet.getItem() == ItemList.gobber2_boots)
	    	{
	    		((LivingEntity) ForgeRegistries.POTIONS).removePotionEffect(Effects.POISON);
	    	}	
		    
		    //Helmet
		    if(head.getItem() == ItemList.gobber2_helmet)
			{
				int newfoodlevel = 1;
				float newsatlevel = 0.0F;
				SpecialAbilities.giveRegenffect(world, player, stack, newfoodlevel, newsatlevel);			
			}
		    
		    //Chestplate
		    if(chest.getItem() == ItemList.gobber2_chestplate)
			{
		 		if(player.isInWater())
		 		{
		 			SpecialAbilities.giveBreathing(world, player, chest);
		 		}
			}
		    
		    //Leggings
		    if(legs.getItem() == ItemList.gobber2_leggings)
			{
				player.fallDistance = 0.0F;
			}	
		    
		    //Boots
		    if(feet.getItem() == ItemList.gobber2_boots)
			{
				player.stepHeight = 2.1F;
				
				if(!player.onGround)
				{
					//player.jumpMovementFactor += 0.09F;
				}
		    }		 	
		}
	}
	
	public void inventoryTick(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
	{			
		ItemStack head = player.getItemStackFromSlot(EquipmentSlotType.HEAD);
		ItemStack chest = player.getItemStackFromSlot(EquipmentSlotType.CHEST);
		ItemStack legs = player.getItemStackFromSlot(EquipmentSlotType.LEGS);
	    ItemStack feet = player.getItemStackFromSlot(EquipmentSlotType.FEET);
	    
		if(!(legs.getItem() == ItemList.gobber2_leggings))
		{
			player.fallDistance = 1.0F;
		}	
		
		if(!(feet.getItem() == ItemList.gobber2_boots))
		{
			player.stepHeight = 0.0F;
	    }		
	}
	
	@Override
	public boolean isBookEnchantable(ItemStack stack, ItemStack book)
	{
		return true;
	}

	@Override
	public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
	{
		return repair.getItem() == ItemList.gobber2_armor_repair;
	}
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.