Made boots not consume energy when in creative mode.

This commit is contained in:
Florian Nücke 2015-05-22 20:08:29 +02:00
parent 6040644a94
commit ce0ec1dc54
3 changed files with 8 additions and 18 deletions

View File

@ -17,7 +17,7 @@ object HoverBootsHandler {
val hadHoverBoots = nbt.getBoolean(Settings.namespace + "hasHoverBoots") val hadHoverBoots = nbt.getBoolean(Settings.namespace + "hasHoverBoots")
val hasHoverBoots = !player.isSneaking && equippedArmor(player).exists(stack => stack.getItem match { val hasHoverBoots = !player.isSneaking && equippedArmor(player).exists(stack => stack.getItem match {
case boots: HoverBoots => case boots: HoverBoots =>
if (player.onGround && player.worldObj.getTotalWorldTime % 20 == 0) { if (player.onGround && !player.capabilities.isCreativeMode && player.worldObj.getTotalWorldTime % 20 == 0) {
val velocity = player.motionX * player.motionX + player.motionY * player.motionY + player.motionZ * player.motionZ val velocity = player.motionX * player.motionX + player.motionY * player.motionY + player.motionZ * player.motionZ
if (velocity > 0.015f) { if (velocity > 0.015f) {
boots.charge(stack, -Settings.get.hoverBootMove, simulate = false) boots.charge(stack, -Settings.get.hoverBootMove, simulate = false)
@ -43,8 +43,9 @@ object HoverBootsHandler {
case stack if stack.getItem.isInstanceOf[HoverBoots] => case stack if stack.getItem.isInstanceOf[HoverBoots] =>
val boots = stack.getItem.asInstanceOf[HoverBoots] val boots = stack.getItem.asInstanceOf[HoverBoots]
val hoverJumpCost = -Settings.get.hoverBootJump val hoverJumpCost = -Settings.get.hoverBootJump
if (boots.charge(stack, hoverJumpCost, simulate = true) == 0) { val isCreative = player.capabilities.isCreativeMode
boots.charge(stack, hoverJumpCost, simulate = false) if (isCreative || boots.charge(stack, hoverJumpCost, simulate = true) == 0) {
if (!isCreative) boots.charge(stack, hoverJumpCost, simulate = false)
if (player.isSprinting) if (player.isSprinting)
player.addVelocity(player.motionX * 0.5, 0.4, player.motionZ * 0.5) player.addVelocity(player.motionX * 0.5, 0.4, player.motionZ * 0.5)
else else
@ -61,8 +62,9 @@ object HoverBootsHandler {
case stack if stack.getItem.isInstanceOf[HoverBoots] => case stack if stack.getItem.isInstanceOf[HoverBoots] =>
val boots = stack.getItem.asInstanceOf[HoverBoots] val boots = stack.getItem.asInstanceOf[HoverBoots]
val hoverFallCost = -Settings.get.hoverBootAbsorb val hoverFallCost = -Settings.get.hoverBootAbsorb
if (boots.charge(stack, hoverFallCost, simulate = true) == 0) { val isCreative = player.capabilities.isCreativeMode
boots.charge(stack, hoverFallCost, simulate = false) if (isCreative || boots.charge(stack, hoverFallCost, simulate = true) == 0) {
if (!isCreative) boots.charge(stack, hoverFallCost, simulate = false)
e.distance *= 0.3f e.distance *= 0.3f
} }
} }

View File

@ -6,14 +6,13 @@ import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers import li.cil.oc.OpenComputers
import li.cil.oc.api import li.cil.oc.api
import li.cil.oc.common.item.traits.Delegate
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.util.EnumChatFormatting import net.minecraft.util.EnumChatFormatting
import net.minecraft.world.World import net.minecraft.world.World
class Manual(val parent: Delegator) extends Delegate { class Manual(val parent: Delegator) extends traits.Delegate {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean): Unit = { override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean): Unit = {
tooltip.add(EnumChatFormatting.DARK_GRAY.toString + "v" + OpenComputers.Version) tooltip.add(EnumChatFormatting.DARK_GRAY.toString + "v" + OpenComputers.Version)

View File

@ -1,11 +0,0 @@
package li.cil.oc.common.item
import li.cil.oc.util.BlockPosition
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
class RemoteControl(val parent: Delegator) extends traits.Delegate {
override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
super.onItemUse(stack, player, position, side, hitX, hitY, hitZ)
}
}