From 73a139b9e643686e7775067fac4fb7a8ac46749e Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 17 Jan 2015 13:13:26 +0800 Subject: [PATCH] Cleaned up some tile prefabs --- .../edx/basic/blocks/TileFilterable.scala | 20 +- .../engineering/TileEngineeringTable.scala | 268 +++++++++--------- .../process/smelting/TileCastingMold.scala | 7 +- .../prefab/part/connector/PartAbstract.scala | 6 +- .../electrical/generator/TileSolarPanel.scala | 2 +- .../electrical/generator/TileThermopile.scala | 2 +- .../edx/electrical/tesla/TileTesla.scala | 18 +- .../mech/process/mixer/TileMixer.scala | 8 +- .../machine/accelerator/TileAccelerator.scala | 45 +-- .../machine/boiler/TileNuclearBoiler.scala | 9 +- .../machine/centrifuge/GuiCentrifuge.scala | 1 - .../machine/centrifuge/TileCentrifuge.scala | 9 +- .../extractor/GuiChemicalExtractor.scala | 1 - .../extractor/TileChemicalExtractor.scala | 7 +- .../machine/extractor/TileProcess.scala | 2 +- .../machine/fulmination/TileFulmination.scala | 6 +- .../machine/plasma/TilePlasmaHeater.scala | 6 +- .../machine/quantum/GuiQuantumAssembler.scala | 7 +- .../quantum/TileQuantumAssembler.scala | 13 +- .../machine/reactor/TileReactorCell.scala | 27 +- 20 files changed, 233 insertions(+), 231 deletions(-) diff --git a/src/main/scala/edx/basic/blocks/TileFilterable.scala b/src/main/scala/edx/basic/blocks/TileFilterable.scala index 9391e565b..8f0bd7a9e 100644 --- a/src/main/scala/edx/basic/blocks/TileFilterable.scala +++ b/src/main/scala/edx/basic/blocks/TileFilterable.scala @@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.common.util.ForgeDirection import resonant.api.tile.{IFilterable, IRotatable} -import resonant.lib.prefab.tile.TileInventory +import resonant.lib.prefab.tile.mixed.TileInventory import resonant.lib.transform.vector.Vector3 object TileFilterable @@ -16,16 +16,12 @@ object TileFilterable final val BATERY_DRAIN_SLOT: Int = 1 } -abstract class TileFilterable(material: Material) extends TileInventory(material: Material) with IRotatable with IFilterable +abstract class TileFilterable extends TileInventory(Material.wood) with IRotatable with IFilterable { private var filterItem: ItemStack = null private var inverted: Boolean = false - def this() - { - this(Material.wood) - this.setSizeInventory(2) - } + override def getSizeInventory: Int = 2 /** * Allows filters to be placed inside of this block. @@ -65,6 +61,11 @@ abstract class TileFilterable(material: Material) extends TileInventory(material this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord) } + def getFilter: ItemStack = + { + return this.filterItem + } + override def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean = { toggleInversion @@ -114,11 +115,6 @@ abstract class TileFilterable(material: Material) extends TileInventory(material return inverted } - def getFilter: ItemStack = - { - return this.filterItem - } - override def getDirection: ForgeDirection = { return ForgeDirection.getOrientation(if (getBlockType != null) getBlockMetadata else 0) diff --git a/src/main/scala/edx/basic/engineering/TileEngineeringTable.scala b/src/main/scala/edx/basic/engineering/TileEngineeringTable.scala index 86816b0cc..6cf1b2f61 100644 --- a/src/main/scala/edx/basic/engineering/TileEngineeringTable.scala +++ b/src/main/scala/edx/basic/engineering/TileEngineeringTable.scala @@ -32,8 +32,8 @@ import resonant.lib.collection.Pair import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.IPacketReceiver import resonant.lib.prefab.gui.ContainerDummy -import resonant.lib.prefab.tile.TileInventory import resonant.lib.prefab.tile.item.ItemBlockSaved +import resonant.lib.prefab.tile.mixed.TileInventory import resonant.lib.render.RenderItemOverlayUtility import resonant.lib.transform.region.Cuboid import resonant.lib.transform.vector.{Vector2, Vector3} @@ -129,9 +129,97 @@ class TileEngineeringTable extends TileInventory(Material.wood) with IPacketRece } } - override def getSizeInventory: Int = + override def use(player: EntityPlayer, hitSide: Int, hit: Vector3): Boolean = { - return 10 + (if (this.invPlayer != null) this.invPlayer.getSizeInventory else 0) + if (player.getCurrentEquippedItem != null && player.getCurrentEquippedItem.getItem.isInstanceOf[ItemHammer]) + { + for (slot <- 0 to TileEngineeringTable.CRAFTING_OUTPUT_END) + { + val inputStack: ItemStack = getStackInSlot(slot) + if (inputStack != null) + { + val oreName: String = OreDictionary.getOreName(OreDictionary.getOreID(inputStack)) + if (oreName != null && !(oreName == "Unknown")) + { + val outputs: Array[RecipeResource] = MachineRecipes.instance.getOutput(RecipeType.GRINDER.name, oreName) + if (outputs != null && outputs.length > 0) + { + if (!world.isRemote && world.rand.nextFloat < 0.2) + { + for (resource <- outputs) + { + val outputStack: ItemStack = resource.getItemStack.copy + if (outputStack != null) + { + InventoryUtility.dropItemStack(world, new Vector3(player), outputStack, 0) + setInventorySlotContents(slot, if (({ + inputStack.stackSize -= 1; + inputStack.stackSize + }) <= 0) null + else inputStack) + } + } + } + Electrodynamics.proxy.renderBlockParticle(world, new Vector3(x + 0.5, y + 0.5, z + 0.5), new Vector3((Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3), Item.getIdFromItem(inputStack.getItem), 1) + world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Reference.prefix + "hammer", 0.5f, 0.8f + (0.2f * world.rand.nextFloat)) + player.addExhaustion(0.1f) + player.getCurrentEquippedItem.damageItem(1, player) + return true + } + } + } + } + return true + } + if (hitSide == 1) + { + if (!world.isRemote) + { + val hitVector: Vector3 = new Vector3(hit.x, 0, hit.z) + val regionLength: Double = 1d / 3d + + for (j <- 0 to 3) + { + for (k <- 0 to 3) + { + val check: Vector2 = new Vector2(j, k).multiply(regionLength) + if (check.distance(hitVector.toVector2) < regionLength) + { + val slotID: Int = j * 3 + k + interactCurrentItem(this, slotID, player) + onInventoryChanged + return true + } + } + } + onInventoryChanged + } + return true + } + else if (hitSide != 0) + { + if (!world.isRemote) + { + setPlayerInventory(player.inventory) + var output: ItemStack = getStackInSlot(9) + var firstLoop: Boolean = true + while (output != null && (firstLoop || ControlKeyModifer.isControlDown(player))) + { + onPickUpFromSlot(player, 9, output) + if (output.stackSize > 0) + { + InventoryUtility.dropItemStack(world, new Vector3(player), output, 0) + } + setInventorySlotContents(9, null) + onInventoryChanged + output = getStackInSlot(9) + firstLoop = false + } + setPlayerInventory(null) + } + return true + } + return false } override def setInventorySlotContents(slot: Int, itemStack: ItemStack) @@ -252,137 +340,6 @@ class TileEngineeringTable extends TileInventory(Material.wood) with IPacketRece return inventoryCrafting } - /** - * DO NOT USE THIS INTERNALLY. FOR EXTERNAL USE ONLY! - */ - override def getStackInSlot(slot: Int): ItemStack = - { - if (slot < TileEngineeringTable.CRAFTING_MATRIX_END) - { - return this.craftingMatrix(slot) - } - else if (slot < TileEngineeringTable.CRAFTING_OUTPUT_END) - { - return outputInventory(slot - TileEngineeringTable.CRAFTING_MATRIX_END) - } - else if (slot < TileEngineeringTable.PLAYER_OUTPUT_END && invPlayer != null) - { - return this.invPlayer.getStackInSlot(slot - TileEngineeringTable.CRAFTING_OUTPUT_END) - } - else if (searchInventories) - { - var idDisplacement: Int = TileEngineeringTable.PLAYER_OUTPUT_END - for (dir <- ForgeDirection.VALID_DIRECTIONS) - { - val tile: TileEntity = toVectorWorld.add(dir).getTileEntity - if (tile.isInstanceOf[IInventory]) - { - val inventory: IInventory = tile.asInstanceOf[IInventory] - val slotID: Int = slot - idDisplacement - if (slotID >= 0 && slotID < inventory.getSizeInventory) - { - return inventory.getStackInSlot(slotID) - } - idDisplacement += inventory.getSizeInventory - } - } - } - return null - } - - override def use(player: EntityPlayer, hitSide: Int, hit: Vector3): Boolean = - { - if (player.getCurrentEquippedItem != null && player.getCurrentEquippedItem.getItem.isInstanceOf[ItemHammer]) - { - for (slot <- 0 to TileEngineeringTable.CRAFTING_OUTPUT_END) - { - val inputStack: ItemStack = getStackInSlot(slot) - if (inputStack != null) - { - val oreName: String = OreDictionary.getOreName(OreDictionary.getOreID(inputStack)) - if (oreName != null && !(oreName == "Unknown")) - { - val outputs: Array[RecipeResource] = MachineRecipes.instance.getOutput(RecipeType.GRINDER.name, oreName) - if (outputs != null && outputs.length > 0) - { - if (!world.isRemote && world.rand.nextFloat < 0.2) - { - for (resource <- outputs) - { - val outputStack: ItemStack = resource.getItemStack.copy - if (outputStack != null) - { - InventoryUtility.dropItemStack(world, new Vector3(player), outputStack, 0) - setInventorySlotContents(slot, if (({ - inputStack.stackSize -= 1; - inputStack.stackSize - }) <= 0) null - else inputStack) - } - } - } - Electrodynamics.proxy.renderBlockParticle(world, new Vector3(x + 0.5, y + 0.5, z + 0.5), new Vector3((Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3), Item.getIdFromItem(inputStack.getItem), 1) - world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Reference.prefix + "hammer", 0.5f, 0.8f + (0.2f * world.rand.nextFloat)) - player.addExhaustion(0.1f) - player.getCurrentEquippedItem.damageItem(1, player) - return true - } - } - } - } - return true - } - if (hitSide == 1) - { - if (!world.isRemote) - { - val hitVector: Vector3 = new Vector3(hit.x, 0, hit.z) - val regionLength: Double = 1d / 3d - - for (j <- 0 to 3) - { - for (k <- 0 to 3) - { - val check: Vector2 = new Vector2(j, k).multiply(regionLength) - if (check.distance(hitVector.toVector2) < regionLength) - { - val slotID: Int = j * 3 + k - interactCurrentItem(this, slotID, player) - onInventoryChanged - return true - } - } - } - onInventoryChanged - } - return true - } - else if (hitSide != 0) - { - if (!world.isRemote) - { - setPlayerInventory(player.inventory) - var output: ItemStack = getStackInSlot(9) - var firstLoop: Boolean = true - while (output != null && (firstLoop || ControlKeyModifer.isControlDown(player))) - { - onPickUpFromSlot(player, 9, output) - if (output.stackSize > 0) - { - InventoryUtility.dropItemStack(world, new Vector3(player), output, 0) - } - setInventorySlotContents(9, null) - onInventoryChanged - output = getStackInSlot(9) - firstLoop = false - } - setPlayerInventory(null) - } - return true - } - return false - } - /** * Creates a "fake inventory" and hook the player up to the crafter to use the player's items. */ @@ -491,6 +448,11 @@ class TileEngineeringTable extends TileInventory(Material.wood) with IPacketRece nbt.setBoolean("searchInventories", this.searchInventories) } + override def getSizeInventory: Int = + { + return 10 + (if (this.invPlayer != null) this.invPlayer.getSizeInventory else 0) + } + def read(data: ByteBuf, player: EntityPlayer, `type`: PacketType) { try @@ -675,6 +637,44 @@ class TileEngineeringTable extends TileInventory(Material.wood) with IPacketRece GL11.glPopMatrix } + /** + * DO NOT USE THIS INTERNALLY. FOR EXTERNAL USE ONLY! + */ + override def getStackInSlot(slot: Int): ItemStack = + { + if (slot < TileEngineeringTable.CRAFTING_MATRIX_END) + { + return this.craftingMatrix(slot) + } + else if (slot < TileEngineeringTable.CRAFTING_OUTPUT_END) + { + return outputInventory(slot - TileEngineeringTable.CRAFTING_MATRIX_END) + } + else if (slot < TileEngineeringTable.PLAYER_OUTPUT_END && invPlayer != null) + { + return this.invPlayer.getStackInSlot(slot - TileEngineeringTable.CRAFTING_OUTPUT_END) + } + else if (searchInventories) + { + var idDisplacement: Int = TileEngineeringTable.PLAYER_OUTPUT_END + for (dir <- ForgeDirection.VALID_DIRECTIONS) + { + val tile: TileEntity = toVectorWorld.add(dir).getTileEntity + if (tile.isInstanceOf[IInventory]) + { + val inventory: IInventory = tile.asInstanceOf[IInventory] + val slotID: Int = slot - idDisplacement + if (slotID >= 0 && slotID < inventory.getSizeInventory) + { + return inventory.getStackInSlot(slotID) + } + idDisplacement += inventory.getSizeInventory + } + } + } + return null + } + override def getDirection: ForgeDirection = { return null diff --git a/src/main/scala/edx/basic/process/smelting/TileCastingMold.scala b/src/main/scala/edx/basic/process/smelting/TileCastingMold.scala index 9c3fb4777..1c34f336c 100644 --- a/src/main/scala/edx/basic/process/smelting/TileCastingMold.scala +++ b/src/main/scala/edx/basic/process/smelting/TileCastingMold.scala @@ -1,7 +1,6 @@ package edx.basic.process.smelting import cpw.mods.fml.common.network.ByteBufUtils -import edx.core.Reference import io.netty.buffer.ByteBuf import net.minecraft.block.material.Material import net.minecraft.entity.player.EntityPlayer @@ -12,7 +11,7 @@ import net.minecraftforge.fluids._ import resonant.api.recipe.{MachineRecipes, RecipeResource, RecipeType} import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.IPacketReceiver -import resonant.lib.prefab.tile.TileInventory +import resonant.lib.prefab.tile.mixed.TileInventory import resonant.lib.transform.vector.Vector3 import resonant.lib.utility.FluidUtility import resonant.lib.utility.inventory.InventoryUtility @@ -31,10 +30,12 @@ class TileCastingMold extends TileInventory(Material.rock) with IFluidHandler wi protected var tank: FluidTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME) //Constructor - setTextureName(Reference.prefix + "material_metal_side") + textureName = "material_metal_side" normalRender = false isOpaqueCube = false + override def getSizeInventory: Int = 1 + override def canUpdate: Boolean = { return false diff --git a/src/main/scala/edx/core/prefab/part/connector/PartAbstract.scala b/src/main/scala/edx/core/prefab/part/connector/PartAbstract.scala index 07b2eca4e..987e88f62 100644 --- a/src/main/scala/edx/core/prefab/part/connector/PartAbstract.scala +++ b/src/main/scala/edx/core/prefab/part/connector/PartAbstract.scala @@ -5,16 +5,16 @@ import codechicken.multipart.{IRedstonePart, TMultiPart} import edx.core.ResonantPartFactory import net.minecraft.item.ItemStack import net.minecraft.util.MovingObjectPosition -import resonant.lib.prefab.TraitTicker +import resonant.lib.prefab.tile.traits.TTicker import scala.collection.convert.wrapAll._ import scala.collection.mutable -abstract class PartAbstract extends TMultiPart with TraitTicker +abstract class PartAbstract extends TMultiPart with TTicker { override def update() { - super[TraitTicker].update() + super[TTicker].update() } protected def getItem: ItemStack diff --git a/src/main/scala/edx/electrical/generator/TileSolarPanel.scala b/src/main/scala/edx/electrical/generator/TileSolarPanel.scala index 7936b746b..370063c96 100644 --- a/src/main/scala/edx/electrical/generator/TileSolarPanel.scala +++ b/src/main/scala/edx/electrical/generator/TileSolarPanel.scala @@ -6,7 +6,7 @@ import net.minecraft.block.material.Material import net.minecraft.client.renderer.texture.IIconRegister import net.minecraft.util.IIcon import resonant.lib.content.prefab.TIO -import resonant.lib.prefab.tile.TileElectric +import resonant.lib.prefab.tile.mixed.TileElectric import resonant.lib.prefab.tile.spatial.SpatialBlock import resonant.lib.render.block.RenderConnectedTexture import resonant.lib.transform.region.Cuboid diff --git a/src/main/scala/edx/electrical/generator/TileThermopile.scala b/src/main/scala/edx/electrical/generator/TileThermopile.scala index 53a4e77da..228cc09f4 100644 --- a/src/main/scala/edx/electrical/generator/TileThermopile.scala +++ b/src/main/scala/edx/electrical/generator/TileThermopile.scala @@ -9,7 +9,7 @@ import net.minecraft.init.Blocks import net.minecraft.util.IIcon import net.minecraftforge.common.util.ForgeDirection import resonant.lib.content.prefab.TIO -import resonant.lib.prefab.tile.TileElectric +import resonant.lib.prefab.tile.mixed.TileElectric import resonant.lib.prefab.tile.spatial.SpatialBlock import resonant.lib.transform.vector.Vector3 diff --git a/src/main/scala/edx/electrical/tesla/TileTesla.scala b/src/main/scala/edx/electrical/tesla/TileTesla.scala index 4cff141ca..80e876085 100644 --- a/src/main/scala/edx/electrical/tesla/TileTesla.scala +++ b/src/main/scala/edx/electrical/tesla/TileTesla.scala @@ -24,7 +24,7 @@ import resonant.lib.content.prefab.{TEnergyStorage, TIO} import resonant.lib.grid.energy.EnergyStorage import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.{TPacketIDReceiver, TPacketSender} -import resonant.lib.prefab.tile.TileElectric +import resonant.lib.prefab.tile.mixed.TileElectric import resonant.lib.prefab.tile.multiblock.reference.{IMultiBlockStructure, MultiBlockHandler} import resonant.lib.render.EnumColor import resonant.lib.transform.vector.{Vector3, VectorWorld} @@ -80,8 +80,8 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti energy.setCapacity(TRANSFER_CAP * 2) energy.setMaxTransfer(TRANSFER_CAP) setTextureName(Reference.prefix + "material_metal_side") - normalRender(false) - isOpaqueCube(false) + normalRender = false + isOpaqueCube = false override def start { @@ -388,12 +388,6 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti getMultiBlock.load(nbt) } - def getMultiBlock: MultiBlockHandler[TileTesla] = - { - if (multiBlock == null) multiBlock = new MultiBlockHandler[TileTesla](this) - return multiBlock - } - /** * Writes a tile entity to NBT. */ @@ -413,6 +407,12 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti getMultiBlock.save(nbt) } + def getMultiBlock: MultiBlockHandler[TileTesla] = + { + if (multiBlock == null) multiBlock = new MultiBlockHandler[TileTesla](this) + return multiBlock + } + def setLink(vector3: Vector3, dimID: Int, setOpponent: Boolean) { if (!worldObj.isRemote) diff --git a/src/main/scala/edx/mechanical/mech/process/mixer/TileMixer.scala b/src/main/scala/edx/mechanical/mech/process/mixer/TileMixer.scala index 86f913a62..bbeb41daf 100644 --- a/src/main/scala/edx/mechanical/mech/process/mixer/TileMixer.scala +++ b/src/main/scala/edx/mechanical/mech/process/mixer/TileMixer.scala @@ -40,10 +40,10 @@ class TileMixer extends TileMechanical(Material.iron) //Constructor mechanicalNode = new MixerNode(this) - isOpaqueCube(false) - normalRender(false) - customItemRender(true) - setTextureName("material_metal_top") + isOpaqueCube = false + normalRender = false + customItemRender = true + textureName = "material_metal_top" override def update { diff --git a/src/main/scala/edx/quantum/machine/accelerator/TileAccelerator.scala b/src/main/scala/edx/quantum/machine/accelerator/TileAccelerator.scala index aa8294bda..7950b413e 100644 --- a/src/main/scala/edx/quantum/machine/accelerator/TileAccelerator.scala +++ b/src/main/scala/edx/quantum/machine/accelerator/TileAccelerator.scala @@ -17,7 +17,7 @@ import resonant.lib.content.prefab.TEnergyStorage import resonant.lib.grid.energy.EnergyStorage import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.{TPacketIDReceiver, TPacketSender} -import resonant.lib.prefab.tile.TileElectricInventory +import resonant.lib.prefab.tile.mixed.TileElectricInventory import resonant.lib.transform.vector.Vector3 import resonant.lib.utility.BlockUtility @@ -25,7 +25,7 @@ import scala.collection.JavaConversions._ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectromagnet with IRotatable with TPacketIDReceiver with TPacketSender with TEnergyStorage { - final val DESC_PACKET_ID = 2; + final val DESC_PACKET_ID = 2 /** * The total amount of energy consumed by this particle. In Joules. */ @@ -44,12 +44,13 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro private var antiMatterDensityMultiplyer: Int = Settings.ACCELERATOR_ANITMATTER_DENSITY_MULTIPLIER //Constructor - this.setSizeInventory(4) //TODO: Dummy energy = new EnergyStorage(0) energy.setCapacity(Settings.ACCELERATOR_ENERGY_COST_PER_TICK * 20) energy.setMaxTransfer(Settings.ACCELERATOR_ENERGY_COST_PER_TICK) + override def getSizeInventory: Int = 4 + override def update { super.update @@ -212,20 +213,6 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro /// Packet Handling /// //////////////////////////////////////// - override def getDirection: ForgeDirection = - { - return ForgeDirection.getOrientation(getBlockMetadata) - } - - override def setDirection(direction: ForgeDirection) - { - world.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal, 3) - } - - ///////////////////////////////////////// - /// Save handling /// - //////////////////////////////////////// - /** get velocity for the particle and @return it as a float */ def getParticleVel(): Float = { @@ -242,7 +229,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro } ///////////////////////////////////////// - /// Inventory Overrides /// + /// Save handling /// //////////////////////////////////////// override def read(buf: ByteBuf, id: Int, player: EntityPlayer, packet: PacketType): Boolean = @@ -270,6 +257,10 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro antimatter = par1NBTTagCompound.getInteger("antimatter") } + ///////////////////////////////////////// + /// Inventory Overrides /// + //////////////////////////////////////// + override def writeToNBT(par1NBTTagCompound: NBTTagCompound) { super.writeToNBT(par1NBTTagCompound) @@ -277,10 +268,6 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro par1NBTTagCompound.setInteger("antimatter", antimatter) } - ///////////////////////////////////////// - /// Field Getters & Setters /// - //////////////////////////////////////// - override def canInsertItem(slotID: Int, itemStack: ItemStack, j: Int): Boolean = { return isItemValidForSlot(slotID, itemStack) && slotID != 2 && slotID != 3 @@ -302,6 +289,10 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro return false } + ///////////////////////////////////////// + /// Field Getters & Setters /// + //////////////////////////////////////// + override def canExtractItem(slotID: Int, itemstack: ItemStack, j: Int): Boolean = { return slotID == 2 || slotID == 3 @@ -321,4 +312,14 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro } return getIcon } + + override def getDirection: ForgeDirection = + { + return ForgeDirection.getOrientation(getBlockMetadata) + } + + override def setDirection(direction: ForgeDirection) + { + world.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal, 3) + } } \ No newline at end of file diff --git a/src/main/scala/edx/quantum/machine/boiler/TileNuclearBoiler.scala b/src/main/scala/edx/quantum/machine/boiler/TileNuclearBoiler.scala index 95da5c432..26f16db01 100644 --- a/src/main/scala/edx/quantum/machine/boiler/TileNuclearBoiler.scala +++ b/src/main/scala/edx/quantum/machine/boiler/TileNuclearBoiler.scala @@ -16,7 +16,7 @@ import resonant.lib.grid.energy.EnergyStorage import resonant.lib.network.Synced import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.IPacketReceiver -import resonant.lib.prefab.tile.TileElectricInventory +import resonant.lib.prefab.tile.mixed.TileElectricInventory import resonant.lib.prefab.tile.traits.TRotatable import resonant.lib.transform.vector.Vector3 @@ -47,9 +47,10 @@ class TileNuclearBoiler extends TileElectricInventory(Material.iron) with IPacke //TODO: Dummy energy = new EnergyStorage(0) energy.setCapacity(TileNuclearBoiler.DIAN * 2) - this.setSizeInventory(4) - normalRender(false) - isOpaqueCube(false) + normalRender = false + isOpaqueCube = false + + override def getSizeInventory: Int = 4 override def update { diff --git a/src/main/scala/edx/quantum/machine/centrifuge/GuiCentrifuge.scala b/src/main/scala/edx/quantum/machine/centrifuge/GuiCentrifuge.scala index fc66ebd66..18a31dea6 100644 --- a/src/main/scala/edx/quantum/machine/centrifuge/GuiCentrifuge.scala +++ b/src/main/scala/edx/quantum/machine/centrifuge/GuiCentrifuge.scala @@ -29,7 +29,6 @@ class GuiCentrifuge(par1InventoryPlayer: InventoryPlayer, tileEntity: TileCentri } this.fontRendererObj.drawString("Status: " + displayText, 70, 50, 4210752) this.renderUniversalDisplay(8, 112, TileCentrifuge.DIAN * 20, mouseX, mouseY, UnitDisplay.Unit.WATT) - this.renderUniversalDisplay(100, 112, this.tileEntity.getVoltage, mouseX, mouseY, UnitDisplay.Unit.VOLTAGE) this.fontRendererObj.drawString("The centrifuge spins", 8, 75, 4210752) this.fontRendererObj.drawString("uranium hexafluoride gas into", 8, 85, 4210752) this.fontRendererObj.drawString("enriched uranium for fission.", 8, 95, 4210752) diff --git a/src/main/scala/edx/quantum/machine/centrifuge/TileCentrifuge.scala b/src/main/scala/edx/quantum/machine/centrifuge/TileCentrifuge.scala index 2d92c9841..8f6a6d30f 100644 --- a/src/main/scala/edx/quantum/machine/centrifuge/TileCentrifuge.scala +++ b/src/main/scala/edx/quantum/machine/centrifuge/TileCentrifuge.scala @@ -16,7 +16,7 @@ import resonant.lib.grid.energy.EnergyStorage import resonant.lib.mod.compat.energy.Compatibility import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.IPacketReceiver -import resonant.lib.prefab.tile.TileElectricInventory +import resonant.lib.prefab.tile.mixed.TileElectricInventory import resonant.lib.prefab.tile.traits.TRotatable import resonant.lib.transform.vector.Vector3 @@ -37,10 +37,11 @@ class TileCentrifuge extends TileElectricInventory(Material.iron) with IPacketRe //TODO: Dummy energy = new EnergyStorage(0) - isOpaqueCube(false) - normalRender(false) + isOpaqueCube = false + normalRender = false energy.setCapacity(TileCentrifuge.DIAN * 2) - setSizeInventory(4) + + override def getSizeInventory: Int = 4 override def update { diff --git a/src/main/scala/edx/quantum/machine/extractor/GuiChemicalExtractor.scala b/src/main/scala/edx/quantum/machine/extractor/GuiChemicalExtractor.scala index ac80d73db..83cd352e2 100644 --- a/src/main/scala/edx/quantum/machine/extractor/GuiChemicalExtractor.scala +++ b/src/main/scala/edx/quantum/machine/extractor/GuiChemicalExtractor.scala @@ -15,7 +15,6 @@ class GuiChemicalExtractor(par1InventoryPlayer: InventoryPlayer, tileEntity: Til { this.fontRendererObj.drawString("Chemical Extractor", 45, 6, 4210752) this.renderUniversalDisplay(8, 112, TileChemicalExtractor.ENERGY * 20, mouseX, mouseY, UnitDisplay.Unit.WATT) - this.renderUniversalDisplay(100, 112, this.tileEntity.getVoltage, mouseX, mouseY, UnitDisplay.Unit.VOLTAGE) this.fontRendererObj.drawString("The extractor can extract", 8, 75, 4210752) this.fontRendererObj.drawString("uranium, deuterium and tritium.", 8, 85, 4210752) this.fontRendererObj.drawString("Place them in the input slot.", 8, 95, 4210752) diff --git a/src/main/scala/edx/quantum/machine/extractor/TileChemicalExtractor.scala b/src/main/scala/edx/quantum/machine/extractor/TileChemicalExtractor.scala index 875554ac2..459755112 100644 --- a/src/main/scala/edx/quantum/machine/extractor/TileChemicalExtractor.scala +++ b/src/main/scala/edx/quantum/machine/extractor/TileChemicalExtractor.scala @@ -33,9 +33,8 @@ class TileChemicalExtractor extends TileProcess(Material.iron) with IFluidHandle //TODO: Dummy energy = new EnergyStorage(0) energy.setCapacity(TileChemicalExtractor.ENERGY * 2) - this.setSizeInventory(7) - this.isOpaqueCube(false) - this.normalRender(false) + isOpaqueCube = false + normalRender = false inputSlot = 1 outputSlot = 2 tankInputFillSlot = 3 @@ -48,6 +47,8 @@ class TileChemicalExtractor extends TileProcess(Material.iron) with IFluidHandle @Synced var time: Int = 0 var rotation: Float = 0 + override def getSizeInventory: Int = 7 + override def update { super.update diff --git a/src/main/scala/edx/quantum/machine/extractor/TileProcess.scala b/src/main/scala/edx/quantum/machine/extractor/TileProcess.scala index 03508ba95..33a12c134 100644 --- a/src/main/scala/edx/quantum/machine/extractor/TileProcess.scala +++ b/src/main/scala/edx/quantum/machine/extractor/TileProcess.scala @@ -4,7 +4,7 @@ import net.minecraft.block.material.Material import net.minecraft.item.ItemStack import net.minecraftforge.fluids.{FluidContainerRegistry, FluidStack, FluidTank} import resonant.api.recipe.{MachineRecipes, RecipeResource} -import resonant.lib.prefab.tile.TileElectricInventory +import resonant.lib.prefab.tile.mixed.TileElectricInventory /** * General class for all machines that do traditional recipe processing diff --git a/src/main/scala/edx/quantum/machine/fulmination/TileFulmination.scala b/src/main/scala/edx/quantum/machine/fulmination/TileFulmination.scala index 5a4060d79..eb4fefb7d 100644 --- a/src/main/scala/edx/quantum/machine/fulmination/TileFulmination.scala +++ b/src/main/scala/edx/quantum/machine/fulmination/TileFulmination.scala @@ -3,7 +3,7 @@ package edx.quantum.machine.fulmination import net.minecraft.block.material.Material import resonant.lib.content.prefab.TEnergyStorage import resonant.lib.grid.energy.EnergyStorage -import resonant.lib.prefab.tile.TileElectric +import resonant.lib.prefab.tile.mixed.TileElectric /** * Fulmination TileEntity @@ -18,8 +18,8 @@ class TileFulmination extends TileElectric(Material.iron) with TEnergyStorage //TODO: Dummy energy = new EnergyStorage(0) energy.setCapacity(TileFulmination.maxEnergy * 2) - this.blockHardness(10) - this.blockResistance(25000) + blockHardness = 10 + blockResistance = 25000 override def start { diff --git a/src/main/scala/edx/quantum/machine/plasma/TilePlasmaHeater.scala b/src/main/scala/edx/quantum/machine/plasma/TilePlasmaHeater.scala index 3cff8e65e..90abf9057 100644 --- a/src/main/scala/edx/quantum/machine/plasma/TilePlasmaHeater.scala +++ b/src/main/scala/edx/quantum/machine/plasma/TilePlasmaHeater.scala @@ -18,7 +18,7 @@ import resonant.lib.grid.energy.EnergyStorage import resonant.lib.mod.config.Config import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.IPacketReceiver -import resonant.lib.prefab.tile.TileElectric +import resonant.lib.prefab.tile.mixed.TileElectric import resonant.lib.transform.vector.Vector3 import resonant.lib.utility.science.UnitDisplay import resonant.lib.utility.{FluidUtility, LanguageUtility} @@ -42,8 +42,8 @@ class TilePlasmaHeater extends TileElectric(Material.iron) with IPacketReceiver energy = new EnergyStorage(0) energy.setCapacity(TilePlasmaHeater.joules) energy.setMaxTransfer(TilePlasmaHeater.joules / 20) - normalRender(false) - isOpaqueCube(false) + normalRender = false + isOpaqueCube = false override def update() { diff --git a/src/main/scala/edx/quantum/machine/quantum/GuiQuantumAssembler.scala b/src/main/scala/edx/quantum/machine/quantum/GuiQuantumAssembler.scala index a98b9c7b6..0864a9f43 100644 --- a/src/main/scala/edx/quantum/machine/quantum/GuiQuantumAssembler.scala +++ b/src/main/scala/edx/quantum/machine/quantum/GuiQuantumAssembler.scala @@ -1,5 +1,6 @@ package edx.quantum.machine.quantum +import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.Reference import net.minecraft.entity.player.InventoryPlayer import net.minecraft.util.ResourceLocation @@ -9,7 +10,8 @@ import resonant.lib.utility.science.UnitDisplay object GuiQuantumAssembler { - final val TEXTURE: ResourceLocation = new ResourceLocation(Reference.domain, Reference.guiDirectory + "gui_atomic_assembler.png") + @SideOnly(Side.CLIENT) + final val texture = new ResourceLocation(Reference.domain, Reference.guiDirectory + "gui_atomic_assembler.png") } class GuiQuantumAssembler(par1InventoryPlayer: InventoryPlayer, tileEntity: TileQuantumAssembler) extends GuiContainerBase(new ContainerQuantumAssembler(par1InventoryPlayer, tileEntity)) @@ -37,7 +39,6 @@ class GuiQuantumAssembler(par1InventoryPlayer: InventoryPlayer, tileEntity: Tile displayText = "Idle" } this.fontRendererObj.drawString(displayText, 9, this.ySize - 106, 4210752) - this.renderUniversalDisplay(100, this.ySize - 94, this.tileEntity.getVoltage, mouseX, mouseY, UnitDisplay.Unit.VOLTAGE) this.renderUniversalDisplay(8, this.ySize - 95, tileEntity.MAX_TIME, mouseX, mouseY, UnitDisplay.Unit.WATT) } @@ -46,7 +47,7 @@ class GuiQuantumAssembler(par1InventoryPlayer: InventoryPlayer, tileEntity: Tile */ protected override def drawGuiContainerBackgroundLayer(par1: Float, par2: Int, par3: Int) { - this.mc.renderEngine.bindTexture(GuiQuantumAssembler.TEXTURE) + this.mc.renderEngine.bindTexture(GuiQuantumAssembler.texture) GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F) this.containerWidth = (this.width - this.xSize) / 2 this.containerHeight = (this.height - this.ySize) / 2 diff --git a/src/main/scala/edx/quantum/machine/quantum/TileQuantumAssembler.scala b/src/main/scala/edx/quantum/machine/quantum/TileQuantumAssembler.scala index 74376fa5a..bbc7ef6d9 100644 --- a/src/main/scala/edx/quantum/machine/quantum/TileQuantumAssembler.scala +++ b/src/main/scala/edx/quantum/machine/quantum/TileQuantumAssembler.scala @@ -13,7 +13,7 @@ import resonant.lib.content.prefab.TEnergyStorage import resonant.lib.grid.energy.EnergyStorage import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.handle.IPacketReceiver -import resonant.lib.prefab.tile.TileElectricInventory +import resonant.lib.prefab.tile.mixed.TileElectricInventory import resonant.lib.transform.vector.Vector3 /** @@ -36,16 +36,17 @@ class TileQuantumAssembler extends TileElectricInventory(Material.iron) with IPa private[quantum] var entityItem: EntityItem = null //Constructor - setSizeInventory(7) //TODO: Dummy energy = new EnergyStorage(0) energy.setCapacity(ENERGY) energy.setMaxTransfer(ENERGY / 10) - isOpaqueCube(false) - normalRender(false) - customItemRender(true) - setTextureName("machine") + isOpaqueCube = false + normalRender = false + customItemRender = true + textureName = "machine" + + override def getSizeInventory: Int = 7 /** * Called when the block is right clicked by the player diff --git a/src/main/scala/edx/quantum/machine/reactor/TileReactorCell.scala b/src/main/scala/edx/quantum/machine/reactor/TileReactorCell.scala index a9a80eb32..74fdade61 100644 --- a/src/main/scala/edx/quantum/machine/reactor/TileReactorCell.scala +++ b/src/main/scala/edx/quantum/machine/reactor/TileReactorCell.scala @@ -26,7 +26,7 @@ import resonant.lib.network.Synced import resonant.lib.network.Synced.{SyncedInput, SyncedOutput} import resonant.lib.network.discriminator.PacketAnnotation import resonant.lib.prefab.poison.PoisonRadiation -import resonant.lib.prefab.tile.TileInventory +import resonant.lib.prefab.tile.mixed.TileInventory import resonant.lib.prefab.tile.multiblock.reference.{IMultiBlockStructure, MultiBlockHandler} import resonant.lib.transform.vector.{Vector3, VectorWorld} import resonant.lib.utility.inventory.InventoryUtility @@ -61,13 +61,19 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc textureName = "machine" isOpaqueCube = false normalRender = false - maxSlots = 1 + + override def getSizeInventory: Int = 1 override def onWorldJoin { updatePositionStatus } + override def onNeighborChanged(block: Block) + { + updatePositionStatus + } + /** Multiblock Methods */ def updatePositionStatus { @@ -110,9 +116,13 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc return lowest } - override def onNeighborChanged(block: Block) + override def getMultiBlock: MultiBlockHandler[TileReactorCell] = { - updatePositionStatus + if (multiBlock == null) + { + multiBlock = new MultiBlockHandler[TileReactorCell](this) + } + return multiBlock } override def update @@ -397,15 +407,6 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc return getMultiBlock.get.tank.fill(resource, doFill) } - override def getMultiBlock: MultiBlockHandler[TileReactorCell] = - { - if (multiBlock == null) - { - multiBlock = new MultiBlockHandler[TileReactorCell](this) - } - return multiBlock - } - override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack = { return tank.drain(maxDrain, doDrain)