diff --git a/build.gradle b/build.gradle index a63e09d76..6a384060b 100644 --- a/build.gradle +++ b/build.gradle @@ -103,6 +103,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/" @@ -185,6 +189,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" @@ -228,6 +233,7 @@ sourceSets { exclude 'li/cil/oc/integration/igw/**' exclude 'li/cil/oc/integration/mfr/**' exclude 'li/cil/oc/integration/mystcraft/**' + exclude 'li/cil/oc/integration/nek/**' exclude 'li/cil/oc/integration/projectred/**' exclude 'li/cil/oc/integration/railcraft/**' exclude 'li/cil/oc/integration/redlogic/**' diff --git a/build.properties b/build.properties index 1fb6cfc53..3e6a6063e 100644 --- a/build.properties +++ b/build.properties @@ -30,6 +30,7 @@ mekanism.version=7.1.2 mfr.cf=2229/626 mfr.version=[1.7.10]2.8.0RC8-86 nei.version=1.0.5.82 +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/lib/native.32.so b/src/main/resources/assets/opencomputers/lib/native.32.so index 8963fe8b7..4c47ab5ee 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 3303558cb..c6fe8fa82 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 43e7bdf77..cd16eb414 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]] } @@ -254,9 +254,9 @@ hoverUpgrade1 { [feather, "oc:materialCircuitBoardPrinted", feather]] } hoverUpgrade2 { - input: [[{block="minecraft:end_stone"}, "oc:circuitChip2", {block="minecraft:end_stone"}] + input: [["oc:stoneEndstone", "oc:circuitChip2", "oc:stoneEndstone"] [nuggetGold, ingotIron, nuggetGold] - [{block="minecraft:end_stone"}, "oc:materialCircuitBoardPrinted", {block="minecraft: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 cb938d823..586b33334 100644 --- a/src/main/scala/li/cil/oc/client/KeyBindings.scala +++ b/src/main/scala/li/cil/oc/client/KeyBindings.scala @@ -1,29 +1,36 @@ package li.cil.oc.client import li.cil.oc.OpenComputers +import net.minecraft.client.settings.GameSettings import net.minecraft.client.settings.KeyBinding import net.minecraftforge.fml.client.FMLClientHandler 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 2a64b2dce..718598452 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 @@ -86,7 +86,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) } } @@ -99,7 +99,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 57904efb9..db495ee0c 100644 --- a/src/main/scala/li/cil/oc/common/block/Item.scala +++ b/src/main/scala/li/cil/oc/common/block/Item.scala @@ -59,7 +59,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 793334e8d..9731f683a 100644 --- a/src/main/scala/li/cil/oc/common/item/Tablet.scala +++ b/src/main/scala/li/cil/oc/common/item/Tablet.scala @@ -36,12 +36,15 @@ 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.client.resources.model.ModelBakery import net.minecraft.client.resources.model.ModelResourceLocation 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.util.EnumFacing import net.minecraft.world.World import net.minecraftforge.event.world.WorldEvent @@ -126,14 +129,14 @@ class Tablet(val parent: Delegator) extends traits.Delegate with CustomModel wit def charge(stack: ItemStack, amount: Double, simulate: Boolean): Double = { if (amount < 0) amount else { - val data = new TabletData(stack) - val charge = math.min(data.maxEnergy - data.energy, amount) - if (!simulate) { - data.energy += charge - data.save(stack) + val data = new TabletData(stack) + val charge = math.min(data.maxEnergy - data.energy, amount) + if (!simulate) { + data.energy += charge + data.save(stack) + } + amount - charge } - amount - charge - } } // ----------------------------------------------------------------------- // @@ -456,6 +459,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 @@ -528,6 +539,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 41fdef093..e4b225883 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 @@ -94,7 +94,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 257b776c8..9a83c3d46 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 @@ -49,7 +49,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 07865e769..6705485b0 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 b8cd79865..147feaf28 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.