Homogeneity, ho!

This commit is contained in:
Florian Nücke 2015-10-17 13:42:51 +02:00
parent 1928cb3704
commit f0ff3796c1
21 changed files with 72 additions and 72 deletions

View File

@ -207,11 +207,11 @@ class ClassTransformer extends IClassTransformer {
toInject.add(new TypeInsnNode(Opcodes.INSTANCEOF, "li/cil/oc/common/entity/Drone"))
val skip = new LabelNode()
toInject.add(new JumpInsnNode(Opcodes.IFEQ, skip))
toInject.add(new LdcInsnNode(double2Double(0.0)))
toInject.add(new LdcInsnNode(Double.box(0.0)))
toInject.add(new VarInsnNode(Opcodes.DSTORE, 16))
toInject.add(new LdcInsnNode(double2Double(0.0)))
toInject.add(new LdcInsnNode(Double.box(0.0)))
toInject.add(new VarInsnNode(Opcodes.DSTORE, 18))
toInject.add(new LdcInsnNode(double2Double(-0.75)))
toInject.add(new LdcInsnNode(Double.box(-0.75)))
toInject.add(new VarInsnNode(Opcodes.DSTORE, 20))
toInject.add(skip)
instructions.insertBefore(varNode, toInject)

View File

@ -829,14 +829,14 @@ object TextBuffer {
args += player
args += name
if (owner.precisionMode) {
args += double2Double(x)
args += double2Double(y)
args += Double.box(x)
args += Double.box(y)
}
else {
args += int2Integer(x.toInt + 1)
args += int2Integer(y.toInt + 1)
args += Int.box(x.toInt + 1)
args += Int.box(y.toInt + 1)
}
args += int2Integer(data)
args += Int.box(data)
if (Settings.get.inputUsername) {
args += player.getCommandSenderName
}

View File

@ -233,24 +233,24 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
override def entityInit() {
// Running or not.
dataWatcher.addObject(2, byte2Byte(0: Byte))
dataWatcher.addObject(2, Byte.box(0: Byte))
// Target position.
dataWatcher.addObject(3, float2Float(0f))
dataWatcher.addObject(4, float2Float(0f))
dataWatcher.addObject(5, float2Float(0f))
dataWatcher.addObject(3, Float.box(0f))
dataWatcher.addObject(4, Float.box(0f))
dataWatcher.addObject(5, Float.box(0f))
// Max acceleration.
dataWatcher.addObject(6, float2Float(0f))
dataWatcher.addObject(6, Float.box(0f))
// Selected inventory slot.
dataWatcher.addObject(7, byte2Byte(0: Byte))
dataWatcher.addObject(7, Byte.box(0: Byte))
// Current and maximum energy.
dataWatcher.addObject(8, int2Integer(0))
dataWatcher.addObject(9, int2Integer(100))
dataWatcher.addObject(8, Int.box(0))
dataWatcher.addObject(9, Int.box(100))
// Status text.
dataWatcher.addObject(10, "")
// Inventory size for client.
dataWatcher.addObject(11, byte2Byte(0: Byte))
dataWatcher.addObject(11, Byte.box(0: Byte))
// Light color.
dataWatcher.addObject(12, int2Integer(0x66DD55))
dataWatcher.addObject(12, Int.box(0x66DD55))
}
def initializeAfterPlacement(stack: ItemStack, player: EntityPlayer, position: Vec3) {
@ -299,28 +299,28 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
def lightColor = dataWatcher.getWatchableObjectInt(12)
def setRunning(value: Boolean) = dataWatcher.updateObject(2, byte2Byte(if (value) 1: Byte else 0: Byte))
def setRunning(value: Boolean) = dataWatcher.updateObject(2, Byte.box(if (value) 1: Byte else 0: Byte))
// Round target values to low accuracy to avoid floating point errors accumulating.
def targetX_=(value: Float): Unit = dataWatcher.updateObject(3, float2Float(math.round(value * 4) / 4f))
def targetX_=(value: Float): Unit = dataWatcher.updateObject(3, Float.box(math.round(value * 4) / 4f))
def targetY_=(value: Float): Unit = dataWatcher.updateObject(4, float2Float(math.round(value * 4) / 4f))
def targetY_=(value: Float): Unit = dataWatcher.updateObject(4, Float.box(math.round(value * 4) / 4f))
def targetZ_=(value: Float): Unit = dataWatcher.updateObject(5, float2Float(math.round(value * 4) / 4f))
def targetZ_=(value: Float): Unit = dataWatcher.updateObject(5, Float.box(math.round(value * 4) / 4f))
def targetAcceleration_=(value: Float): Unit = dataWatcher.updateObject(6, float2Float(math.max(0, math.min(maxAcceleration, value))))
def targetAcceleration_=(value: Float): Unit = dataWatcher.updateObject(6, Float.box(math.max(0, math.min(maxAcceleration, value))))
def setSelectedSlot(value: Int) = dataWatcher.updateObject(7, byte2Byte(value.toByte))
def setSelectedSlot(value: Int) = dataWatcher.updateObject(7, Byte.box(value.toByte))
def globalBuffer_=(value: Int) = dataWatcher.updateObject(8, int2Integer(value))
def globalBuffer_=(value: Int) = dataWatcher.updateObject(8, Int.box(value))
def globalBufferSize_=(value: Int) = dataWatcher.updateObject(9, int2Integer(value))
def globalBufferSize_=(value: Int) = dataWatcher.updateObject(9, Int.box(value))
def statusText_=(value: String) = dataWatcher.updateObject(10, Option(value).fold("")(_.lines.map(_.take(10)).take(2).mkString("\n")))
def inventorySize_=(value: Int) = dataWatcher.updateObject(11, byte2Byte(value.toByte))
def inventorySize_=(value: Int) = dataWatcher.updateObject(11, Byte.box(value.toByte))
def lightColor_=(value: Int) = dataWatcher.updateObject(12, int2Integer(value))
def lightColor_=(value: Int) = dataWatcher.updateObject(12, Int.box(value))
@SideOnly(Side.CLIENT)
override def setPositionAndRotation2(x: Double, y: Double, z: Double, yaw: Float, pitch: Float, data: Int) {
@ -451,9 +451,9 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
val direction = Vec3.createVectorHelper(entity.posX - posX, entity.posY + entity.getEyeHeight - posY, entity.posZ - posZ).normalize()
if (!world.isRemote) {
if (Settings.get.inputUsername)
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord), entity.getCommandSenderName)
machine.signal("hit", Double.box(direction.xCoord), Double.box(direction.zCoord), Double.box(direction.yCoord), entity.getCommandSenderName)
else
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord))
machine.signal("hit", Double.box(direction.xCoord), Double.box(direction.zCoord), Double.box(direction.yCoord))
}
motionX = (motionX - direction.xCoord) * 0.5f
motionY = (motionY - direction.yCoord) * 0.5f

