diff --git a/build.gradle b/build.gradle index 5a30a7a7a..5c7894919 100644 --- a/build.gradle +++ b/build.gradle @@ -94,6 +94,10 @@ repositories { name = "mobius" url = "http://mobiusstrip.eu/maven" } + maven { + name = "builtbroken" + url = "http://ci.builtbroken.com/maven/" + } maven { name = "ue" url = "http://calclavia.com/maven/" @@ -172,6 +176,7 @@ dependencies { provided "mcp.mobius.waila:Waila:${config.waila.version}_${config.minecraft.version}:dev" provided "net.industrial-craft:industrialcraft-2:${config.ic2.version}:dev" provided "net.sengir.forestry:forestry_${config.minecraft.version}:${config.forestry.version}:dev" + provided "notenoughkeys:NeK:${config.minecraft.version}-${config.nek.version}:deobf-dev" provided "qmunity:QmunityLib:${config.qmunitylib.version}:deobf" provided "tmech:TMechworks:${config.minecraft.version}-${config.tmech.version}:deobf" diff --git a/build.properties b/build.properties index 87bd88c75..959ba942b 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ minecraft.version=1.7.10 -forge.version=10.13.2.1291 +forge.version=10.13.3.1395-1710ls oc.version=1.5.11 oc.subversion= @@ -29,6 +29,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 projred.version=4.5.8.59 qmunitylib.version=0.1.105 rc.cf=2219/321 diff --git a/src/main/resources/assets/opencomputers/doc/en_US/item/hoverBoots.md b/src/main/resources/assets/opencomputers/doc/en_US/item/hoverBoots.md index 2f226673e..444dca718 100644 --- a/src/main/resources/assets/opencomputers/doc/en_US/item/hoverBoots.md +++ b/src/main/resources/assets/opencomputers/doc/en_US/item/hoverBoots.md @@ -8,4 +8,4 @@ Either way, these boots have a few useful properties: as long as they have power Additionally, due to always being in kind of a hovering state anyway, they allow you to seamlessly walk up steps of up to one block height. This is particularly handy when sprinting up a mountain, for example, a very commonplace fitness routine amongst Minecrafters. Or so I hear. -The boots can be recharged in an OpenComptuers [charger](../block/charger.md) or any other such device, like the Applied Energistics 2 charger, an IndustrialCraft 2 battery box, or the Energetic Infuser from Thermal Expansion. +The boots can be recharged in an OpenComputers [charger](../block/charger.md) or any other such device, like the Applied Energistics 2 charger, an IndustrialCraft 2 battery box, or the Energetic Infuser from Thermal Expansion. diff --git a/src/main/resources/assets/opencomputers/lib/native.32.so b/src/main/resources/assets/opencomputers/lib/native.32.so index c3c65f0f1..322e90d34 100644 Binary files a/src/main/resources/assets/opencomputers/lib/native.32.so and b/src/main/resources/assets/opencomputers/lib/native.32.so differ diff --git a/src/main/resources/assets/opencomputers/lib/native.64.so b/src/main/resources/assets/opencomputers/lib/native.64.so index b7ecf74e3..05e14fc27 100644 Binary files a/src/main/resources/assets/opencomputers/lib/native.64.so and b/src/main/resources/assets/opencomputers/lib/native.64.so differ diff --git a/src/main/resources/assets/opencomputers/recipes/default.recipes b/src/main/resources/assets/opencomputers/recipes/default.recipes index f7982a03d..2c70a1ff1 100644 --- a/src/main/resources/assets/opencomputers/recipes/default.recipes +++ b/src/main/resources/assets/opencomputers/recipes/default.recipes @@ -7,7 +7,7 @@ analyzer { ["oc:materialCircuitBoardPrinted", nuggetGold, ""]] } hoverBoots { - input: [[nuggetIron, "oc:hoverUpgrade1", nuggetIron] + input: [[nuggetIron, "oc:hoverUpgrade2", nuggetIron] [leather, "oc:droneCase1", leather] [nuggetIron, "oc:capacitor", nuggetIron]] } @@ -253,9 +253,9 @@ hoverUpgrade1 { [feather, "oc:materialCircuitBoardPrinted", feather]] } hoverUpgrade2 { - input: [[end_stone, "oc:circuitChip2", end_stone] + input: [["oc:stoneEndstone", "oc:circuitChip2", "oc:stoneEndstone"] [nuggetGold, ingotIron, nuggetGold] - [end_stone, "oc:materialCircuitBoardPrinted", end_stone]] + ["oc:stoneEndstone", "oc:materialCircuitBoardPrinted", "oc:stoneEndstone"]] } inventoryUpgrade { input: [[plankWood, hopper, plankWood] diff --git a/src/main/scala/li/cil/oc/client/KeyBindings.scala b/src/main/scala/li/cil/oc/client/KeyBindings.scala index 1a0940341..c5c7e3d27 100644 --- a/src/main/scala/li/cil/oc/client/KeyBindings.scala +++ b/src/main/scala/li/cil/oc/client/KeyBindings.scala @@ -2,28 +2,35 @@ package li.cil.oc.client import cpw.mods.fml.client.FMLClientHandler import li.cil.oc.OpenComputers +import net.minecraft.client.settings.GameSettings import net.minecraft.client.settings.KeyBinding import org.lwjgl.input.Keyboard import org.lwjgl.input.Mouse +import scala.collection.mutable + object KeyBindings { - def showExtendedTooltips = isKeybindPressed(extendedTooltip) + val keyBindingChecks = mutable.ArrayBuffer(isKeyBindingPressedVanilla _) - def showMaterialCosts = isKeybindPressed(materialCosts) + val keyBindingNameGetters = mutable.ArrayBuffer(getKeyBindingNameVanilla _) - def isPastingClipboard = isKeybindPressed(clipboardPaste) + def showExtendedTooltips = isKeyBindingPressed(extendedTooltip) - def getKeybindName(keyBinding: KeyBinding) = try { - if (keyBinding.getKeyCode < 0) - Mouse.getButtonName(keyBinding.getKeyCode + 100) - else - Keyboard.getKeyName(keyBinding.getKeyCode) - } - catch { - case _: Throwable => "???" + def showMaterialCosts = isKeyBindingPressed(materialCosts) + + def isPastingClipboard = isKeyBindingPressed(clipboardPaste) + + def getKeyBindingName(keyBinding: KeyBinding) = keyBindingNameGetters.map(_(keyBinding)).collectFirst { + case Some(name) => name + }.getOrElse("???") + + def isKeyBindingPressed(keyBinding: KeyBinding) = keyBindingChecks.forall(_(keyBinding)) + + def getKeyBindingNameVanilla(keyBinding: KeyBinding) = try Some(GameSettings.getKeyDisplayString(keyBinding.getKeyCode)) catch { + case _: Throwable => None } - def isKeybindPressed(keyBinding: KeyBinding) = try { + def isKeyBindingPressedVanilla(keyBinding: KeyBinding) = try { if (keyBinding.getKeyCode < 0) Mouse.isCreated && Mouse.isButtonDown(keyBinding.getKeyCode + 100) else diff --git a/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala b/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala index f9ca8fa48..413af3b2c 100644 --- a/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala +++ b/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala @@ -83,7 +83,7 @@ trait InputBuffer extends DisplayBuffer { case _ => // Wasn't pressed while viewing the screen. } - if (KeyBindings.clipboardPaste.getKeyCode == code && Keyboard.getEventKeyState) { + if (KeyBindings.isPastingClipboard) { buffer.clipboard(GuiScreen.getClipboardString, null) } } @@ -96,7 +96,7 @@ trait InputBuffer extends DisplayBuffer { override protected def mouseClicked(x: Int, y: Int, button: Int) { super.mouseClicked(x, y, button) val isMiddleMouseButton = button == 2 - val isBoundMouseButton = KeyBindings.clipboardPaste.getKeyCode < 0 && button == KeyBindings.clipboardPaste.getKeyCode + 100 + val isBoundMouseButton = KeyBindings.isPastingClipboard if (buffer != null && (isMiddleMouseButton || isBoundMouseButton)) { if (hasKeyboard) { buffer.clipboard(GuiScreen.getClipboardString, null) diff --git a/src/main/scala/li/cil/oc/common/block/Item.scala b/src/main/scala/li/cil/oc/common/block/Item.scala index 17531006c..ab0840a66 100644 --- a/src/main/scala/li/cil/oc/common/block/Item.scala +++ b/src/main/scala/li/cil/oc/common/block/Item.scala @@ -36,7 +36,7 @@ class Item(value: Block) extends ItemBlock(value) { else { lines.add(StatCollector.translateToLocalFormatted( Settings.namespace + "tooltip.MaterialCosts", - KeyBindings.getKeybindName(KeyBindings.materialCosts))) + KeyBindings.getKeyBindingName(KeyBindings.materialCosts))) } case _ => } diff --git a/src/main/scala/li/cil/oc/common/item/Tablet.scala b/src/main/scala/li/cil/oc/common/item/Tablet.scala index f47e23719..77ec032d8 100644 --- a/src/main/scala/li/cil/oc/common/item/Tablet.scala +++ b/src/main/scala/li/cil/oc/common/item/Tablet.scala @@ -41,10 +41,13 @@ import li.cil.oc.util.ExtendedNBT._ import li.cil.oc.util.Rarity import li.cil.oc.util.RotationHelper import li.cil.oc.util.Tooltip +import net.minecraft.client.Minecraft import net.minecraft.entity.Entity import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound +import net.minecraft.server.MinecraftServer +import net.minecraft.server.integrated.IntegratedServer import net.minecraft.world.World import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.event.world.WorldEvent @@ -458,6 +461,14 @@ object Tablet { @SubscribeEvent def onClientTick(e: ClientTickEvent) { Client.cleanUp() + MinecraftServer.getServer match { + case integrated: IntegratedServer if Minecraft.getMinecraft.isGamePaused => + // While the game is paused, manually keep all tablets alive, to avoid + // them being cleared from the cache, causing them to stop. + Client.keepAlive() + Server.keepAlive() + case _ => // Never mind! + } } @SubscribeEvent @@ -530,6 +541,11 @@ object Tablet { def cleanUp() { cache.synchronized(cache.cleanUp()) } + + def keepAlive() = { + // Just touching to update last access time. + cache.getAllPresent(asJavaIterable(cache.asMap.keys)) + } } object Client extends Cache { diff --git a/src/main/scala/li/cil/oc/common/item/traits/Delegate.scala b/src/main/scala/li/cil/oc/common/item/traits/Delegate.scala index fd20d96df..8d0c8b9ee 100644 --- a/src/main/scala/li/cil/oc/common/item/traits/Delegate.scala +++ b/src/main/scala/li/cil/oc/common/item/traits/Delegate.scala @@ -97,7 +97,7 @@ trait Delegate { else { tooltip.add(Localization.localizeImmediately( Settings.namespace + "tooltip.MaterialCosts", - KeyBindings.getKeybindName(KeyBindings.materialCosts))) + KeyBindings.getKeyBindingName(KeyBindings.materialCosts))) } } if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) { diff --git a/src/main/scala/li/cil/oc/common/item/traits/SimpleItem.scala b/src/main/scala/li/cil/oc/common/item/traits/SimpleItem.scala index 4a3aaebb4..cceab03d6 100644 --- a/src/main/scala/li/cil/oc/common/item/traits/SimpleItem.scala +++ b/src/main/scala/li/cil/oc/common/item/traits/SimpleItem.scala @@ -48,7 +48,7 @@ trait SimpleItem extends Item { else { tt.add(Localization.localizeImmediately( Settings.namespace + "tooltip.MaterialCosts", - KeyBindings.getKeybindName(KeyBindings.materialCosts))) + KeyBindings.getKeyBindingName(KeyBindings.materialCosts))) } } if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) { diff --git a/src/main/scala/li/cil/oc/integration/Mods.scala b/src/main/scala/li/cil/oc/integration/Mods.scala index 8c8b83330..0de8a9dbe 100644 --- a/src/main/scala/li/cil/oc/integration/Mods.scala +++ b/src/main/scala/li/cil/oc/integration/Mods.scala @@ -50,6 +50,7 @@ object Mods { val MineFactoryReloaded = new SimpleMod(IDs.MineFactoryReloaded) val Mystcraft = new SimpleMod(IDs.Mystcraft) val NotEnoughItems = new SimpleMod(IDs.NotEnoughItems) + val NotEnoughKeys = new SimpleMod(IDs.NotEnoughKeys) val OpenComputers = new SimpleMod(IDs.OpenComputers) val PortalGun = new SimpleMod(IDs.PortalGun) val ProjectRedCore = new SimpleMod(IDs.ProjectRedCore) @@ -97,6 +98,7 @@ object Mods { integration.ic2.ModIndustrialCraft2, integration.mfr.ModMineFactoryReloaded, integration.mystcraft.ModMystcraft, + integration.nek.ModNotEnoughKeys, integration.projectred.ModProjectRed, integration.railcraft.ModRailcraft, integration.redlogic.ModRedLogic, @@ -177,6 +179,7 @@ object Mods { final val MineFactoryReloaded = "MineFactoryReloaded" final val Mystcraft = "Mystcraft" final val NotEnoughItems = "NotEnoughItems" + final val NotEnoughKeys = "notenoughkeys" final val OpenComputers = "OpenComputers" final val PortalGun = "PortalGun" final val ProjectRedCore = "ProjRed|Core" diff --git a/src/main/scala/li/cil/oc/integration/nek/ModNotEnoughKeys.scala b/src/main/scala/li/cil/oc/integration/nek/ModNotEnoughKeys.scala new file mode 100644 index 000000000..95cdf51df --- /dev/null +++ b/src/main/scala/li/cil/oc/integration/nek/ModNotEnoughKeys.scala @@ -0,0 +1,58 @@ +package li.cil.oc.integration.nek + +import cpw.mods.fml.common.FMLCommonHandler +import cpw.mods.fml.relauncher.Side +import li.cil.oc.OpenComputers +import li.cil.oc.client.KeyBindings +import li.cil.oc.integration.ModProxy +import li.cil.oc.integration.Mods +import modwarriors.notenoughkeys.Helper +import modwarriors.notenoughkeys.api.Api +import modwarriors.notenoughkeys.keys.KeyHelper +import net.minecraft.client.settings.GameSettings +import net.minecraft.client.settings.KeyBinding +import org.lwjgl.input.Keyboard + +object ModNotEnoughKeys extends ModProxy { + override def getMod = Mods.NotEnoughKeys + + override def initialize(): Unit = { + if (FMLCommonHandler.instance.getSide == Side.CLIENT) { + Api.registerMod(OpenComputers.ID, KeyBindings.clipboardPaste.getKeyDescription, KeyBindings.materialCosts.getKeyDescription) + + KeyBindings.keyBindingChecks.append(isKeyBindingPressed) + KeyBindings.keyBindingNameGetters.prepend(getKeyBindingName) // Run before vanilla resolver. + } + } + + def isKeyBindingPressed(kb: KeyBinding): Boolean = try { + Helper.isKeyPressed_KeyBoard(kb) && (Option(KeyHelper.alternates.get(kb.getKeyDescription)) match { + case Some(Array(shift, ctrl, alt)) => + Helper.isShiftKeyDown == shift && + Helper.isCtrlKeyDown == ctrl && + Helper.isAltKeyDown == alt + case _ => true + }) + } + catch { + case _: Throwable => true + } + + def getKeyBindingName(kb: KeyBinding) = try { + Option(KeyHelper.alternates.get(kb.getKeyDescription)) match { + case Some(Array(shift, ctrl, alt)) => + val baseName = GameSettings.getKeyDisplayString(kb.getKeyCode) + val modifierNames = Array( + if (ctrl) GameSettings.getKeyDisplayString(Keyboard.KEY_LCONTROL) else null, + if (alt) GameSettings.getKeyDisplayString(Keyboard.KEY_LMENU) else null, + if (shift) GameSettings.getKeyDisplayString(Keyboard.KEY_LSHIFT) else null). + filter(_ != null). + mkString("+") + Some(modifierNames + "+" + baseName) + case _ => None // Use default. + } + } + catch { + case _: Throwable => None + } +} diff --git a/src/main/scala/li/cil/oc/util/Tooltip.scala b/src/main/scala/li/cil/oc/util/Tooltip.scala index cadc4d62d..30db99a86 100644 --- a/src/main/scala/li/cil/oc/util/Tooltip.scala +++ b/src/main/scala/li/cil/oc/util/Tooltip.scala @@ -21,7 +21,7 @@ object Tooltip { val shouldShorten = (isSubTooltip || font.getStringWidth(tooltip) > maxWidth) && !KeyBindings.showExtendedTooltips if (shouldShorten) { if (isSubTooltip) Seq.empty[String] - else Seq(Localization.localizeImmediately("tooltip.TooLong", KeyBindings.getKeybindName(KeyBindings.extendedTooltip))) + else Seq(Localization.localizeImmediately("tooltip.TooLong", KeyBindings.getKeyBindingName(KeyBindings.extendedTooltip))) } else tooltip. lines.