diff --git a/src/main/scala/resonantinduction/archaic/crate/TileCrate.scala b/src/main/scala/resonantinduction/archaic/crate/TileCrate.scala index 68f86312e..a92887e7b 100644 --- a/src/main/scala/resonantinduction/archaic/crate/TileCrate.scala +++ b/src/main/scala/resonantinduction/archaic/crate/TileCrate.scala @@ -12,14 +12,11 @@ import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.oredict.OreDictionary import resonant.api.IFilterable import resonant.api.IRemovable.ISneakPickup -import resonant.content.spatial.block.SpatialTile -import resonant.engine.ResonantEngine -import resonant.lib.content.prefab.TInventory +import resonant.lib.content.prefab.java.TileInventory import resonant.lib.network.ByteBufWrapper._ import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.TPacketReceiver import resonantinduction.archaic.ArchaicBlocks -import universalelectricity.core.transform.vector.Vector3 /** Basic single stack inventory. *

@@ -42,7 +39,7 @@ object TileCrate { final val maxSize: Int = 2 } -class TileCrate extends SpatialTile(Material.rock) with TInventory with TPacketReceiver with IFilterable with ISneakPickup { +class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with IFilterable with ISneakPickup { /** delay from last click */ var prevClickTime: Long = -1000 @@ -66,7 +63,7 @@ class TileCrate extends SpatialTile(Material.rock) with TInventory with TPacketR } if (doUpdate) { doUpdate = false - ResonantEngine.instance.packetHandler.sendToAllAround(getDescriptionPacket, this.worldObj, new Vector3(this), 50) + sendPacket(getDescPacket) } } } @@ -90,7 +87,7 @@ class TileCrate extends SpatialTile(Material.rock) with TInventory with TPacketR if (worldObj == null || !worldObj.isRemote) { var newSampleStack: ItemStack = null var rebuildBase: Boolean = false - for (slot <- getSizeInventory) { + for (slot <- 0 until getSizeInventory) { val slotStack: ItemStack = this.getInventory.getStackInSlot(slot) if (slotStack != null && slotStack.getItem != null && slotStack.stackSize > 0) { @@ -210,15 +207,16 @@ class TileCrate extends SpatialTile(Material.rock) with TInventory with TPacketR } override def getDescPacket: PacketTile = { - var packet: PacketTile = null + var packet: PacketTile = new PacketTile(this) this.buildSampleStack val stack: ItemStack = this.getSampleStack if (stack != null) { - - packet = new PacketTile(this, true, stack.writeToNBT(new NBTTagCompound), stack.stackSize) + packet <<< true + packet <<< stack + packet <<< stack.stackSize } else { - packet = new PacketTile(this, false) + packet <<< false } return packet } diff --git a/src/main/scala/resonantinduction/archaic/fluid/tank/ItemBlockTank.scala b/src/main/scala/resonantinduction/archaic/fluid/tank/ItemBlockTank.scala index e70b35623..00266da61 100644 --- a/src/main/scala/resonantinduction/archaic/fluid/tank/ItemBlockTank.scala +++ b/src/main/scala/resonantinduction/archaic/fluid/tank/ItemBlockTank.scala @@ -44,11 +44,11 @@ class ItemBlockTank(block: Block) extends ItemBlock(block: Block) with IFluidCon } override def getUnlocalizedName(itemStack: ItemStack): String = { - val translation: String = LanguageUtility.getLocal(getUnlocalizedName + "." + itemStack.getItemDamage) + val translation: String = LanguageUtility.getLocal(getUnlocalizedName() + "." + itemStack.getItemDamage) if (translation == null || translation.isEmpty) { - return getUnlocalizedName + return getUnlocalizedName() } - return getUnlocalizedName + "." + itemStack.getItemDamage + return getUnlocalizedName() + "." + itemStack.getItemDamage } override def placeBlockAt(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float, metadata: Int): Boolean = { diff --git a/src/main/scala/resonantinduction/atomic/AtomicContent.scala b/src/main/scala/resonantinduction/atomic/AtomicContent.scala index 668c16ca4..646e7aff6 100644 --- a/src/main/scala/resonantinduction/atomic/AtomicContent.scala +++ b/src/main/scala/resonantinduction/atomic/AtomicContent.scala @@ -80,8 +80,11 @@ object AtomicContent extends ContentHolder super.postInit() recipes += shaped(new ItemStack(itemAntimatter, 1, 1), itemAntimatter, itemAntimatter, itemAntimatter, itemAntimatter, itemAntimatter, AtomicContent.itemAntimatter, itemAntimatter, itemAntimatter) recipes += shaped(new ItemStack(itemAntimatter, 8, 0), new ItemStack(AtomicContent.itemAntimatter, 1, 1)) + + recipes += shaped(new ItemStack(blockSteamFunnel, 2), " B ", "B B", "B B", 'B', UniversalRecipe.SECONDARY_METAL.get) recipes += shaped(new ItemStack(blockSteamFunnel, 2), " B ", "B B", "B B", 'B', "ingotIron") + recipes += shaped(blockQuantumAssembler, "CCC", "SXS", "SSS", 'X', blockCentrifuge, 'C', UniversalRecipe.CIRCUIT_T3.get, 'S', UniversalRecipe.PRIMARY_PLATE.get) recipes += shaped(blockFulmination, "OSO", "SCS", "OSO", 'O', Blocks.obsidian, 'C', UniversalRecipe.CIRCUIT_T2.get, 'S', UniversalRecipe.PRIMARY_PLATE.get) recipes += shaped(blockAccelerator, "SCS", "CMC", "SCS", 'M', UniversalRecipe.MOTOR.get, 'C', UniversalRecipe.CIRCUIT_T3.get, 'S', UniversalRecipe.PRIMARY_PLATE.get) @@ -92,19 +95,22 @@ object AtomicContent extends ContentHolder recipes += shaped(new ItemStack(blockSiren, 2), "NPN", 'N', Blocks.noteblock, 'P', UniversalRecipe.SECONDARY_PLATE.get) recipes += shaped(blockReactorCell, "SCS", "MEM", "SCS", 'E', "cellEmpty", 'C', UniversalRecipe.CIRCUIT_T2.get, 'S', UniversalRecipe.PRIMARY_PLATE.get, 'M', UniversalRecipe.MOTOR.get) recipes += shaped(blockFusionCore, "CPC", "PFP", "CPC", 'P', UniversalRecipe.PRIMARY_PLATE.get, 'F', AtomicContent.blockReactorCell, 'C', UniversalRecipe.CIRCUIT_T3.get) - recipes += shaped(new ItemStack(itemCell, 16), " T ", "TGT", " T ", 'T', "ingotTin", 'G', Blocks.glass) recipes += shaped(blockThermometer, "SSS", "GCG", "GSG", 'S', UniversalRecipe.PRIMARY_METAL.get, 'G', Blocks.glass, 'C', UniversalRecipe.CIRCUIT_T1.get) recipes += shaped(blockControlRod, "I", "I", "I", 'I', Items.iron_ingot) recipes += shaped(itemFissileFuel, "CUC", "CUC", "CUC", 'U', "ingotUranium", 'C', "cellEmpty") recipes += shaped(itemBreedingRod, "CUC", "CUC", "CUC", 'U', "breederUranium", 'C', "cellEmpty") - recipes += shaped(new ItemStack(blockElectromagnet, 2, 0), "BBB", "BMB", "BBB", 'B', UniversalRecipe.SECONDARY_METAL.get, 'M', UniversalRecipe.MOTOR.get) + + //Hazmat recipes recipes += shaped(itemHazmatTop, "SSS", "BAB", "SCS", 'A', Items.leather_helmet, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool) recipes += shaped(itemHazmatBody, "SSS", "BAB", "SCS", 'A', Items.leather_chestplate, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool) recipes += shaped(itemHazmatLeggings, "SSS", "BAB", "SCS", 'A', Items.leather_leggings, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool) recipes += shaped(itemHazmatBoots, "SSS", "BAB", "SCS", 'A', Items.leather_boots, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool) + //Electro magnets + recipes += shaped(new ItemStack(blockElectromagnet, 2, 0), "BBB", "BMB", "BBB", 'B', UniversalRecipe.SECONDARY_METAL.get, 'M', UniversalRecipe.MOTOR.get) recipes += shapeless(new ItemStack(AtomicContent.blockElectromagnet, 1, 1), AtomicContent.blockElectromagnet, Blocks.glass) + recipes += shapeless(new ItemStack(AtomicContent.itemWaterCell), "cellEmpty", Items.water_bucket) } diff --git a/src/main/scala/resonantinduction/atomic/gate/ItemQuantumGlyph.scala b/src/main/scala/resonantinduction/atomic/gate/ItemQuantumGlyph.scala index b09253dea..69fdcb9db 100644 --- a/src/main/scala/resonantinduction/atomic/gate/ItemQuantumGlyph.scala +++ b/src/main/scala/resonantinduction/atomic/gate/ItemQuantumGlyph.scala @@ -19,10 +19,8 @@ import scala.util.control.Breaks._ import resonant.lib.wrapper.WrapList._ class ItemQuantumGlyph extends JItemMultiPart with IHighlight { - def this() { - this() - setHasSubtypes(true) - } + + setHasSubtypes(true) override def getUnlocalizedName(itemStack: ItemStack): String = { return super.getUnlocalizedName(itemStack) + "." + itemStack.getItemDamage @@ -65,7 +63,7 @@ class ItemQuantumGlyph extends JItemMultiPart with IHighlight { override def getSubItems(item: Item, tab: CreativeTabs, listToAddTo: List[_]) { - for(i <- PartQuantumGlyph.MAX_GLYPH) + for(i <- 0 until PartQuantumGlyph.MAX_GLYPH) { { listToAddTo.add(new ItemStack(item, 1, i)) diff --git a/src/main/scala/resonantinduction/atomic/gate/PartQuantumGlyph.scala b/src/main/scala/resonantinduction/atomic/gate/PartQuantumGlyph.scala index 72656753e..208e23265 100644 --- a/src/main/scala/resonantinduction/atomic/gate/PartQuantumGlyph.scala +++ b/src/main/scala/resonantinduction/atomic/gate/PartQuantumGlyph.scala @@ -1,38 +1,22 @@ package resonantinduction.atomic.gate -import java.util.ArrayList -import java.util.Arrays -import java.util.HashMap -import java.util.List -import java.util.Set +import java.util.{ArrayList, List, Set} + +import codechicken.lib.data.{MCDataInput, MCDataOutput} +import codechicken.lib.vec.{Cuboid6, Vector3} +import codechicken.multipart.{JCuboidPart, JNormalOcclusion, TSlottedPart} +import cpw.mods.fml.relauncher.{Side, SideOnly} import net.minecraft.entity.Entity import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound import net.minecraft.tileentity.TileEntity -import net.minecraft.util.MovingObjectPosition -import net.minecraftforge.common.util.ForgeDirection -import net.minecraftforge.fluids.Fluid -import net.minecraftforge.fluids.FluidContainerRegistry -import net.minecraftforge.fluids.FluidStack -import net.minecraftforge.fluids.FluidTank -import net.minecraftforge.fluids.FluidTankInfo -import resonant.api.IExternalInventory +import net.minecraft.util.{ChatComponentText, MovingObjectPosition} import resonant.api.blocks.IBlockFrequency import resonant.api.mffs.fortron.FrequencyGridRegistry -import resonant.engine.grid.frequency.FrequencyGrid -import resonant.lib.utility.inventory.ExternalInventory -import codechicken.lib.data.MCDataInput -import codechicken.lib.data.MCDataOutput -import codechicken.lib.vec.Cuboid6 -import codechicken.lib.vec.Vector3 -import codechicken.multipart.JCuboidPart -import codechicken.multipart.JNormalOcclusion -import codechicken.multipart.TSlottedPart -import cpw.mods.fml.relauncher.Side -import cpw.mods.fml.relauncher.SideOnly import resonantinduction.electrical.Electrical import universalelectricity.core.transform.vector.VectorWorld +import scala.collection.JavaConversions._ object PartQuantumGlyph { final val MAX_GLYPH: Int = 4 @@ -40,6 +24,11 @@ object PartQuantumGlyph { } class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusion with IQuantumGate { + + private var slot: Byte = 0 + private[gate] var number: Byte = 0 + private[gate] var ticks: Int = 0 + def preparePlacement(side: Int, itemDamage: Int) { this.slot = side.asInstanceOf[Byte] this.number = itemDamage.asInstanceOf[Byte] @@ -62,21 +51,31 @@ class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusi } } - def transport(entity: Entity) { - if (ticks % 10 == 0 && (tile.asInstanceOf[IQuantumGate]).getFrequency != -1) { + def transport(`ob`: scala.Any) + { + if (ticks % 10 == 0 && (tile.asInstanceOf[IQuantumGate]).getFrequency != -1) + { val frequencyBlocks: Set[IBlockFrequency] = FrequencyGridRegistry.instance.getNodes((tile.asInstanceOf[IQuantumGate]).getFrequency) val gates: List[IQuantumGate] = new ArrayList[IQuantumGate] - import scala.collection.JavaConversions._ - for (frequencyBlock <- frequencyBlocks) { - if (frequencyBlock.isInstanceOf[IQuantumGate]) { + + + for (frequencyBlock <- frequencyBlocks) + { + if (frequencyBlock.isInstanceOf[IQuantumGate]) + { gates.add(frequencyBlock.asInstanceOf[IQuantumGate]) } } gates.remove(tile) + if (gates.size > 0) { - val gate: IQuantumGate = gates.get(if (gates.size > 1) entity.worldObj.rand.nextInt(gates.size - 1) else 0) - val position: VectorWorld = new VectorWorld(gate.asInstanceOf[TileEntity]).add(0.5, 2, 0.5) - if (QuantumGateManager.moveEntity(entity, position)) world.playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F) + if (ob.isInstanceOf[Entity]) + { + val gate: IQuantumGate = gates.get(if (gates.size > 1) ob.asInstanceOf[Entity].worldObj.rand.nextInt(gates.size - 1) else 0) + val position: VectorWorld = new VectorWorld(gate.asInstanceOf[TileEntity]).add(0.5, 2, 0.5) + + if (QuantumGateManager.moveEntity(ob.asInstanceOf[Entity], position)) world.playSoundAtEntity(ob.asInstanceOf[Entity], "mob.endermen.portal", 1.0F, 1.0F) + } } } } @@ -97,7 +96,7 @@ class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusi val frequency: Int = (tile.asInstanceOf[IBlockFrequency]).getFrequency if (frequency > -1) { if (!world.isRemote) { - player.addChatMessage(new ChatMessageComponent("Quantum Gate Frequency: " + frequency)) + player.addChatMessage(new ChatComponentText("Quantum Gate Frequency: " + frequency)) } return true } @@ -167,7 +166,7 @@ class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusi } } - private var slot: Byte = 0 - private[gate] var number: Byte = 0 - private[gate] var ticks: Int = 0 + override def setFrequency(frequency: Int): Unit = ??? + + override def getFrequency: Int = ??? } \ No newline at end of file diff --git a/src/main/scala/resonantinduction/atomic/gate/TraitQuantumGate.scala b/src/main/scala/resonantinduction/atomic/gate/TraitQuantumGate.scala index e7916d6d5..051aee68d 100644 --- a/src/main/scala/resonantinduction/atomic/gate/TraitQuantumGate.scala +++ b/src/main/scala/resonantinduction/atomic/gate/TraitQuantumGate.scala @@ -28,7 +28,7 @@ class TraitQuantumGate extends TileMultipart with IQuantumGate { { if (part.isInstanceOf[IQuantumGate]) { - frequency += Math.pow(PartQuantumGlyph.MAX_GLYPH, i) * (part.asInstanceOf[IBlockFrequency]).getFrequency + frequency += (Math.pow(PartQuantumGlyph.MAX_GLYPH, i) * (part.asInstanceOf[IBlockFrequency]).getFrequency).asInstanceOf[Int] i += 1 } } diff --git a/src/main/scala/resonantinduction/atomic/machine/reactor/TileReactorCell.scala b/src/main/scala/resonantinduction/atomic/machine/reactor/TileReactorCell.scala index cc597a0a4..2422e703a 100644 --- a/src/main/scala/resonantinduction/atomic/machine/reactor/TileReactorCell.scala +++ b/src/main/scala/resonantinduction/atomic/machine/reactor/TileReactorCell.scala @@ -1,47 +1,38 @@ package resonantinduction.atomic.machine.reactor -import java.util.ArrayList -import java.util.List -import net.minecraft.block.material.Material -import net.minecraft.init.Blocks -import resonant.api.event.PlasmaEvent -import resonant.engine.grid.thermal.{ThermalGrid, ThermalPhysics} -import resonant.lib.content.prefab.java.TileInventory -import resonant.lib.multiblock.reference.{MultiBlockHandler, IMultiBlockStructure} -import resonant.lib.network.discriminator.PacketAnnotation -import resonant.lib.network.netty.PacketManager +import java.util.{ArrayList, List} + +import cpw.mods.fml.relauncher.{Side, SideOnly} import net.minecraft.block.Block +import net.minecraft.block.material.Material import net.minecraft.entity.EntityLiving import net.minecraft.entity.player.EntityPlayer +import net.minecraft.init.Blocks import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound import net.minecraft.tileentity.TileEntity import net.minecraft.util.AxisAlignedBB import net.minecraft.world.World -import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.MinecraftForge -import net.minecraftforge.fluids.Fluid -import net.minecraftforge.fluids.FluidContainerRegistry -import net.minecraftforge.fluids.FluidStack -import net.minecraftforge.fluids.FluidTank -import net.minecraftforge.fluids.FluidTankInfo -import net.minecraftforge.fluids.IFluidHandler -import resonant.api.IReactor -import resonant.api.IReactorComponent +import net.minecraftforge.common.util.ForgeDirection +import net.minecraftforge.fluids.{Fluid, FluidContainerRegistry, FluidStack, FluidTank, FluidTankInfo, IFluidHandler} +import resonant.api.{IReactor, IReactorComponent} +import resonant.api.event.PlasmaEvent +import resonant.engine.grid.thermal.{ThermalGrid, ThermalPhysics} +import resonant.lib.content.prefab.java.TileInventory +import resonant.lib.multiblock.reference.{IMultiBlockStructure, MultiBlockHandler} import resonant.lib.network.Synced -import resonant.lib.network.Synced.SyncedInput -import resonant.lib.network.Synced.SyncedOutput +import resonant.lib.network.Synced.{SyncedInput, SyncedOutput} +import resonant.lib.network.discriminator.PacketAnnotation import resonant.lib.prefab.poison.PoisonRadiation import resonant.lib.utility.inventory.InventoryUtility -import resonantinduction.atomic.Atomic -import resonantinduction.atomic.ReactorExplosion import resonantinduction.atomic.machine.plasma.TilePlasma +import resonantinduction.atomic.{Atomic, AtomicContent} import resonantinduction.core.Reference -import resonantinduction.core.ResonantInduction -import universalelectricity.core.transform.vector.{VectorWorld, Vector3} -import cpw.mods.fml.relauncher.Side -import cpw.mods.fml.relauncher.SideOnly +import universalelectricity.core.transform.vector.{Vector3, VectorWorld} + import scala.util.control.Breaks._ +import scala.collection.convert.wrapAll._ /** The primary reactor component cell used to build reactors with. * @@ -66,13 +57,10 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc /** Multiblock Methods. */ private var multiBlock: MultiBlockHandler[TileReactorCell] = null - def this() { - this - textureName = "machine" - isOpaqueCube = false - normalRender = false - customItemRender = true - } + textureName = "machine" + isOpaqueCube = false + normalRender = false + customItemRender = true override protected def onWorldJoin { updatePositionStatus @@ -128,7 +116,7 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc } } if (!getWorld.isRemote) { - if (getMultiBlock().isPrimary() && tank.getFluid != null && tank.getFluid.fluidID == Atomic.FLUID_PLASMA.getID) { + if (getMultiBlock().isPrimary() && tank.getFluid != null && tank.getFluid.fluidID == AtomicContent.FLUID_PLASMA.getID) { val drain: FluidStack = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false) if (drain != null && drain.amount >= FluidContainerRegistry.BUCKET_VOLUME) { val spawnDir: ForgeDirection = ForgeDirection.getOrientation(worldObj.rand.nextInt(3) + 2) @@ -153,7 +141,7 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc } if (ticks % 20 == 0) { if (worldObj.rand.nextFloat > 0.65) { - val entities: List[_] = worldObj.getEntitiesWithinAABB(classOf[EntityLiving], AxisAlignedBB.getBoundingBox(xCoord - TileReactorCell.RADIUS * 2, yCoord - TileReactorCell.RADIUS * 2, zCoord - TileReactorCell.RADIUS * 2, xCoord + TileReactorCell.RADIUS * 2, yCoord + TileReactorCell.RADIUS * 2, zCoord + TileReactorCell.RADIUS * 2)) + val entities: List[EntityLiving] = worldObj.getEntitiesWithinAABB(classOf[EntityLiving], AxisAlignedBB.getBoundingBox(xCoord - TileReactorCell.RADIUS * 2, yCoord - TileReactorCell.RADIUS * 2, zCoord - TileReactorCell.RADIUS * 2, xCoord + TileReactorCell.RADIUS * 2, yCoord + TileReactorCell.RADIUS * 2, zCoord + TileReactorCell.RADIUS * 2)).asInstanceOf[List[EntityLiving]] for (entity <- entities) { PoisonRadiation.INSTANCE.poisonEntity(new Vector3(this), entity) } @@ -161,21 +149,21 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc } } } - temperature = ThermalGrid.getTemperature(new Nothing(this)) + temperature = ThermalGrid.getTemperature(new VectorWorld(this)) if (internalEnergy - prevInternalEnergy > 0) { var deltaT: Float = ThermalPhysics.getTemperatureForEnergy(mass, specificHeatCapacity, ((internalEnergy - prevInternalEnergy) * 0.15).asInstanceOf[Long]) var rods: Int = 0 - for(i <- 6) { + for(i <- 0 to 5) { { val checkAdjacent: Vector3 = new Vector3(this).add(ForgeDirection.getOrientation(i)) - if (checkAdjacent.getBlock(worldObj) == Atomic.blockControlRod) { - deltaT /= 1.1 + if (checkAdjacent.getBlock(worldObj) == AtomicContent.blockControlRod) { + deltaT /= 1.1f rods += 1 } } } - ThermalGrid.addTemperature(new Nothing(this), deltaT) + ThermalGrid.addTemperature(new VectorWorld(this), deltaT) if (worldObj.rand.nextInt(80) == 0 && this.getTemperature >= 373) { worldObj.playSoundEffect(this.xCoord + 0.5F, this.yCoord + 0.5F, this.zCoord + 0.5F, "Fluid.lava", 0.5F, 2.1F + (worldObj.rand.nextFloat - worldObj.rand.nextFloat) * 0.85F) } @@ -208,12 +196,12 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc val leakPos: VectorWorld = new VectorWorld(this).add(worldObj.rand.nextInt(20) - 10, worldObj.rand.nextInt(20) - 10, worldObj.rand.nextInt(20) - 10) val block : Block = leakPos.getBlock if (block == Blocks.grass) { - leakPos.setBlock(worldObj, Atomic.blockRadioactive) + leakPos.setBlock(world, AtomicContent.blockRadioactive) tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true) } else if (block == null) { if (tank.getFluid != null) { - leakPos.setBlock(worldObj, tank.getFluid.getFluid.getBlock) + leakPos.setBlock(world, tank.getFluid.getFluid.getBlock) tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true) } } @@ -222,7 +210,7 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc if (ticks % 60 == 0 || shouldUpdate) { shouldUpdate = false notifyChange - PacketManager.sendPacketToClients(getDescriptionPacket, worldObj, new Vector3(this), 50) + sendPacket(getDescPacket) } } else { @@ -234,7 +222,7 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc } def isOverToxic: Boolean = { - return tank.getFluid != null && tank.getFluid.fluidID == Atomic.FLUID_TOXIC_WASTE.getID && tank.getFluid.amount >= tank.getCapacity + return tank.getFluid != null && tank.getFluid.fluidID == AtomicContent.FLUID_TOXIC_WASTE.getID && tank.getFluid.amount >= tank.getCapacity } /** Multiblock Methods */ @@ -324,9 +312,9 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc private def meltDown { if (!worldObj.isRemote) { this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.lava) - val reactorExplosion: ReactorExplosion = new ReactorExplosion(worldObj, null, xCoord, yCoord, zCoord, 9f) - reactorExplosion.doExplosionA - reactorExplosion.doExplosionB(true) + //val reactorExplosion: ReactorExplosion = new ReactorExplosion(worldObj, null, xCoord, yCoord, zCoord, 9f) + //reactorExplosion.doExplosionA + //reactorExplosion.doExplosionB(true) } } @@ -388,20 +376,20 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc } override def canFill(from: ForgeDirection, fluid: Fluid): Boolean = { - return fluid eq Atomic.FLUID_PLASMA + return fluid == AtomicContent.FLUID_PLASMA } override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = { - return fluid eq Atomic.FLUID_TOXIC_WASTE + return fluid == AtomicContent.FLUID_TOXIC_WASTE } override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = { return Array[FluidTankInfo](tank.getInfo) } - @SideOnly(Side.CLIENT) def getRenderBoundingBox: AxisAlignedBB = { + @SideOnly(Side.CLIENT) override def getRenderBoundingBox: AxisAlignedBB = { if (getMultiBlock.isPrimary && getMultiBlock.isConstructed) { - return INFINITE_EXTENT_AABB + return AxisAlignedBB.getBoundingBox(x - 5, y - 5, z - 5, x + 5, y + 5, z + 5); } return super.getRenderBoundingBox } diff --git a/src/main/scala/resonantinduction/electrical/Electrical.scala b/src/main/scala/resonantinduction/electrical/Electrical.scala index 3f9a1b724..416df1c76 100644 --- a/src/main/scala/resonantinduction/electrical/Electrical.scala +++ b/src/main/scala/resonantinduction/electrical/Electrical.scala @@ -1,46 +1,27 @@ package resonantinduction.electrical +import cpw.mods.fml.common.Mod.{EventHandler, Instance} +import cpw.mods.fml.common.event.{FMLInitializationEvent, FMLPostInitializationEvent, FMLPreInitializationEvent} +import cpw.mods.fml.common.network.NetworkRegistry +import cpw.mods.fml.common.registry.GameRegistry +import cpw.mods.fml.common.{Loader, Mod, ModMetadata, SidedProxy} import ic2.api.item.IC2Items -import net.minecraft.block.Block -import net.minecraft.init.Blocks -import net.minecraft.init.Items -import net.minecraft.item.Item +import net.minecraft.init.{Blocks, Items} import net.minecraft.item.ItemStack -import net.minecraftforge.oredict.OreDictionary -import net.minecraftforge.oredict.ShapedOreRecipe -import net.minecraftforge.oredict.ShapelessOreRecipe +import net.minecraftforge.oredict.{OreDictionary, ShapedOreRecipe, ShapelessOreRecipe} import resonant.content.loader.ModManager import resonant.lib.loadable.LoadableHandler import resonant.lib.recipe.UniversalRecipe -import resonantinduction.core.Reference -import resonantinduction.core.ResonantInduction -import resonantinduction.core.ResonantTab -import resonantinduction.core.Settings +import resonantinduction.atomic.gate.ItemQuantumGlyph import resonantinduction.core.resource.ItemResourcePart -import resonantinduction.electrical.battery.BlockBattery -import resonantinduction.electrical.battery.ItemBlockBattery -import resonantinduction.electrical.battery.TileBattery -import resonantinduction.electrical.generator.TileMotor -import resonantinduction.electrical.generator.TileSolarPanel -import resonantinduction.electrical.generator.TileThermopile +import resonantinduction.core.{Reference, ResonantTab, Settings} +import resonantinduction.electrical.battery.{BlockBattery, ItemBlockBattery, TileBattery} +import resonantinduction.electrical.generator.{TileMotor, TileSolarPanel, TileThermopile} import resonantinduction.electrical.levitator.ItemLevitator import resonantinduction.electrical.multimeter.ItemMultimeter import resonantinduction.electrical.tesla.TileTesla import resonantinduction.electrical.transformer.ItemTransformer -import resonantinduction.electrical.wire.EnumWireMaterial -import resonantinduction.electrical.wire.ItemWire -import resonantinduction.atomic.gate.ItemQuantumGlyph -import cpw.mods.fml.common.Loader -import cpw.mods.fml.common.Mod -import cpw.mods.fml.common.Mod.EventHandler -import cpw.mods.fml.common.Mod.Instance -import cpw.mods.fml.common.ModMetadata -import cpw.mods.fml.common.SidedProxy -import cpw.mods.fml.common.event.FMLInitializationEvent -import cpw.mods.fml.common.event.FMLPostInitializationEvent -import cpw.mods.fml.common.event.FMLPreInitializationEvent -import cpw.mods.fml.common.network.NetworkRegistry -import cpw.mods.fml.common.registry.GameRegistry +import resonantinduction.electrical.wire.{EnumWireMaterial, ItemWire} /** Resonant Induction Electrical Module * @@ -49,54 +30,37 @@ object Electrical { /** Mod Information */ final val ID: String = "ResonantInduction|Electrical" final val NAME: String = Reference.name + " Electrical" - @Instance(ID) var INSTANCE: Electrical = null + @Instance("ResonantInduction|Electrical") var INSTANCE: Electrical = null @SidedProxy(clientSide = "ClientProxy", serverSide = "CommonProxy") var proxy: CommonProxy = null - @Mod.Metadata(ID) var metadata: ModMetadata = null + @Mod.Metadata("ResonantInduction|Electrical") var metadata: ModMetadata = null final val contentRegistry: ModManager = new ModManager().setPrefix(Reference.prefix).setTab(ResonantTab.tab) - var itemWire: Item = null - var itemMultimeter: Item = null - var itemTransformer: Item = null - var itemCharger: Item = null - var blockTesla: Block = null - var blockBattery: Block = null - var blockEncoder: Block = null - var itemRailing: Item = null - var blockSolarPanel: Block = null - var blockMotor: Block = null - var blockThermopile: Block = null - var itemLevitator: Item = null - var blockArmbot: Block = null - var itemDisk: Item = null - var itemInsulation: Item = null - var blockQuantumGate: Block = null - var itemQuantumGlyph: Item = null - var itemLaserGun: Item = null + } -@Mod(modid = Electrical.ID, name = Electrical.NAME, version = Reference.version, dependencies = "before:ThermalExpansion;before:Mekanism;after:ResonantInduction|Mechanical;required-after:" + Reference.coreID) class Electrical { +@Mod(modid = "ResonantInduction|Electrical", name = "Resonant Induction Electrical", version = Reference.version, dependencies = "before:ThermalExpansion;before:Mekanism;after:ResonantInduction|Mechanical;required-after:" + Reference.coreID) class Electrical { @EventHandler def preInit(evt: FMLPreInitializationEvent) { modproxies = new LoadableHandler NetworkRegistry.INSTANCE.registerGuiHandler(this, Electrical.proxy) Settings.config.load - Electrical.itemWire = Electrical.contentRegistry.newItem(classOf[ItemWire]) - Electrical.itemMultimeter = Electrical.contentRegistry.newItem(classOf[ItemMultimeter]) - Electrical.itemTransformer = Electrical.contentRegistry.newItem(classOf[ItemTransformer]) - Electrical.blockTesla = Electrical.contentRegistry.newBlock(classOf[TileTesla]) - Electrical.blockBattery = Electrical.contentRegistry.newBlock(classOf[BlockBattery], classOf[ItemBlockBattery], classOf[TileBattery]) - Electrical.itemLevitator = Electrical.contentRegistry.newItem(classOf[ItemLevitator]) - Electrical.itemInsulation = Electrical.contentRegistry.newItem("insulation", classOf[ItemResourcePart]) - Electrical.blockSolarPanel = Electrical.contentRegistry.newBlock(classOf[TileSolarPanel]) - Electrical.blockMotor = Electrical.contentRegistry.newBlock(classOf[TileMotor]) - Electrical.blockThermopile = Electrical.contentRegistry.newBlock(classOf[TileThermopile]) - Electrical.itemQuantumGlyph = Electrical.contentRegistry.newItem(classOf[ItemQuantumGlyph]) + ElectricalContent.itemWire = Electrical.contentRegistry.newItem(classOf[ItemWire]) + ElectricalContent.itemMultimeter = Electrical.contentRegistry.newItem(classOf[ItemMultimeter]) + ElectricalContent.itemTransformer = Electrical.contentRegistry.newItem(classOf[ItemTransformer]) + ElectricalContent.blockTesla = Electrical.contentRegistry.newBlock(classOf[TileTesla]) + ElectricalContent.blockBattery = Electrical.contentRegistry.newBlock(classOf[BlockBattery], classOf[ItemBlockBattery], classOf[TileBattery]) + ElectricalContent.itemLevitator = Electrical.contentRegistry.newItem(classOf[ItemLevitator]) + ElectricalContent.itemInsulation = Electrical.contentRegistry.newItem("insulation", classOf[ItemResourcePart]) + ElectricalContent.blockSolarPanel = Electrical.contentRegistry.newBlock(classOf[TileSolarPanel]) + ElectricalContent.blockMotor = Electrical.contentRegistry.newBlock(classOf[TileMotor]) + ElectricalContent.blockThermopile = Electrical.contentRegistry.newBlock(classOf[TileThermopile]) + ElectricalContent.itemQuantumGlyph = Electrical.contentRegistry.newItem(classOf[ItemQuantumGlyph]) Settings.config.save - OreDictionary.registerOre("wire", Electrical.itemWire) - OreDictionary.registerOre("motor", Electrical.blockMotor) - OreDictionary.registerOre("battery", ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte])) - OreDictionary.registerOre("batteryBox", ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte])) - ResonantTab.itemStack(new ItemStack(Electrical.itemTransformer)) + OreDictionary.registerOre("wire", ElectricalContent.itemWire) + OreDictionary.registerOre("motor", ElectricalContent.blockMotor) + OreDictionary.registerOre("battery", ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte])) + OreDictionary.registerOre("batteryBox", ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte])) + ResonantTab.itemStack(new ItemStack(ElectricalContent.itemTransformer)) for (material <- EnumWireMaterial.values) { - material.setWire(Electrical.itemWire) + material.setWire(ElectricalContent.itemWire) } Electrical.proxy.preInit modproxies.preInit @@ -109,11 +73,11 @@ object Electrical { } @EventHandler def postInit(evt: FMLPostInitializationEvent) { - GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.blockTesla, "WEW", " C ", "DID", 'W', "wire", 'E', Items.ender_eye, 'C', UniversalRecipe.BATTERY.get, 'D', Items.diamond, 'I', UniversalRecipe.PRIMARY_PLATE.get)) - GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.itemMultimeter, "WWW", "ICI", 'W', "wire", 'C', UniversalRecipe.BATTERY.get, 'I', UniversalRecipe.PRIMARY_METAL.get)) - val tierOneBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte]) - val tierTwoBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 1.asInstanceOf[Byte]) - val tierThreeBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 2.asInstanceOf[Byte]) + GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.blockTesla, "WEW", " C ", "DID", 'W', "wire", 'E', Items.ender_eye, 'C', UniversalRecipe.BATTERY.get, 'D', Items.diamond, 'I', UniversalRecipe.PRIMARY_PLATE.get)) + GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.itemMultimeter, "WWW", "ICI", 'W', "wire", 'C', UniversalRecipe.BATTERY.get, 'I', UniversalRecipe.PRIMARY_METAL.get)) + val tierOneBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte]) + val tierTwoBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 1.asInstanceOf[Byte]) + val tierThreeBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 2.asInstanceOf[Byte]) GameRegistry.addRecipe(new ShapedOreRecipe(tierOneBattery, "III", "IRI", "III", 'R', Blocks.redstone_block, 'I', UniversalRecipe.PRIMARY_METAL.get)) GameRegistry.addRecipe(new ShapedOreRecipe(tierTwoBattery, "RRR", "RIR", "RRR", 'R', tierOneBattery, 'I', UniversalRecipe.PRIMARY_PLATE.get)) GameRegistry.addRecipe(new ShapedOreRecipe(tierThreeBattery, "RRR", "RIR", "RRR", 'R', tierTwoBattery, 'I', Blocks.diamond_block)) @@ -124,16 +88,16 @@ object Electrical { GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SILVER.getWire, "MMM", 'M', "ingotSilver")) GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", 'M', "ingotSuperconductor")) GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", "MEM", "MMM", 'M', Items.gold_ingot, 'E', Items.ender_eye)) - GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.itemCharger, "WWW", "ICI", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get, 'C', UniversalRecipe.CIRCUIT_T1.get)) - GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.itemTransformer, "WWW", "WWW", "III", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Electrical.itemQuantumGlyph, 1, 0), " CT", "LBL", "TCT", 'B', Blocks.diamond_block, 'L', Electrical.itemLevitator, 'C', Electrical.itemCharger, 'T', Electrical.blockTesla)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Electrical.itemQuantumGlyph, 1, 1), "TCT", "LBL", " CT", 'B', Blocks.diamond_block, 'L', Electrical.itemLevitator, 'C', Electrical.itemCharger, 'T', Electrical.blockTesla)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Electrical.itemQuantumGlyph, 1, 2), "TC ", "LBL", "TCT", 'B', Blocks.diamond_block, 'L', Electrical.itemLevitator, 'C', Electrical.itemCharger, 'T', Electrical.blockTesla)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Electrical.itemQuantumGlyph, 1, 3), "TCT", "LBL", "TC ", 'B', Blocks.diamond_block, 'L', Electrical.itemLevitator, 'C', Electrical.itemCharger, 'T', Electrical.blockTesla)) - GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.blockSolarPanel, "CCC", "WWW", "III", 'W', "wire", 'C', Items.coal, 'I', UniversalRecipe.PRIMARY_METAL.get)) - GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.blockMotor, "SRS", "SMS", "SWS", 'W', "wire", 'R', Items.redstone, 'M', Blocks.iron_block, 'S', UniversalRecipe.PRIMARY_METAL.get)) - GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.blockThermopile, "ORO", "OWO", "OOO", 'W', "wire", 'O', Blocks.obsidian, 'R', Items.redstone)) - GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.itemLaserGun, "RDR", "RDR", "ICB", 'R', Items.redstone, 'D', Items.diamond, 'I', Items.gold_ingot, 'C', UniversalRecipe.CIRCUIT_T2.get, 'B', ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte]))) + GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.itemCharger, "WWW", "ICI", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get, 'C', UniversalRecipe.CIRCUIT_T1.get)) + GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.itemTransformer, "WWW", "WWW", "III", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get)) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ElectricalContent.itemQuantumGlyph, 1, 0), " CT", "LBL", "TCT", 'B', Blocks.diamond_block, 'L', ElectricalContent.itemLevitator, 'C', ElectricalContent.itemCharger, 'T', ElectricalContent.blockTesla)) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ElectricalContent.itemQuantumGlyph, 1, 1), "TCT", "LBL", " CT", 'B', Blocks.diamond_block, 'L', ElectricalContent.itemLevitator, 'C', ElectricalContent.itemCharger, 'T', ElectricalContent.blockTesla)) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ElectricalContent.itemQuantumGlyph, 1, 2), "TC ", "LBL", "TCT", 'B', Blocks.diamond_block, 'L', ElectricalContent.itemLevitator, 'C', ElectricalContent.itemCharger, 'T', ElectricalContent.blockTesla)) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ElectricalContent.itemQuantumGlyph, 1, 3), "TCT", "LBL", "TC ", 'B', Blocks.diamond_block, 'L', ElectricalContent.itemLevitator, 'C', ElectricalContent.itemCharger, 'T', ElectricalContent.blockTesla)) + GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.blockSolarPanel, "CCC", "WWW", "III", 'W', "wire", 'C', Items.coal, 'I', UniversalRecipe.PRIMARY_METAL.get)) + GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.blockMotor, "SRS", "SMS", "SWS", 'W', "wire", 'R', Items.redstone, 'M', Blocks.iron_block, 'S', UniversalRecipe.PRIMARY_METAL.get)) + GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.blockThermopile, "ORO", "OWO", "OOO", 'W', "wire", 'O', Blocks.obsidian, 'R', Items.redstone)) + //GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.itemLaserGun, "RDR", "RDR", "ICB", 'R', Items.redstone, 'D', Items.diamond, 'I', Items.gold_ingot, 'C', UniversalRecipe.CIRCUIT_T2.get, 'B', ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte]))) if (Loader.isModLoaded("IC2")) { GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.COPPER.getWire, IC2Items.getItem("copperCableItem"))) GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.TIN.getWire, IC2Items.getItem("tinCableItem"))) diff --git a/src/main/scala/resonantinduction/electrical/ElectricalContent.scala b/src/main/scala/resonantinduction/electrical/ElectricalContent.scala new file mode 100644 index 000000000..1b45bf4de --- /dev/null +++ b/src/main/scala/resonantinduction/electrical/ElectricalContent.scala @@ -0,0 +1,37 @@ +package resonantinduction.electrical + +import net.minecraft.block.Block +import net.minecraft.item.Item +import resonant.content.loader.ContentHolder + +/** + * Created by robert on 8/11/2014. + */ +object ElectricalContent extends ContentHolder { + + var itemWire: Item = null + var itemMultimeter: Item = null + var itemTransformer: Item = null + var itemCharger: Item = null + var blockTesla: Block = null + var blockBattery: Block = null + var blockEncoder: Block = null + var itemRailing: Item = null + var blockSolarPanel: Block = null + var blockMotor: Block = null + var blockThermopile: Block = null + var itemLevitator: Item = null + var blockArmbot: Block = null + var itemDisk: Item = null + var itemInsulation: Item = null + var blockQuantumGate: Block = null + var itemQuantumGlyph: Item = null + var itemLaserGun: Item = null + + override def postInit + { + + + } + +} diff --git a/src/main/scala/resonantinduction/electrical/battery/ItemBlockBattery.java b/src/main/scala/resonantinduction/electrical/battery/ItemBlockBattery.java index 5c335cf6f..1f41994ae 100644 --- a/src/main/scala/resonantinduction/electrical/battery/ItemBlockBattery.java +++ b/src/main/scala/resonantinduction/electrical/battery/ItemBlockBattery.java @@ -2,28 +2,27 @@ package resonantinduction.electrical.battery; import java.util.List; +import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import resonant.lib.render.EnumColor; import resonant.lib.utility.LanguageUtility; -import universalelectricity.api.CompatibilityModule; +import universalelectricity.api.UnitDisplay; import universalelectricity.api.UniversalClass; -import universalelectricity.api.UniversalElectricity; -import universalelectricity.api.energy.UnitDisplay; -import universalelectricity.api.energy.UnitDisplay.Unit; import universalelectricity.api.item.IEnergyItem; -import universalelectricity.api.item.IVoltageItem; +import universalelectricity.compatibility.Compatibility; @UniversalClass -public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltageItem +public class ItemBlockBattery extends ItemBlock implements IEnergyItem { - public ItemBlockBattery(int id) + public ItemBlockBattery(Block block) { - super(id); + super(block); this.setMaxStackSize(1); this.setMaxDamage(100); this.setNoRepair(); @@ -36,7 +35,7 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage list.add(LanguageUtility.getLocal("tooltip.tier") + ": " + (getTier(itemStack) + 1)); String color = ""; - long joules = this.getEnergy(itemStack); + double joules = this.getEnergy(itemStack); if (joules <= this.getEnergyCapacity(itemStack) / 3) { @@ -51,7 +50,7 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage color = "\u00a76"; } itemStack.getItemDamageForDisplay(); - list.add(LanguageUtility.getLocal("tooltip.battery.energy").replace("%0", color).replace("%1", EnumColor.GREY.toString()).replace("%v0", UnitDisplay.getDisplayShort(joules, Unit.JOULES)).replace("%v1", UnitDisplay.getDisplayShort(this.getEnergyCapacity(itemStack), Unit.JOULES))); + list.add(LanguageUtility.getLocal("tooltip.battery.energy").replace("%0", color).replace("%1", EnumColor.GREY.toString()).replace("%v0", new UnitDisplay(UnitDisplay.Unit.JOULES, joules).toString()).replace("%v1", new UnitDisplay(UnitDisplay.Unit.JOULES, this.getEnergyCapacity(itemStack), true).toString())); } /** @@ -65,10 +64,10 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage } @Override - public long recharge(ItemStack itemStack, long energy, boolean doReceive) + public double recharge(ItemStack itemStack, double energy, boolean doReceive) { - long rejectedElectricity = Math.max((this.getEnergy(itemStack) + energy) - this.getEnergyCapacity(itemStack), 0); - long energyToReceive = Math.min(energy - rejectedElectricity, getTransferRate(itemStack)); + double rejectedElectricity = Math.max((this.getEnergy(itemStack) + energy) - this.getEnergyCapacity(itemStack), 0); + double energyToReceive = Math.min(energy - rejectedElectricity, getTransferRate(itemStack)); if (doReceive) { @@ -79,9 +78,9 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage } @Override - public long discharge(ItemStack itemStack, long energy, boolean doTransfer) + public double discharge(ItemStack itemStack, double energy, boolean doTransfer) { - long energyToExtract = Math.min(Math.min(this.getEnergy(itemStack), energy), getTransferRate(itemStack)); + double energyToExtract = Math.min(Math.min(this.getEnergy(itemStack), energy), getTransferRate(itemStack)); if (doTransfer) { @@ -92,31 +91,31 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage } @Override - public long getVoltage(ItemStack itemStack) + public double getVoltage(ItemStack itemStack) { - return UniversalElectricity.DEFAULT_VOLTAGE; + return 240; } @Override - public void setEnergy(ItemStack itemStack, long joules) + public void setEnergy(ItemStack itemStack, double joules) { if (itemStack.getTagCompound() == null) { itemStack.setTagCompound(new NBTTagCompound()); } - long electricityStored = Math.max(Math.min(joules, this.getEnergyCapacity(itemStack)), 0); - itemStack.getTagCompound().setLong("electricity", electricityStored); + double electricityStored = Math.max(Math.min(joules, this.getEnergyCapacity(itemStack)), 0); + itemStack.getTagCompound().setDouble("electricity", electricityStored); } - public long getTransfer(ItemStack itemStack) + public double getTransfer(ItemStack itemStack) { return this.getEnergyCapacity(itemStack) - this.getEnergy(itemStack); } /** Gets the energy stored in the item. Energy is stored using item NBT */ @Override - public long getEnergy(ItemStack itemStack) + public double getEnergy(ItemStack itemStack) { if (itemStack.getTagCompound() == null) { @@ -154,24 +153,24 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage } @Override - public long getEnergyCapacity(ItemStack theItem) + public double getEnergyCapacity(ItemStack theItem) { return TileBattery.getEnergyForTier(getTier(theItem)); } - public long getTransferRate(ItemStack itemStack) + public double getTransferRate(ItemStack itemStack) { return this.getEnergyCapacity(itemStack) / 100; } @SuppressWarnings("unchecked") @Override - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for (byte tier = 0; tier <= TileBattery.MAX_TIER; tier++) { - par3List.add(CompatibilityModule.getItemWithCharge(setTier(new ItemStack(this), tier), 0)); - par3List.add(CompatibilityModule.getItemWithCharge(setTier(new ItemStack(this), tier), TileBattery.getEnergyForTier(tier))); + par3List.add(Compatibility.getItemWithCharge(setTier(new ItemStack(this), tier), 0)); + par3List.add(Compatibility.getItemWithCharge(setTier(new ItemStack(this), tier), TileBattery.getEnergyForTier(tier))); } } }