View File

@ -47,14 +47,14 @@ object GeolyzerHandler {
val block = world.getBlock(blockPos)
e.data += "name" -> Block.blockRegistry.getNameForObject(block)
e.data += "metadata" -> int2Integer(world.getBlockMetadata(blockPos))
e.data += "hardness" -> float2Float(world.getBlockHardness(blockPos))
e.data += "harvestLevel" -> int2Integer(world.getBlockHarvestLevel(blockPos))
e.data += "metadata" -> Int.box(world.getBlockMetadata(blockPos))
e.data += "hardness" -> Float.box(world.getBlockHardness(blockPos))
e.data += "harvestLevel" -> Int.box(world.getBlockHarvestLevel(blockPos))
e.data += "harvestTool" -> world.getBlockHarvestTool(blockPos)
e.data += "color" -> int2Integer(world.getBlockMapColor(blockPos).colorValue)
e.data += "color" -> Int.box(world.getBlockMapColor(blockPos).colorValue)
if (Settings.get.insertIdsInConverters)
e.data += "id" -> int2Integer(Block.getIdFromBlock(block))
e.data += "id" -> Int.box(Block.getIdFromBlock(block))
}
private def isFluid(block: Block) = FluidRegistry.lookupFluidForBlock(block) != null

View File

@ -182,7 +182,7 @@ class Tablet(val parent: Delegator) extends traits.Delegate with Chargeable {
val computer = Tablet.get(stack, player).machine
if (computer.isRunning) {
val data = new NBTTagCompound()
computer.node.sendToReachable("tablet.use", data, stack, player, position, ForgeDirection.getOrientation(side), float2Float(hitX), float2Float(hitY), float2Float(hitZ))
computer.node.sendToReachable("tablet.use", data, stack, player, position, ForgeDirection.getOrientation(side), Float.box(hitX), Float.box(hitY), Float.box(hitZ))
if (!data.hasNoTags) {
computer.signal("tablet_use", data)
}

View File

@ -40,7 +40,7 @@ object DroneTemplate extends Template {
data.save(stack)
val energy = Settings.get.droneBaseCost + complexity(inventory) * Settings.get.droneComplexityCost
Array(stack, double2Double(energy))
Array(stack, Double.box(energy))
}
def selectDisassembler(stack: ItemStack) = api.Items.get(stack) == api.Items.get(Constants.ItemName.Drone)

View File

@ -36,7 +36,7 @@ object MicrocontrollerTemplate extends Template {
val stack = data.createItemStack()
val energy = Settings.get.microcontrollerBaseCost + complexity(inventory) * Settings.get.microcontrollerComplexityCost
Array(stack, double2Double(energy))
Array(stack, Double.box(energy))
}
def selectDisassembler(stack: ItemStack) = api.Items.get(stack) == api.Items.get(Constants.BlockName.Microcontroller)

View File

@ -38,7 +38,7 @@ object RobotTemplate extends Template {
val stack = data.createItemStack()
val energy = Settings.get.robotBaseCost + complexity(inventory) * Settings.get.robotComplexityCost
Array(stack, double2Double(energy))
Array(stack, Double.box(energy))
}
def selectDisassembler(stack: ItemStack) = api.Items.get(stack) == api.Items.get(Constants.BlockName.Robot)

View File

@ -49,7 +49,7 @@ object TabletTemplate extends Template {
data.save(stack)
val energy = Settings.get.tabletBaseCost + complexity(inventory) * Settings.get.tabletComplexityCost
Array(stack, double2Double(energy))
Array(stack, Double.box(energy))
}
def selectDisassembler(stack: ItemStack) = api.Items.get(stack) == api.Items.get(Constants.ItemName.Tablet)

View File

@ -44,7 +44,7 @@ class Redstone extends traits.Environment with traits.BundledRedstoneAware {
super.onRedstoneInputChanged(side, oldMaxValue, newMaxValue)
if (node != null && node.network != null) {
node.connect(dummyNode)
dummyNode.sendToNeighbors("redstone.changed", side, int2Integer(oldMaxValue), int2Integer(newMaxValue))
dummyNode.sendToNeighbors("redstone.changed", side, Int.box(oldMaxValue), Int.box(newMaxValue))
}
}
}

View File

@ -519,7 +519,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
override protected def onRedstoneInputChanged(side: ForgeDirection, oldMaxValue: Int, newMaxValue: Int) {
super.onRedstoneInputChanged(side, oldMaxValue, newMaxValue)
servers collect {
case Some(server) => server.machine.node.sendToNeighbors("redstone.changed", toLocal(side), int2Integer(oldMaxValue), int2Integer(newMaxValue))
case Some(server) => server.machine.node.sendToNeighbors("redstone.changed", toLocal(side), Int.box(oldMaxValue), Int.box(newMaxValue))
}
}

View File

@ -218,7 +218,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
override protected def onRedstoneInputChanged(side: ForgeDirection, oldMaxValue: Int, newMaxValue: Int) {
super.onRedstoneInputChanged(side, oldMaxValue, newMaxValue)
machine.node.sendToNeighbors("redstone.changed", toLocal(side), int2Integer(oldMaxValue), int2Integer(newMaxValue))
machine.node.sendToNeighbors("redstone.changed", toLocal(side), Int.box(oldMaxValue), Int.box(newMaxValue))
}
// ----------------------------------------------------------------------- //

View File

@ -15,12 +15,12 @@ object ConverterSeeds extends Converter {
if (api.isHandledByAgricraft(stack) && stack.hasTagCompound && stack.getTagCompound.getBoolean("analyzed")) api.getSeedStats(stack) match {
case stats: ISeedStats =>
output += "agricraft" -> Map(
"gain" -> float2Float(stats.getGain),
"maxGain" -> float2Float(stats.getMaxGain),
"growth" -> float2Float(stats.getGrowth),
"maxGrowth" -> float2Float(stats.getMaxGrowth),
"strength" -> float2Float(stats.getStrength),
"maxStrength" -> float2Float(stats.getMaxStrength)
"gain" -> Float.box(stats.getGain),
"maxGain" -> Float.box(stats.getMaxGain),
"growth" -> Float.box(stats.getGrowth),
"maxGrowth" -> Float.box(stats.getMaxGrowth),
"strength" -> Float.box(stats.getStrength),
"maxStrength" -> Float.box(stats.getMaxStrength)
)
case _ =>
}

View File

@ -12,17 +12,17 @@ object EventHandlerAgriCraft {
val world = e.host.world
ApiHandler.Api.foreach(api => if (api.isCrops(world, e.x, e.y, e.z)) {
e.data += "growth" -> float2Float(if (api.isMature(world, e.x, e.y, e.z)) 1f else 0f)
e.data += "growth" -> Float.box(if (api.isMature(world, e.x, e.y, e.z)) 1f else 0f)
if (api.isAnalyzed(world, e.x, e.y, e.z)) {
api.getStats(world, e.x, e.y, e.z) match {
case stats: ISeedStats =>
e.data += "gain" -> float2Float(stats.getGain)
e.data += "maxGain" -> float2Float(stats.getMaxGain)
e.data += "growth" -> float2Float(stats.getGrowth)
e.data += "maxGrowth" -> float2Float(stats.getMaxGrowth)
e.data += "strength" -> float2Float(stats.getStrength)
e.data += "maxStrength" -> float2Float(stats.getMaxStrength)
e.data += "gain" -> Float.box(stats.getGain)
e.data += "maxGain" -> Float.box(stats.getMaxGain)
e.data += "growth" -> Float.box(stats.getGrowth)
e.data += "maxGrowth" -> Float.box(stats.getMaxGrowth)
e.data += "strength" -> Float.box(stats.getStrength)
e.data += "maxStrength" -> Float.box(stats.getMaxStrength)
case _ => // Invalid crop.
}
}

View File

@ -16,7 +16,7 @@ object ItemCharge {
def charge(stack: ItemStack, amount: Double): Double = {
if (stack != null) chargers.find(charger => IMC.tryInvokeStatic(charger._1, stack)(false)) match {
case Some(charger) => IMC.tryInvokeStatic(charger._2, stack, double2Double(amount), java.lang.Boolean.FALSE)(0.0)
case Some(charger) => IMC.tryInvokeStatic(charger._2, stack, Double.box(amount), java.lang.Boolean.FALSE)(0.0)
case _ => 0.0
}
else 0.0

View File

@ -20,8 +20,8 @@ object Wrench {
def isWrench(stack: ItemStack): Boolean = stack != null && checks.exists(IMC.tryInvokeStatic(_, stack)(false))
def holdsApplicableWrench(player: EntityPlayer, position: BlockPosition): Boolean =
player.getHeldItem != null && usages.exists(IMC.tryInvokeStatic(_, player, int2Integer(position.x), int2Integer(position.y), int2Integer(position.z), boolean2Boolean(false))(false))
player.getHeldItem != null && usages.exists(IMC.tryInvokeStatic(_, player, Int.box(position.x), Int.box(position.y), Int.box(position.z), Boolean.box(false))(false))
def wrenchUsed(player: EntityPlayer, position: BlockPosition): Unit =
if (player.getHeldItem != null) usages.foreach(IMC.tryInvokeStaticVoid(_, player, int2Integer(position.x), int2Integer(position.y), int2Integer(position.z), boolean2Boolean(true)))
if (player.getHeldItem != null) usages.foreach(IMC.tryInvokeStaticVoid(_, player, Int.box(position.x), Int.box(position.y), Int.box(position.z), Boolean.box(true)))
}

View File

@ -15,12 +15,12 @@ object ConverterNBT extends api.driver.Converter {
}
private def convert(nbt: NBTBase): AnyRef = nbt match {
case tag: NBTTagByte => byte2Byte(tag.func_150290_f())
case tag: NBTTagShort => short2Short(tag.func_150289_e())
case tag: NBTTagInt => int2Integer(tag.func_150287_d())
case tag: NBTTagLong => long2Long(tag.func_150291_c())
case tag: NBTTagFloat => float2Float(tag.func_150288_h())
case tag: NBTTagDouble => double2Double(tag.func_150286_g())
case tag: NBTTagByte => Byte.box(tag.func_150290_f())
case tag: NBTTagShort => Short.box(tag.func_150289_e())
case tag: NBTTagInt => Int.box(tag.func_150287_d())
case tag: NBTTagLong => Long.box(tag.func_150291_c())
case tag: NBTTagFloat => Float.box(tag.func_150288_h())
case tag: NBTTagDouble => Double.box(tag.func_150286_g())
case tag: NBTTagByteArray => tag.func_150292_c()
case tag: NBTTagString => tag.func_150285_a_()
case tag: NBTTagList =>

View File

@ -13,16 +13,16 @@ object EventHandlerVanilla {
val world = e.host.world
val block = world.getBlock(e.x, e.y, e.z)
if (block.isInstanceOf[BlockCrops] || block == Blocks.melon_stem || block == Blocks.pumpkin_stem || block == Blocks.carrots || block == Blocks.potatoes) {
e.data += "growth" -> float2Float((world.getBlockMetadata(e.x, e.y, e.z) / 7f) max 0 min 1)
e.data += "growth" -> Float.box((world.getBlockMetadata(e.x, e.y, e.z) / 7f) max 0 min 1)
}
if (block == Blocks.cocoa) {
e.data += "growth" -> float2Float(((world.getBlockMetadata(e.x, e.y, e.z) >> 2) / 2f) max 0 min 1)
e.data += "growth" -> Float.box(((world.getBlockMetadata(e.x, e.y, e.z) >> 2) / 2f) max 0 min 1)
}
if (block == Blocks.nether_wart) {
e.data += "growth" -> float2Float((world.getBlockMetadata(e.x, e.y, e.z) / 3f) max 0 min 1)
e.data += "growth" -> Float.box((world.getBlockMetadata(e.x, e.y, e.z) / 3f) max 0 min 1)
}
if (block == Blocks.melon_block || block == Blocks.pumpkin || block == Blocks.cactus || block == Blocks.reeds) {
e.data += "growth" -> float2Float(1f)
e.data += "growth" -> Float.box(1f)
}
}
}

View File

@ -32,7 +32,7 @@ trait RedstoneSignaller extends prefab.ManagedEnvironment {
// ----------------------------------------------------------------------- //
def onRedstoneChanged(side: AnyRef, oldMaxValue: Int, newMaxValue: Int): Unit = {
node.sendToReachable("computer.signal", "redstone_changed", side, int2Integer(oldMaxValue), int2Integer(newMaxValue))
node.sendToReachable("computer.signal", "redstone_changed", side, Int.box(oldMaxValue), Int.box(newMaxValue))
if (oldMaxValue < wakeThreshold && newMaxValue >= wakeThreshold) {
if (wakeNeighborsOnly)
node.sendToNeighbors("computer.start")

View File

@ -59,7 +59,7 @@ trait RedstoneVanilla extends RedstoneSignaller {
super.onMessage(message)
if (message.name == "redstone.changed") message.data match {
case Array(side: ForgeDirection, oldMaxValue: Number, newMaxValue: Number) =>
onRedstoneChanged(int2Integer(side.ordinal()), oldMaxValue.intValue(), newMaxValue.intValue())
onRedstoneChanged(Int.box(side.ordinal()), oldMaxValue.intValue(), newMaxValue.intValue())
case _ =>
}
}

View File

@ -17,7 +17,7 @@ class ItemStackWrapper(val inner: ItemStack) extends Ordered[ItemStackWrapper] {
else this.id - that.id
}
override def hashCode() = Objects.hash(int2Integer(id), int2Integer(damage))
override def hashCode() = Objects.hash(Int.box(id), Int.box(damage))
override def equals(obj: scala.Any) = obj match {
case that: ItemStackWrapper => compare(that) == 0