mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-11 16:28:12 -04:00
Avoid hover boots taking actual damage, subtract energy instead. Closes #1400.
Also added slowness effect when running around with drained boots.
This commit is contained in:
parent
0bc35468da
commit
81c2b7d1cc
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user