Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8

Conflicts:
	build.properties
	src/main/resources/assets/opencomputers/recipes/default.recipes
	src/main/scala/li/cil/oc/common/item/Tablet.scala
	src/main/scala/li/cil/oc/integration/Mods.scala
This commit is contained in:
Florian Nücke 2015-05-23 14:37:06 +02:00
commit de7f95d24b
14 changed files with 119 additions and 28 deletions

View File

@ -103,6 +103,10 @@ repositories {
name = "mobius" name = "mobius"
url = "http://mobiusstrip.eu/maven" url = "http://mobiusstrip.eu/maven"
} }
maven {
name = "builtbroken"
url = "http://ci.builtbroken.com/maven/"
}
maven { maven {
name = "ue" name = "ue"
url = "http://calclavia.com/maven/" url = "http://calclavia.com/maven/"
@ -185,6 +189,7 @@ dependencies {
provided "mcp.mobius.waila:Waila:${config.waila.version}_${config.minecraft.version}:dev" provided "mcp.mobius.waila:Waila:${config.waila.version}_${config.minecraft.version}:dev"
provided "net.industrial-craft:industrialcraft-2:${config.ic2.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 "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 "qmunity:QmunityLib:${config.qmunitylib.version}:deobf"
provided "tmech:TMechworks:${config.minecraft.version}-${config.tmech.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/igw/**'
exclude 'li/cil/oc/integration/mfr/**' exclude 'li/cil/oc/integration/mfr/**'
exclude 'li/cil/oc/integration/mystcraft/**' exclude 'li/cil/oc/integration/mystcraft/**'
exclude 'li/cil/oc/integration/nek/**'
exclude 'li/cil/oc/integration/projectred/**' exclude 'li/cil/oc/integration/projectred/**'
exclude 'li/cil/oc/integration/railcraft/**' exclude 'li/cil/oc/integration/railcraft/**'
exclude 'li/cil/oc/integration/redlogic/**' exclude 'li/cil/oc/integration/redlogic/**'

View File

@ -30,6 +30,7 @@ mekanism.version=7.1.2
mfr.cf=2229/626 mfr.cf=2229/626
mfr.version=[1.7.10]2.8.0RC8-86 mfr.version=[1.7.10]2.8.0RC8-86
nei.version=1.0.5.82 nei.version=1.0.5.82
nek.version=1.0.0b35dev
projred.version=4.5.8.59 projred.version=4.5.8.59
qmunitylib.version=0.1.105 qmunitylib.version=0.1.105
rc.cf=2219/321 rc.cf=2219/321

View File

@ -7,7 +7,7 @@ analyzer {
["oc:materialCircuitBoardPrinted", nuggetGold, ""]] ["oc:materialCircuitBoardPrinted", nuggetGold, ""]]
} }
hoverBoots { hoverBoots {
input: [[nuggetIron, "oc:hoverUpgrade1", nuggetIron] input: [[nuggetIron, "oc:hoverUpgrade2", nuggetIron]
[leather, "oc:droneCase1", leather] [leather, "oc:droneCase1", leather]
[nuggetIron, "oc:capacitor", nuggetIron]] [nuggetIron, "oc:capacitor", nuggetIron]]
} }
@ -254,9 +254,9 @@ hoverUpgrade1 {
[feather, "oc:materialCircuitBoardPrinted", feather]] [feather, "oc:materialCircuitBoardPrinted", feather]]
} }
hoverUpgrade2 { hoverUpgrade2 {
input: [[{block="minecraft:end_stone"}, "oc:circuitChip2", {block="minecraft:end_stone"}] input: [["oc:stoneEndstone", "oc:circuitChip2", "oc:stoneEndstone"]
[nuggetGold, ingotIron, nuggetGold] [nuggetGold, ingotIron, nuggetGold]
[{block="minecraft:end_stone"}, "oc:materialCircuitBoardPrinted", {block="minecraft:end_stone"}]] ["oc:stoneEndstone", "oc:materialCircuitBoardPrinted", "oc:stoneEndstone"]]
} }
inventoryUpgrade { inventoryUpgrade {
input: [[plankWood, hopper, plankWood] input: [[plankWood, hopper, plankWood]

View File

@ -1,29 +1,36 @@
package li.cil.oc.client package li.cil.oc.client
import li.cil.oc.OpenComputers import li.cil.oc.OpenComputers
import net.minecraft.client.settings.GameSettings
import net.minecraft.client.settings.KeyBinding import net.minecraft.client.settings.KeyBinding
import net.minecraftforge.fml.client.FMLClientHandler import net.minecraftforge.fml.client.FMLClientHandler
import org.lwjgl.input.Keyboard import org.lwjgl.input.Keyboard
import org.lwjgl.input.Mouse import org.lwjgl.input.Mouse
import scala.collection.mutable
object KeyBindings { 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 { def showMaterialCosts = isKeyBindingPressed(materialCosts)
if (keyBinding.getKeyCode < 0)
Mouse.getButtonName(keyBinding.getKeyCode + 100) def isPastingClipboard = isKeyBindingPressed(clipboardPaste)
else
Keyboard.getKeyName(keyBinding.getKeyCode) def getKeyBindingName(keyBinding: KeyBinding) = keyBindingNameGetters.map(_(keyBinding)).collectFirst {
} case Some(name) => name
catch { }.getOrElse("???")
case _: Throwable => "???"
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) if (keyBinding.getKeyCode < 0)
Mouse.isCreated && Mouse.isButtonDown(keyBinding.getKeyCode + 100) Mouse.isCreated && Mouse.isButtonDown(keyBinding.getKeyCode + 100)
else else

View File

@ -86,7 +86,7 @@ trait InputBuffer extends DisplayBuffer {
case _ => // Wasn't pressed while viewing the screen. case _ => // Wasn't pressed while viewing the screen.
} }
if (KeyBindings.clipboardPaste.getKeyCode == code && Keyboard.getEventKeyState) { if (KeyBindings.isPastingClipboard) {
buffer.clipboard(GuiScreen.getClipboardString, null) buffer.clipboard(GuiScreen.getClipboardString, null)
} }
} }
@ -99,7 +99,7 @@ trait InputBuffer extends DisplayBuffer {
override protected def mouseClicked(x: Int, y: Int, button: Int) { override protected def mouseClicked(x: Int, y: Int, button: Int) {
super.mouseClicked(x, y, button) super.mouseClicked(x, y, button)
val isMiddleMouseButton = button == 2 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 (buffer != null && (isMiddleMouseButton || isBoundMouseButton)) {
if (hasKeyboard) { if (hasKeyboard) {
buffer.clipboard(GuiScreen.getClipboardString, null) buffer.clipboard(GuiScreen.getClipboardString, null)

View File

@ -59,7 +59,7 @@ class Item(value: Block) extends ItemBlock(value) {
else { else {
lines.add(StatCollector.translateToLocalFormatted( lines.add(StatCollector.translateToLocalFormatted(
Settings.namespace + "tooltip.MaterialCosts", Settings.namespace + "tooltip.MaterialCosts",
KeyBindings.getKeybindName(KeyBindings.materialCosts))) KeyBindings.getKeyBindingName(KeyBindings.materialCosts)))
} }
case _ => case _ =>
} }

View File

@ -36,12 +36,15 @@ import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.Rarity import li.cil.oc.util.Rarity
import li.cil.oc.util.RotationHelper import li.cil.oc.util.RotationHelper
import li.cil.oc.util.Tooltip import li.cil.oc.util.Tooltip
import net.minecraft.client.Minecraft
import net.minecraft.client.resources.model.ModelBakery import net.minecraft.client.resources.model.ModelBakery
import net.minecraft.client.resources.model.ModelResourceLocation import net.minecraft.client.resources.model.ModelResourceLocation
import net.minecraft.entity.Entity import net.minecraft.entity.Entity
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.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import net.minecraft.server.MinecraftServer
import net.minecraft.server.integrated.IntegratedServer
import net.minecraft.util.EnumFacing import net.minecraft.util.EnumFacing
import net.minecraft.world.World import net.minecraft.world.World
import net.minecraftforge.event.world.WorldEvent 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 = { def charge(stack: ItemStack, amount: Double, simulate: Boolean): Double = {
if (amount < 0) amount if (amount < 0) amount
else { else {
val data = new TabletData(stack) val data = new TabletData(stack)
val charge = math.min(data.maxEnergy - data.energy, amount) val charge = math.min(data.maxEnergy - data.energy, amount)
if (!simulate) { if (!simulate) {
data.energy += charge data.energy += charge
data.save(stack) data.save(stack)
}
amount - charge
} }
amount - charge
}
} }
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //
@ -456,6 +459,14 @@ object Tablet {
@SubscribeEvent @SubscribeEvent
def onClientTick(e: ClientTickEvent) { def onClientTick(e: ClientTickEvent) {
Client.cleanUp() 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 @SubscribeEvent
@ -528,6 +539,11 @@ object Tablet {
def cleanUp() { def cleanUp() {
cache.synchronized(cache.cleanUp()) cache.synchronized(cache.cleanUp())
} }
def keepAlive() = {
// Just touching to update last access time.
cache.getAllPresent(asJavaIterable(cache.asMap.keys))
}
} }
object Client extends Cache { object Client extends Cache {

View File

@ -94,7 +94,7 @@ trait Delegate {
else { else {
tooltip.add(Localization.localizeImmediately( tooltip.add(Localization.localizeImmediately(
Settings.namespace + "tooltip.MaterialCosts", Settings.namespace + "tooltip.MaterialCosts",
KeyBindings.getKeybindName(KeyBindings.materialCosts))) KeyBindings.getKeyBindingName(KeyBindings.materialCosts)))
} }
} }
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) { if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {

View File

@ -49,7 +49,7 @@ trait SimpleItem extends Item {
else { else {
tt.add(Localization.localizeImmediately( tt.add(Localization.localizeImmediately(
Settings.namespace + "tooltip.MaterialCosts", Settings.namespace + "tooltip.MaterialCosts",
KeyBindings.getKeybindName(KeyBindings.materialCosts))) KeyBindings.getKeyBindingName(KeyBindings.materialCosts)))
} }
} }
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) { if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {

View File

@ -50,6 +50,7 @@ object Mods {
val MineFactoryReloaded = new SimpleMod(IDs.MineFactoryReloaded) val MineFactoryReloaded = new SimpleMod(IDs.MineFactoryReloaded)
val Mystcraft = new SimpleMod(IDs.Mystcraft) val Mystcraft = new SimpleMod(IDs.Mystcraft)
val NotEnoughItems = new SimpleMod(IDs.NotEnoughItems) val NotEnoughItems = new SimpleMod(IDs.NotEnoughItems)
val NotEnoughKeys = new SimpleMod(IDs.NotEnoughKeys)
val OpenComputers = new SimpleMod(IDs.OpenComputers) val OpenComputers = new SimpleMod(IDs.OpenComputers)
val PortalGun = new SimpleMod(IDs.PortalGun) val PortalGun = new SimpleMod(IDs.PortalGun)
val ProjectRedCore = new SimpleMod(IDs.ProjectRedCore) val ProjectRedCore = new SimpleMod(IDs.ProjectRedCore)
@ -97,6 +98,7 @@ object Mods {
// integration.ic2.ModIndustrialCraft2, // integration.ic2.ModIndustrialCraft2,
// integration.mfr.ModMineFactoryReloaded, // integration.mfr.ModMineFactoryReloaded,
// integration.mystcraft.ModMystcraft, // integration.mystcraft.ModMystcraft,
// integration.nek.ModNotEnoughKeys,
// integration.projectred.ModProjectRed, // integration.projectred.ModProjectRed,
// integration.railcraft.ModRailcraft, // integration.railcraft.ModRailcraft,
// integration.redlogic.ModRedLogic, // integration.redlogic.ModRedLogic,
@ -177,6 +179,7 @@ object Mods {
final val MineFactoryReloaded = "MineFactoryReloaded" final val MineFactoryReloaded = "MineFactoryReloaded"
final val Mystcraft = "Mystcraft" final val Mystcraft = "Mystcraft"
final val NotEnoughItems = "NotEnoughItems" final val NotEnoughItems = "NotEnoughItems"
final val NotEnoughKeys = "notenoughkeys"
final val OpenComputers = "OpenComputers" final val OpenComputers = "OpenComputers"
final val PortalGun = "PortalGun" final val PortalGun = "PortalGun"
final val ProjectRedCore = "ProjRed|Core" final val ProjectRedCore = "ProjRed|Core"

View File

@ -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
}
}

View File

@ -21,7 +21,7 @@ object Tooltip {
val shouldShorten = (isSubTooltip || font.getStringWidth(tooltip) > maxWidth) && !KeyBindings.showExtendedTooltips val shouldShorten = (isSubTooltip || font.getStringWidth(tooltip) > maxWidth) && !KeyBindings.showExtendedTooltips
if (shouldShorten) { if (shouldShorten) {
if (isSubTooltip) Seq.empty[String] 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. else tooltip.
lines. lines.