Posted April 27, 20205 yr public class PeridotArmor extends ArmorItem{ public PeridotArmor(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builder) { super(materialIn, slot, builder); } @Override public void onArmorTick(ItemStack itemStack, World world, PlayerEntity player) { ItemStack boots = player.getItemStackFromSlot(EquipmentSlotType.FEET); if(boots.getItem() == ItemListOld.peridot_boots) { player.addPotionEffect(new EffectInstance(Effects.SPEED, 100, 4)); } else player.removePotionEffect(Effects.SPEED); } } I tried writing a class that allowed the player to move faster when wearing the armor. I'm getting no errors but when I apply the piece of armor in game it gives no effect. I've tried rewriting a few things and changing a few things here and there but nothing really seems to work Edited April 28, 20205 yr by GAVINSIGHT
April 28, 20205 yr 50 minutes ago, GAVINSIGHT said: if(boots.getItem() == ItemListOld.peridot_boots) { player.addPotionEffect(new EffectInstance(Effects.SPEED, 100, 4)); } else player.removePotionEffect(Effects.SPEED); } Are my eyes deceiving me or are you missing a bracket somewhere? Moreover, why are you removing the potion effect instead setting the effective time to something smaller. Third, potion effects should be added on the server side.
April 28, 20205 yr Author Quote Third, potion effects should be added on the server side How would I go about adding potion effects on the server side? Edited April 28, 20205 yr by GAVINSIGHT
April 28, 20205 yr https://mcforge.readthedocs.io/en/latest/concepts/sides/#worldisremote That should help you.
April 28, 20205 yr Author public class PeridotArmor extends ArmorItem{ public PeridotArmor(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builder) { super(materialIn, slot, builder); } @Override public void onArmorTick(ItemStack itemStack, World world, PlayerEntity player) { ItemStack boots = player.getItemStackFromSlot(EquipmentSlotType.FEET); if(boots.getItem() == ItemListOld.peridot_boots) { if(!world.isRemote) { player.addPotionEffect(new EffectInstance(Effects.SPEED, 5, 4, false, false, true)); } } } } I updated my code, but it seemed to unfortunately have no effect. I tried swapping the order of the IF statements and adding/removing the booleans
April 28, 20205 yr I can help but notice you are calling "ItemListOld". Any chance you are comparing the wrong item?
April 28, 20205 yr Author 1 hour ago, DarKnighT_0_9 said: I can help but notice you are calling "ItemListOld". Any chance you are comparing the wrong item? No, I have ItemList which uses deferred registry and ItemListOld which doesn’t. I switched to deferred registries for a majority of my items but found it much easier to keep my armor and tools within ItemListOld.
April 28, 20205 yr 8 hours ago, GAVINSIGHT said: public class PeridotArmor extends ArmorItem{ public PeridotArmor(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builder) { super(materialIn, slot, builder); } @Override public void onArmorTick(ItemStack itemStack, World world, PlayerEntity player) { ItemStack boots = player.getItemStackFromSlot(EquipmentSlotType.FEET); if(boots.getItem() == ItemListOld.peridot_boots) { if(!world.isRemote) { player.addPotionEffect(new EffectInstance(Effects.SPEED, 5, 4, false, false, true)); } } } } I updated my code, but it seemed to unfortunately have no effect. I tried swapping the order of the IF statements and adding/removing the booleans Have you tried setting breakpoints? Just curious where in the code you make it to, and what is not doing as expected.
April 28, 20205 yr Author 15 hours ago, ChampionAsh5357 said: https://mcforge.readthedocs.io/en/latest/concepts/sides/#worldisremote That should help you. 13 hours ago, DarKnighT_0_9 said: I can help but notice you are calling "ItemListOld". Any chance you are comparing the wrong item? 6 hours ago, Ugdhar said: Have you tried setting breakpoints? Just curious where in the code you make it to, and what is not doing as expected. Issue solved! In the code I added "PeridotArmor peridotBoots = ItemListOld.peridot_boots" and in the ItemListOld class I referred to peridot_boots as "PeridotArmor" rather than "ArmorItem". Solved the issue! Thank you for your help. Crazy, I dreamed the solution when I fell asleep last night.
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.