Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted
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 by GAVINSIGHT

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.

  • 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 by GAVINSIGHT

  • 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

  • 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.

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.

  • Author
15 hours ago, ChampionAsh5357 said:

 

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.