From 81c2b7d1cc05ac19e574a088fa0eba81008dba36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 4 Sep 2015 18:13:11 +0200 Subject: [PATCH 1/4] Avoid hover boots taking actual damage, subtract energy instead. Closes #1400. Also added slowness effect when running around with drained boots. --- .../li/cil/oc/common/item/HoverBoots.scala | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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) + } } From 38f30944f1f3fc68ed6374d29419d203b926c1f9 Mon Sep 17 00:00:00 2001 From: chaoskagami Date: Fri, 4 Sep 2015 20:40:33 -0400 Subject: [PATCH 2/4] Fix for NeK maven being removed --- build.gradle | 4 ++-- build.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index e688714dd..efb672f38 100644 --- a/build.gradle +++ b/build.gradle @@ -92,8 +92,8 @@ repositories { url = "http://mobiusstrip.eu/maven" } maven { - name = "builtbroken" - url = "http://ci.builtbroken.com/maven/" + name = "dmodoomsirius" + url = "http://ci.dmodoomsirius.me/maven/" } maven { name = "ue" diff --git a/build.properties b/build.properties index 4f5fc4aad..e399ec21a 100644 --- a/build.properties +++ b/build.properties @@ -32,7 +32,7 @@ mekanism.version=7.1.2 mfr.cf=2229/626 mfr.version=[1.7.10]2.8.0RC8-86 nei.version=1.0.3.57 -nek.version=1.0.0b35dev +nek.version=1.0.0b2dev projred.version=1.7.10-4.6.2.82 qmunitylib.version=0.1.105 rc.cf=2219/321 @@ -46,4 +46,4 @@ wrcbe.version=1.4.1.2 cofhcore.cf=2246/697 cofhcore.version=[1.7.10]3.0.3B4-302-dev -maven.url=file:///home/www/maven.cil.li/web \ No newline at end of file +maven.url=file:///home/www/maven.cil.li/web From a0ce5923829f7b33a22a0d607894e5d0da3c82eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 5 Sep 2015 23:00:09 +0200 Subject: [PATCH 3/4] Fixed crash when trying to change APU architecture. Closes #1404. --- .../cil/oc/common/item/traits/CPULike.scala | 27 ++++++++++++------- .../integration/opencomputers/DriverCPU.scala | 10 ++----- .../li/cil/oc/server/machine/Machine.scala | 7 +++++ .../oc/server/machine/luac/ComputerAPI.scala | 8 +++--- .../oc/server/machine/luaj/ComputerAPI.scala | 8 +++--- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/item/traits/CPULike.scala b/src/main/scala/li/cil/oc/common/item/traits/CPULike.scala index 4b26ca417..f6be76ed3 100644 --- a/src/main/scala/li/cil/oc/common/item/traits/CPULike.scala +++ b/src/main/scala/li/cil/oc/common/item/traits/CPULike.scala @@ -3,7 +3,10 @@ package li.cil.oc.common.item.traits import java.util import li.cil.oc.Settings +import li.cil.oc.api +import li.cil.oc.api.driver.item.MutableProcessor import li.cil.oc.integration.opencomputers.DriverCPU +import li.cil.oc.server.machine.Machine import li.cil.oc.util.Tooltip import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack @@ -19,22 +22,26 @@ trait CPULike extends Delegate { override protected def tooltipData: Seq[Any] = Seq(Settings.get.cpuComponentSupport(cpuTier)) override protected def tooltipExtended(stack: ItemStack, tooltip: util.List[String]) { - tooltip.addAll(Tooltip.get("CPU.Architecture", DriverCPU.getArchitectureName(DriverCPU.architecture(stack)))) + tooltip.addAll(Tooltip.get("CPU.Architecture", Machine.getArchitectureName(DriverCPU.architecture(stack)))) } override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer) = { if (player.isSneaking) { if (!world.isRemote) { - val architectures = DriverCPU.allArchitectures.toList - if (architectures.nonEmpty) { - val currentIndex = architectures.indexOf(DriverCPU.architecture(stack)) - val newIndex = (currentIndex + 1) % architectures.length - val archClass = architectures(newIndex) - val archName = DriverCPU.getArchitectureName(archClass) - DriverCPU.setArchitecture(stack, archClass) - player.addChatMessage(new ChatComponentTranslation(Settings.namespace + "tooltip.CPU.Architecture", archName)) + api.Driver.driverFor(stack) match { + case driver: MutableProcessor => + val architectures = driver.allArchitectures.toList + if (architectures.nonEmpty) { + val currentIndex = architectures.indexOf(driver.architecture(stack)) + val newIndex = (currentIndex + 1) % architectures.length + val archClass = architectures(newIndex) + val archName = Machine.getArchitectureName(archClass) + driver.setArchitecture(stack, archClass) + player.addChatMessage(new ChatComponentTranslation(Settings.namespace + "tooltip.CPU.Architecture", archName)) + } + player.swingItem() + case _ => // No known driver for this processor. } - player.swingItem() } } stack diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/DriverCPU.scala b/src/main/scala/li/cil/oc/integration/opencomputers/DriverCPU.scala index 62e8557d3..d5486c5e8 100644 --- a/src/main/scala/li/cil/oc/integration/opencomputers/DriverCPU.scala +++ b/src/main/scala/li/cil/oc/integration/opencomputers/DriverCPU.scala @@ -12,6 +12,7 @@ import li.cil.oc.common.Slot import li.cil.oc.common.Tier import li.cil.oc.common.item import li.cil.oc.common.item.Delegator +import li.cil.oc.server.machine.Machine import li.cil.oc.server.machine.luac.NativeLuaArchitecture import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound @@ -66,13 +67,6 @@ abstract class DriverCPU extends Item with MutableProcessor { if (!worksWith(stack)) throw new IllegalArgumentException("Unsupported processor type.") if (!stack.hasTagCompound) stack.setTagCompound(new NBTTagCompound()) stack.getTagCompound.setString(Settings.namespace + "archClass", architecture.getName) - stack.getTagCompound.setString(Settings.namespace + "archName", getArchitectureName(architecture)) + stack.getTagCompound.setString(Settings.namespace + "archName", Machine.getArchitectureName(architecture)) } - - // TODO Move to Machine API in 1.6 - def getArchitectureName(architecture: Class[_ <: Architecture]) = - architecture.getAnnotation(classOf[Architecture.Name]) match { - case annotation: Architecture.Name => annotation.value - case _ => architecture.getSimpleName - } } diff --git a/src/main/scala/li/cil/oc/server/machine/Machine.scala b/src/main/scala/li/cil/oc/server/machine/Machine.scala index 0b5a256e7..ec503b0c8 100644 --- a/src/main/scala/li/cil/oc/server/machine/Machine.scala +++ b/src/main/scala/li/cil/oc/server/machine/Machine.scala @@ -980,6 +980,13 @@ object Machine extends MachineAPI { override def architectures = checked.toSeq + // TODO Expose in Machine API in 1.6 + def getArchitectureName(architecture: Class[_ <: Architecture]) = + architecture.getAnnotation(classOf[Architecture.Name]) match { + case annotation: Architecture.Name => annotation.value + case _ => architecture.getSimpleName + } + override def create(host: MachineHost) = new Machine(host) /** Possible states of the computer, and in particular its executor. */ diff --git a/src/main/scala/li/cil/oc/server/machine/luac/ComputerAPI.scala b/src/main/scala/li/cil/oc/server/machine/luac/ComputerAPI.scala index c92ea091b..d86b3063c 100644 --- a/src/main/scala/li/cil/oc/server/machine/luac/ComputerAPI.scala +++ b/src/main/scala/li/cil/oc/server/machine/luac/ComputerAPI.scala @@ -5,7 +5,7 @@ import li.cil.oc.api import li.cil.oc.api.driver.item.MutableProcessor import li.cil.oc.api.driver.item.Processor import li.cil.oc.api.network.Connector -import li.cil.oc.integration.opencomputers.DriverCPU +import li.cil.oc.server.machine.Machine import li.cil.oc.util.ExtendedLuaState.extendLuaState import scala.collection.convert.WrapAsScala._ @@ -117,7 +117,7 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) { case (stack, processor: Processor) => Seq(processor.architecture(stack)) } match { case Some(architectures) => - lua.pushValue(architectures.map(DriverCPU.getArchitectureName)) + lua.pushValue(architectures.map(Machine.getArchitectureName)) case _ => lua.newTable() } @@ -128,7 +128,7 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) { lua.pushScalaFunction(lua => { machine.host.internalComponents.map(stack => (stack, api.Driver.driverFor(stack))).collectFirst { case (stack, processor: Processor) => - lua.pushString(DriverCPU.getArchitectureName(processor.architecture(stack))) + lua.pushString(Machine.getArchitectureName(processor.architecture(stack))) 1 }.getOrElse(0) }) @@ -137,7 +137,7 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) { lua.pushScalaFunction(lua => { val archName = lua.checkString(1) machine.host.internalComponents.map(stack => (stack, api.Driver.driverFor(stack))).collectFirst { - case (stack, processor: MutableProcessor) => processor.allArchitectures.find(arch => DriverCPU.getArchitectureName(arch) == archName) match { + case (stack, processor: MutableProcessor) => processor.allArchitectures.find(arch => Machine.getArchitectureName(arch) == archName) match { case Some(archClass) => if (archClass != processor.architecture(stack)) { processor.setArchitecture(stack, archClass) diff --git a/src/main/scala/li/cil/oc/server/machine/luaj/ComputerAPI.scala b/src/main/scala/li/cil/oc/server/machine/luaj/ComputerAPI.scala index cb87c1180..72b166e59 100644 --- a/src/main/scala/li/cil/oc/server/machine/luaj/ComputerAPI.scala +++ b/src/main/scala/li/cil/oc/server/machine/luaj/ComputerAPI.scala @@ -5,7 +5,7 @@ import li.cil.oc.api import li.cil.oc.api.driver.item.MutableProcessor import li.cil.oc.api.driver.item.Processor import li.cil.oc.api.network.Connector -import li.cil.oc.integration.opencomputers.DriverCPU +import li.cil.oc.server.machine.Machine import li.cil.oc.util.ScalaClosure._ import li.cil.repack.org.luaj.vm2.LuaValue import li.cil.repack.org.luaj.vm2.Varargs @@ -65,21 +65,21 @@ class ComputerAPI(owner: LuaJLuaArchitecture) extends LuaJAPI(owner) { case (stack, processor: MutableProcessor) => processor.allArchitectures.toSeq case (stack, processor: Processor) => Seq(processor.architecture(stack)) } match { - case Some(architectures) => LuaValue.listOf(architectures.map(DriverCPU.getArchitectureName).map(LuaValue.valueOf).toArray) + case Some(architectures) => LuaValue.listOf(architectures.map(Machine.getArchitectureName).map(LuaValue.valueOf).toArray) case _ => LuaValue.tableOf() } }) computer.set("getArchitecture", (args: Varargs) => { machine.host.internalComponents.map(stack => (stack, api.Driver.driverFor(stack))).collectFirst { - case (stack, processor: Processor) => LuaValue.valueOf(DriverCPU.getArchitectureName(processor.architecture(stack))) + case (stack, processor: Processor) => LuaValue.valueOf(Machine.getArchitectureName(processor.architecture(stack))) }.getOrElse(LuaValue.NONE) }) computer.set("setArchitecture", (args: Varargs) => { val archName = args.checkjstring(1) machine.host.internalComponents.map(stack => (stack, api.Driver.driverFor(stack))).collectFirst { - case (stack, processor: MutableProcessor) => processor.allArchitectures.find(arch => DriverCPU.getArchitectureName(arch) == archName) match { + case (stack, processor: MutableProcessor) => processor.allArchitectures.find(arch => Machine.getArchitectureName(arch) == archName) match { case Some(archClass) => if (archClass != processor.architecture(stack)) { processor.setArchitecture(stack, archClass) From d90325e6d55b5ca95e37d3c09f3d2515b8243a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 5 Sep 2015 23:03:23 +0200 Subject: [PATCH 4/4] Bump version. --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 4f5fc4aad..35391a17e 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1448-1.7.10 -oc.version=1.5.16 +oc.version=1.5.17 oc.subversion=dev ae2.version=rv2-beta-26