diff --git a/src/main/scala/li/cil/oc/common/item/HoverBoots.scala b/src/main/scala/li/cil/oc/common/item/HoverBoots.scala index 376fe8724..c026fdd67 100644 --- a/src/main/scala/li/cil/oc/common/item/HoverBoots.scala +++ b/src/main/scala/li/cil/oc/common/item/HoverBoots.scala @@ -8,9 +8,13 @@ import li.cil.oc.common.item.data.HoverBootsData import net.minecraft.client.model.ModelBiped import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.EnumRarity import net.minecraft.item.ItemArmor import net.minecraft.item.ItemStack +import net.minecraft.potion.Potion +import net.minecraft.potion.PotionEffect +import net.minecraft.world.World class HoverBoots extends ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 0, 3) with traits.SimpleItem with traits.Chargeable { setNoRepair() @@ -61,6 +65,13 @@ class HoverBoots extends ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 0, 3) with t else null } + override def onArmorTick(world: World, player: EntityPlayer, stack: ItemStack): Unit = { + super.onArmorTick(world, player, stack) + if (player.getActivePotionEffect(Potion.moveSlowdown) == null && getCharge(stack) == 0) { + player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId, 20, 1)) + } + } + override def getDisplayDamage(stack: ItemStack): Int = { val data = new HoverBootsData(stack) (Settings.get.bufferHoverBoots * (1 - data.charge / Settings.get.bufferHoverBoots)).toInt @@ -70,4 +81,15 @@ class HoverBoots extends ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 0, 3) with t // Always show energy bar. override def isDamaged(stack: ItemStack): Boolean = true + + // Contradictory as it may seem with the above, this avoids actual damage value changing. + override def isDamageable: Boolean = false + + override def setDamage(stack: ItemStack, damage: Int): Unit = { + // Subtract energy when taking damage instead of actually damaging the item. + charge(stack, -damage, simulate = false) + + // Set to 0 for old boots that may have been damaged before. + super.setDamage(stack, 0) + } }