Started rework on reactor cell
This commit is contained in:
parent
3cf6752ec5
commit
a1c3a8e8e8
17 changed files with 817 additions and 1159 deletions
|
@ -87,8 +87,8 @@ class TileEngineeringTable extends TileInventory(Material.wood) with IPacketRece
|
|||
private var playerSlots: Array[Int] = null
|
||||
|
||||
//Constructor
|
||||
bounds(new Cuboid(0, 0, 0, 1, 0.9f, 1))
|
||||
isOpaqueCube(false)
|
||||
bounds = new Cuboid(0, 0, 0, 1, 0.9f, 1)
|
||||
isOpaqueCube = false
|
||||
itemBlock(classOf[ItemBlockSaved])
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@ -222,124 +222,6 @@ class TileEngineeringTable extends TileInventory(Material.wood) with IPacketRece
|
|||
return false
|
||||
}
|
||||
|
||||
override def setInventorySlotContents(slot: Int, itemStack: ItemStack)
|
||||
{
|
||||
if (slot < TileEngineeringTable.CRAFTING_MATRIX_END)
|
||||
{
|
||||
craftingMatrix(slot) = itemStack
|
||||
}
|
||||
else if (slot < TileEngineeringTable.CRAFTING_OUTPUT_END)
|
||||
{
|
||||
outputInventory(slot - TileEngineeringTable.CRAFTING_MATRIX_END) = itemStack
|
||||
}
|
||||
else if (slot < TileEngineeringTable.PLAYER_OUTPUT_END && this.invPlayer != null)
|
||||
{
|
||||
this.invPlayer.setInventorySlotContents(slot - TileEngineeringTable.CRAFTING_OUTPUT_END, itemStack)
|
||||
val player: EntityPlayer = this.invPlayer.player
|
||||
if (player.isInstanceOf[EntityPlayerMP])
|
||||
{
|
||||
(player.asInstanceOf[EntityPlayerMP]).sendContainerToPlayer(player.inventoryContainer)
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
inventory.setInventorySlotContents(slotID, itemStack)
|
||||
}
|
||||
idDisplacement += inventory.getSizeInventory
|
||||
}
|
||||
}
|
||||
}
|
||||
onInventoryChanged
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates all the output slots. Call this to update the Engineering Table.
|
||||
*/
|
||||
override def onInventoryChanged
|
||||
{
|
||||
if (worldObj != null)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = null
|
||||
var didCraft: Boolean = false
|
||||
val inventoryCrafting: InventoryCrafting = this.getCraftingMatrix
|
||||
val matrixOutput: ItemStack = CraftingManager.getInstance.findMatchingRecipe(inventoryCrafting, this.worldObj)
|
||||
if (matrixOutput != null && this.getCraftingManager.getIdealRecipe(matrixOutput) != null)
|
||||
{
|
||||
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = matrixOutput
|
||||
didCraft = true
|
||||
}
|
||||
if (!didCraft)
|
||||
{
|
||||
val filterStack: ItemStack = craftingMatrix(TileEngineeringTable.CENTER_SLOT)
|
||||
if (filterStack != null && filterStack.getItem.isInstanceOf[ItemImprint])
|
||||
{
|
||||
val filters: java.util.List[ItemStack] = ItemImprint.getFilters(filterStack)
|
||||
for (o <- filters)
|
||||
{
|
||||
val outputStack: ItemStack = o
|
||||
if (outputStack != null)
|
||||
{
|
||||
val idealRecipe: Pair[ItemStack, Array[ItemStack]] = this.getCraftingManager.getIdealRecipe(outputStack)
|
||||
if (idealRecipe != null)
|
||||
{
|
||||
val recipeOutput: ItemStack = idealRecipe.left
|
||||
if (recipeOutput != null & recipeOutput.stackSize > 0)
|
||||
{
|
||||
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = recipeOutput
|
||||
didCraft = true
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AutoCraftingManager that does all the crafting results
|
||||
*/
|
||||
def getCraftingManager: AutoCraftingManager =
|
||||
{
|
||||
if (craftManager == null)
|
||||
{
|
||||
craftManager = new AutoCraftingManager(this)
|
||||
}
|
||||
return craftManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an InventoryCrafting Matrix on the fly.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
def getCraftingMatrix: InventoryCrafting =
|
||||
{
|
||||
val inventoryCrafting: InventoryCrafting = new InventoryCrafting(new ContainerDummy(this), 3, 3)
|
||||
|
||||
for (i <- 0 until this.craftingMatrix.length)
|
||||
{
|
||||
inventoryCrafting.setInventorySlotContents(i, this.craftingMatrix(i))
|
||||
}
|
||||
return inventoryCrafting
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a "fake inventory" and hook the player up to the crafter to use the player's items.
|
||||
*/
|
||||
|
@ -536,6 +418,162 @@ class TileEngineeringTable extends TileInventory(Material.wood) with IPacketRece
|
|||
}
|
||||
}
|
||||
|
||||
override def setInventorySlotContents(slot: Int, itemStack: ItemStack)
|
||||
{
|
||||
if (slot < TileEngineeringTable.CRAFTING_MATRIX_END)
|
||||
{
|
||||
craftingMatrix(slot) = itemStack
|
||||
}
|
||||
else if (slot < TileEngineeringTable.CRAFTING_OUTPUT_END)
|
||||
{
|
||||
outputInventory(slot - TileEngineeringTable.CRAFTING_MATRIX_END) = itemStack
|
||||
}
|
||||
else if (slot < TileEngineeringTable.PLAYER_OUTPUT_END && this.invPlayer != null)
|
||||
{
|
||||
this.invPlayer.setInventorySlotContents(slot - TileEngineeringTable.CRAFTING_OUTPUT_END, itemStack)
|
||||
val player: EntityPlayer = this.invPlayer.player
|
||||
if (player.isInstanceOf[EntityPlayerMP])
|
||||
{
|
||||
(player.asInstanceOf[EntityPlayerMP]).sendContainerToPlayer(player.inventoryContainer)
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
inventory.setInventorySlotContents(slotID, itemStack)
|
||||
}
|
||||
idDisplacement += inventory.getSizeInventory
|
||||
}
|
||||
}
|
||||
}
|
||||
onInventoryChanged
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates all the output slots. Call this to update the Engineering Table.
|
||||
*/
|
||||
override def onInventoryChanged
|
||||
{
|
||||
if (worldObj != null)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = null
|
||||
var didCraft: Boolean = false
|
||||
val inventoryCrafting: InventoryCrafting = this.getCraftingMatrix
|
||||
val matrixOutput: ItemStack = CraftingManager.getInstance.findMatchingRecipe(inventoryCrafting, this.worldObj)
|
||||
if (matrixOutput != null && this.getCraftingManager.getIdealRecipe(matrixOutput) != null)
|
||||
{
|
||||
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = matrixOutput
|
||||
didCraft = true
|
||||
}
|
||||
if (!didCraft)
|
||||
{
|
||||
val filterStack: ItemStack = craftingMatrix(TileEngineeringTable.CENTER_SLOT)
|
||||
if (filterStack != null && filterStack.getItem.isInstanceOf[ItemImprint])
|
||||
{
|
||||
val filters: java.util.List[ItemStack] = ItemImprint.getFilters(filterStack)
|
||||
for (o <- filters)
|
||||
{
|
||||
val outputStack: ItemStack = o
|
||||
if (outputStack != null)
|
||||
{
|
||||
val idealRecipe: Pair[ItemStack, Array[ItemStack]] = this.getCraftingManager.getIdealRecipe(outputStack)
|
||||
if (idealRecipe != null)
|
||||
{
|
||||
val recipeOutput: ItemStack = idealRecipe.left
|
||||
if (recipeOutput != null & recipeOutput.stackSize > 0)
|
||||
{
|
||||
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = recipeOutput
|
||||
didCraft = true
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AutoCraftingManager that does all the crafting results
|
||||
*/
|
||||
def getCraftingManager: AutoCraftingManager =
|
||||
{
|
||||
if (craftManager == null)
|
||||
{
|
||||
craftManager = new AutoCraftingManager(this)
|
||||
}
|
||||
return craftManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an InventoryCrafting Matrix on the fly.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
def getCraftingMatrix: InventoryCrafting =
|
||||
{
|
||||
val inventoryCrafting: InventoryCrafting = new InventoryCrafting(new ContainerDummy(this), 3, 3)
|
||||
|
||||
for (i <- 0 until this.craftingMatrix.length)
|
||||
{
|
||||
inventoryCrafting.setInventorySlotContents(i, this.craftingMatrix(i))
|
||||
}
|
||||
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 isItemValidForSlot(i: Int, itemstack: ItemStack): Boolean =
|
||||
{
|
||||
return true
|
||||
|
@ -637,44 +675,6 @@ 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
|
||||
|
|
|
@ -184,13 +184,11 @@ class TileFirebox extends SpatialTile(Material.rock) with IFluidHandler with TIn
|
|||
}
|
||||
}
|
||||
|
||||
def isBurning: Boolean = burnTime > 0
|
||||
|
||||
override def getSizeInventory = 1
|
||||
|
||||
def getMeltIronEnergy(volume: Float): Long =
|
||||
{
|
||||
val temperatureChange: Float = 1811 - ThermalPhysics.getTemperatureForCoordinate(worldObj, xCoord, zCoord)
|
||||
val temperatureChange: Float = 1811 - ThermalPhysics.getDefaultTemperature(worldObj, xCoord, zCoord)
|
||||
val mass: Float = ThermalPhysics.getMass(volume, 7.9f)
|
||||
return (ThermalPhysics.getEnergyForTemperatureChange(mass, 450, temperatureChange) + ThermalPhysics.getEnergyForStateChange(mass, 272000)).asInstanceOf[Long]
|
||||
}
|
||||
|
@ -295,6 +293,8 @@ class TileFirebox extends SpatialTile(Material.rock) with IFluidHandler with TIn
|
|||
return if (isBurning) (if (isElectric) SpatialBlock.icon.get("firebox_electric_side_on") else SpatialBlock.icon.get("firebox_side_on")) else (if (isElectric) SpatialBlock.icon.get("firebox_electric_side_off") else SpatialBlock.icon.get("firebox_side_off"))
|
||||
}
|
||||
|
||||
def isBurning: Boolean = burnTime > 0
|
||||
|
||||
override def click(player: EntityPlayer)
|
||||
{
|
||||
if (server)
|
||||
|
|
|
@ -2,7 +2,7 @@ package edx.core
|
|||
|
||||
import java.awt.Color
|
||||
|
||||
import codechicken.multipart.{TMultiPart, TileMultipart}
|
||||
import codechicken.multipart.TileMultipart
|
||||
import cpw.mods.fml.client.FMLClientHandler
|
||||
import cpw.mods.fml.client.registry.{ClientRegistry, RenderingRegistry}
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
|
@ -23,20 +23,19 @@ import edx.mechanical.mech.process.crusher.{RenderMechanicalPiston, TileMechanic
|
|||
import edx.mechanical.mech.turbine._
|
||||
import edx.quantum.gate.RenderQuantumGlyph
|
||||
import edx.quantum.laser.fx.{EntityBlockParticleFX, EntityLaserFX, EntityScorchFX}
|
||||
import edx.quantum.machine.accelerator.{EntityParticle, GuiAccelerator, RenderParticle, TileAccelerator}
|
||||
import edx.quantum.machine.accelerator.{EntityParticle, RenderParticle}
|
||||
import edx.quantum.machine.boiler.{GuiNuclearBoiler, RenderNuclearBoiler, TileNuclearBoiler}
|
||||
import edx.quantum.machine.centrifuge.{GuiCentrifuge, RenderCentrifuge, TileCentrifuge}
|
||||
import edx.quantum.machine.extractor.{GuiChemicalExtractor, RenderChemicalExtractor, TileChemicalExtractor}
|
||||
import edx.quantum.machine.plasma.{RenderPlasmaHeater, TilePlasmaHeater}
|
||||
import edx.quantum.machine.quantum.{GuiQuantumAssembler, RenderQuantumAssembler, TileQuantumAssembler}
|
||||
import edx.quantum.machine.reactor.{GuiReactorCell, RenderReactorCell, TileReactorCell}
|
||||
import edx.quantum.machine.quantum.{RenderQuantumAssembler, TileQuantumAssembler}
|
||||
import edx.quantum.machine.thermometer.{RenderThermometer, TileThermometer}
|
||||
import edx.quantum.reactor.{GuiReactorCell, TileReactorCell}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.client.gui.GuiScreen
|
||||
import net.minecraft.client.particle.{EntityDiggingFX, EntityFX}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.world.World
|
||||
import resonant.lib.render.fx.FXElectricBolt2
|
||||
import resonant.lib.render.wrapper.ItemRenderHandler
|
||||
|
@ -77,7 +76,6 @@ import resonant.lib.transform.vector.Vector3
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileNuclearBoiler], new RenderNuclearBoiler)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileThermometer], new RenderThermometer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileChemicalExtractor], new RenderChemicalExtractor)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileReactorCell], new RenderReactorCell)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileQuantumAssembler], new RenderQuantumAssembler)
|
||||
RenderingRegistry.registerEntityRenderingHandler(classOf[EntityParticle], new RenderParticle)
|
||||
|
||||
|
@ -88,40 +86,23 @@ import resonant.lib.transform.vector.Vector3
|
|||
|
||||
override def getClientGuiElement(id: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef =
|
||||
{
|
||||
val tileEntity: TileEntity = world.getTileEntity(x, y, z)
|
||||
if (tileEntity.isInstanceOf[TileMultipart])
|
||||
world.getTileEntity(x, y, z) match
|
||||
{
|
||||
val part: TMultiPart = (tileEntity.asInstanceOf[TileMultipart]).partMap(id)
|
||||
if (part.isInstanceOf[PartMultimeter])
|
||||
{
|
||||
return new GuiMultimeter(player.inventory, part.asInstanceOf[PartMultimeter])
|
||||
}
|
||||
case tile: TileMultipart =>
|
||||
val part = tile.partMap(id)
|
||||
if (part.isInstanceOf[PartMultimeter])
|
||||
new GuiMultimeter(player.inventory, part.asInstanceOf[PartMultimeter])
|
||||
null
|
||||
case tile: TileCentrifuge =>
|
||||
new GuiCentrifuge(player.inventory, tile)
|
||||
case tile: TileChemicalExtractor =>
|
||||
new GuiChemicalExtractor(player.inventory, tile)
|
||||
case tile: TileNuclearBoiler =>
|
||||
new GuiNuclearBoiler(player, tile)
|
||||
case tile: TileReactorCell =>
|
||||
new GuiReactorCell(player.inventory, tile)
|
||||
case _ => null
|
||||
}
|
||||
else if (tileEntity.isInstanceOf[TileCentrifuge])
|
||||
{
|
||||
return new GuiCentrifuge(player.inventory, (tileEntity.asInstanceOf[TileCentrifuge]))
|
||||
}
|
||||
else if (tileEntity.isInstanceOf[TileChemicalExtractor])
|
||||
{
|
||||
return new GuiChemicalExtractor(player.inventory, (tileEntity.asInstanceOf[TileChemicalExtractor]))
|
||||
}
|
||||
else if (tileEntity.isInstanceOf[TileAccelerator])
|
||||
{
|
||||
return new GuiAccelerator(player, (tileEntity.asInstanceOf[TileAccelerator]))
|
||||
}
|
||||
else if (tileEntity.isInstanceOf[TileQuantumAssembler])
|
||||
{
|
||||
return new GuiQuantumAssembler(player.inventory, (tileEntity.asInstanceOf[TileQuantumAssembler]))
|
||||
}
|
||||
else if (tileEntity.isInstanceOf[TileNuclearBoiler])
|
||||
{
|
||||
return new GuiNuclearBoiler(player, (tileEntity.asInstanceOf[TileNuclearBoiler]))
|
||||
}
|
||||
else if (tileEntity.isInstanceOf[TileReactorCell])
|
||||
{
|
||||
return new GuiReactorCell(player.inventory, tileEntity.asInstanceOf[TileReactorCell])
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override def isPaused: Boolean =
|
||||
|
|
|
@ -9,7 +9,7 @@ import edx.quantum.machine.boiler.{ContainerNuclearBoiler, TileNuclearBoiler}
|
|||
import edx.quantum.machine.centrifuge.{ContainerCentrifuge, TileCentrifuge}
|
||||
import edx.quantum.machine.extractor.{ContainerChemicalExtractor, TileChemicalExtractor}
|
||||
import edx.quantum.machine.quantum.{ContainerQuantumAssembler, TileQuantumAssembler}
|
||||
import edx.quantum.machine.reactor.{ContainerReactorCell, TileReactorCell}
|
||||
import edx.quantum.reactor.{ContainerReactorCell, TileReactorCell}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
|
@ -101,15 +101,15 @@ class CommonProxy extends AbstractProxy
|
|||
this.renderElectricShock(world, start, target, r, g, b, true)
|
||||
}
|
||||
|
||||
def renderElectricShock(world: World, start: Vector3, target: Vector3, r: Float, g: Float, b: Float, split: Boolean)
|
||||
{
|
||||
}
|
||||
|
||||
def renderElectricShock(world: World, start: Vector3, target: Vector3, color: Color, split: Boolean)
|
||||
{
|
||||
this.renderElectricShock(world, start, target, color.getRed / 255f, color.getGreen / 255f, color.getBlue / 255f, split)
|
||||
}
|
||||
|
||||
def renderElectricShock(world: World, start: Vector3, target: Vector3, r: Float, g: Float, b: Float, split: Boolean)
|
||||
{
|
||||
}
|
||||
|
||||
def renderElectricShock(world: World, start: Vector3, target: Vector3)
|
||||
{
|
||||
this.renderElectricShock(world, start, target, true)
|
||||
|
|
|
@ -34,23 +34,23 @@ class GridMechanical extends GridNode[NodeMechanical] with IUpdate
|
|||
override def reconstruct(first: NodeMechanical)
|
||||
{
|
||||
super.reconstruct(first)
|
||||
UpdateTicker.threaded.addUpdater(this)
|
||||
UpdateTicker.world.addUpdater(this)
|
||||
isLocked = false
|
||||
}
|
||||
|
||||
override def deconstruct(first: NodeMechanical)
|
||||
{
|
||||
super.deconstruct(first)
|
||||
UpdateTicker.threaded.removeUpdater(this)
|
||||
UpdateTicker.world.removeUpdater(this)
|
||||
}
|
||||
|
||||
override def update(deltaTime: Double)
|
||||
{
|
||||
getNodes synchronized
|
||||
nodes synchronized
|
||||
{
|
||||
load = 0
|
||||
|
||||
getNodes.foreach(
|
||||
nodes.foreach(
|
||||
n =>
|
||||
{
|
||||
n.torque = 0
|
||||
|
@ -72,7 +72,6 @@ class GridMechanical extends GridNode[NodeMechanical] with IUpdate
|
|||
|
||||
allPassed = Seq.empty[NodeMechanical]
|
||||
|
||||
// UpdateTicker.world.enqueue(resetNodes)
|
||||
resetNodes()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import edx.quantum.machine.extractor.TileChemicalExtractor
|
|||
import edx.quantum.machine.fulmination.{FulminationHandler, TileFulmination}
|
||||
import edx.quantum.machine.plasma.{TilePlasma, TilePlasmaHeater}
|
||||
import edx.quantum.machine.quantum.TileQuantumAssembler
|
||||
import edx.quantum.machine.reactor.{TileControlRod, TileReactorCell}
|
||||
import edx.quantum.reactor.{TileControlRod, TileReactorCell}
|
||||
import edx.quantum.schematic.{SchematicAccelerator, SchematicBreedingReactor, SchematicFissionReactor, SchematicFusionReactor}
|
||||
import ic2.api.item.IC2Items
|
||||
import net.minecraft.block.Block
|
||||
|
@ -77,7 +77,7 @@ object QuantumContent extends ContentHolder
|
|||
//Cells
|
||||
@ExplicitContentName(value = "cellEmpty")
|
||||
var itemCell: Item = new ItemCell("cellEmpty")
|
||||
var itemFissileFuel: Item = new ItemFissileFuel
|
||||
var itemFissileFuel: Item = new ItemFuelRod
|
||||
var itemBreedingRod: Item = new ItemBreederFuel
|
||||
@ExplicitContentName
|
||||
var itemDarkMatter: Item = new ItemCell("darkMatter")
|
||||
|
@ -193,6 +193,63 @@ object QuantumContent extends ContentHolder
|
|||
|
||||
def FLUID_PLASMA: Fluid = new Fluid("plasma").setGaseous(true)
|
||||
|
||||
def FLUID_URANIUM_HEXAFLOURIDE: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("uraniumhexafluoride");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("uraniumhexafluoride").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
def FLUID_STEAM: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("steam");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("steam").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
def FLUID_DEUTERIUM: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("deuterium");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("deuterium").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
/** Gets the Fluid instance of Tritium */
|
||||
def getFluidTritium: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("tritium");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("tritium").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
/** Gets the Fluid instance of Toxic Waste */
|
||||
def getFluidToxicWaste: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("toxicwaste");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("toxicwaste").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
override def postInit()
|
||||
{
|
||||
super.postInit()
|
||||
|
@ -330,6 +387,16 @@ object QuantumContent extends ContentHolder
|
|||
return isItemStackOreDictionaryCompatible(itemStack, "cellWater")
|
||||
}
|
||||
|
||||
def isItemStackUraniumOre(itemStack: ItemStack): Boolean =
|
||||
{
|
||||
return isItemStackOreDictionaryCompatible(itemStack, "dropUranium", "oreUranium")
|
||||
}
|
||||
|
||||
def isItemStackDeuteriumCell(itemStack: ItemStack): Boolean =
|
||||
{
|
||||
return isItemStackOreDictionaryCompatible(itemStack, "molecule_1d", "molecule_1h2", "cellDeuterium")
|
||||
}
|
||||
|
||||
/** Compare to Ore Dict
|
||||
*
|
||||
* @param itemStack
|
||||
|
@ -351,16 +418,6 @@ object QuantumContent extends ContentHolder
|
|||
return false
|
||||
}
|
||||
|
||||
def isItemStackUraniumOre(itemStack: ItemStack): Boolean =
|
||||
{
|
||||
return isItemStackOreDictionaryCompatible(itemStack, "dropUranium", "oreUranium")
|
||||
}
|
||||
|
||||
def isItemStackDeuteriumCell(itemStack: ItemStack): Boolean =
|
||||
{
|
||||
return isItemStackOreDictionaryCompatible(itemStack, "molecule_1d", "molecule_1h2", "cellDeuterium")
|
||||
}
|
||||
|
||||
def isItemStackTritiumCell(itemStack: ItemStack): Boolean =
|
||||
{
|
||||
return isItemStackOreDictionaryCompatible(itemStack, "molecule_h3", "cellTritium")
|
||||
|
@ -379,69 +436,12 @@ object QuantumContent extends ContentHolder
|
|||
|
||||
def FLUIDSTACK_URANIUM_HEXAFLOURIDE: FluidStack = new FluidStack(QuantumContent.FLUID_URANIUM_HEXAFLOURIDE, 0)
|
||||
|
||||
def FLUID_URANIUM_HEXAFLOURIDE: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("uraniumhexafluoride");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("uraniumhexafluoride").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
def FLUIDSTACK_STEAM: FluidStack = new FluidStack(FLUID_STEAM, 0)
|
||||
|
||||
def FLUID_STEAM: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("steam");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("steam").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
def FLUIDSTACK_DEUTERIUM: FluidStack = new FluidStack(FLUID_DEUTERIUM, 0)
|
||||
|
||||
def FLUID_DEUTERIUM: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("deuterium");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("deuterium").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
def getFluidStackTritium: FluidStack = new FluidStack(getFluidTritium, 0)
|
||||
|
||||
/** Gets the Fluid instance of Tritium */
|
||||
def getFluidTritium: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("tritium");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("tritium").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
|
||||
/** Gets a FluidStack of Toxic Waste */
|
||||
def getStackToxicWaste: FluidStack = new FluidStack(getFluidToxicWaste, 0)
|
||||
|
||||
/** Gets the Fluid instance of Toxic Waste */
|
||||
def getFluidToxicWaste: Fluid =
|
||||
{
|
||||
var fluid: Fluid = FluidRegistry.getFluid("toxicwaste");
|
||||
if (fluid == null)
|
||||
{
|
||||
fluid = new Fluid("toxicwaste").setGaseous(true)
|
||||
FluidRegistry.registerFluid(fluid)
|
||||
}
|
||||
return fluid
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,13 @@ import resonant.api.tile.{IReactor, IReactorComponent}
|
|||
class ItemBreederFuel extends ItemRadioactive with IReactorComponent
|
||||
{
|
||||
//Constructor
|
||||
this.setMaxDamage(ItemFissileFuel.DECAY)
|
||||
this.setMaxDamage(ItemFuelRod.decay)
|
||||
this.setMaxStackSize(1)
|
||||
this.setNoRepair
|
||||
|
||||
override def onReact(itemStack: ItemStack, reactor: IReactor)
|
||||
{
|
||||
reactor.heat(ItemFissileFuel.ENERGY_PER_TICK / 2)
|
||||
reactor.heat(ItemFuelRod.energyPerTick / 2)
|
||||
if (reactor.world.getWorldTime % 20 == 0)
|
||||
{
|
||||
itemStack.setItemDamage(Math.min(itemStack.getItemDamage + 1, itemStack.getMaxDamage))
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
package edx.quantum.items
|
||||
|
||||
import java.util.List
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import edx.core.{EDXCreativeTab, Reference, Settings}
|
||||
import edx.quantum.QuantumContent
|
||||
import edx.quantum.machine.reactor.TileReactorCell
|
||||
import net.minecraft.creativetab.CreativeTabs
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.FluidStack
|
||||
import resonant.api.tile.{IReactor, IReactorComponent}
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
import resonant.lib.wrapper.CollectionWrapper._
|
||||
|
||||
/**
|
||||
* Fissile fuel rod
|
||||
*/
|
||||
object ItemFissileFuel
|
||||
{
|
||||
final val DECAY: Int = 2500
|
||||
/**
|
||||
* Temperature at which the fuel rod will begin to re-enrich itself.
|
||||
*/
|
||||
final val BREEDING_TEMP: Int = 1100
|
||||
/**
|
||||
* The energy in one KG of uranium is: 72PJ, 100TJ in one cell of uranium.
|
||||
*/
|
||||
final val ENERGY: Long = 100000000000L
|
||||
/**
|
||||
* Approximately 20,000,000J per tick. 400 MW.
|
||||
*/
|
||||
final val ENERGY_PER_TICK: Long = ENERGY / 50000
|
||||
}
|
||||
|
||||
class ItemFissileFuel extends ItemRadioactive with IReactorComponent
|
||||
{
|
||||
|
||||
//Constructor
|
||||
this.setMaxStackSize(1)
|
||||
this.setMaxDamage(ItemFissileFuel.DECAY)
|
||||
this.setNoRepair
|
||||
this.setUnlocalizedName(Reference.prefix + "rodBreederFuel")
|
||||
this.setTextureName(Reference.prefix + "breederFuel")
|
||||
setCreativeTab(EDXCreativeTab)
|
||||
|
||||
def onReact(itemStack: ItemStack, reactor: IReactor)
|
||||
{
|
||||
val tileEntity: TileEntity = reactor.asInstanceOf[TileEntity]
|
||||
val worldObj: World = tileEntity.getWorldObj
|
||||
var reactors: Int = 0
|
||||
|
||||
for (i <- 0 to 6)
|
||||
{
|
||||
val checkPos: Vector3 = new Vector3(tileEntity).add(ForgeDirection.getOrientation(i))
|
||||
val tile: TileEntity = checkPos.getTileEntity(worldObj)
|
||||
if (tile.isInstanceOf[TileReactorCell] && (tile.asInstanceOf[TileReactorCell]).getTemperature > ItemFissileFuel.BREEDING_TEMP)
|
||||
{
|
||||
reactors += 1
|
||||
}
|
||||
}
|
||||
|
||||
if (reactors >= 2)
|
||||
{
|
||||
if (worldObj.rand.nextInt(1000) <= 100 && reactor.getTemperature > (ItemFissileFuel.BREEDING_TEMP / 2))
|
||||
{
|
||||
val healAmt: Int = worldObj.rand.nextInt(5)
|
||||
itemStack.setItemDamage(Math.max(itemStack.getItemDamage - healAmt, 0))
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reactor.heat(ItemFissileFuel.ENERGY_PER_TICK)
|
||||
if (reactor.world.getWorldTime % 20 == 0)
|
||||
{
|
||||
itemStack.setItemDamage(Math.min(itemStack.getItemDamage + 1, itemStack.getMaxDamage))
|
||||
}
|
||||
if (Settings.allowToxicWaste && worldObj.rand.nextFloat > 0.5)
|
||||
{
|
||||
val fluid: FluidStack = QuantumContent.getStackToxicWaste.copy
|
||||
fluid.amount = 1
|
||||
reactor.fill(ForgeDirection.UNKNOWN, fluid, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def getSubItems(item: Item, par2CreativeTabs: CreativeTabs, par3List: List[_])
|
||||
{
|
||||
par3List.add(new ItemStack(item, 1, 0))
|
||||
par3List.add(new ItemStack(item, 1, getMaxDamage - 1))
|
||||
}
|
||||
}
|
88
src/main/scala/edx/quantum/items/ItemFuelRod.scala
Normal file
88
src/main/scala/edx/quantum/items/ItemFuelRod.scala
Normal file
|
@ -0,0 +1,88 @@
|
|||
package edx.quantum.items
|
||||
|
||||
import java.util.List
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import edx.core.{EDXCreativeTab, Reference}
|
||||
import net.minecraft.creativetab.CreativeTabs
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.api.tile.{IReactor, IReactorComponent}
|
||||
import resonant.lib.grid.thermal.ThermalGrid
|
||||
import resonant.lib.transform.vector.VectorWorld
|
||||
import resonant.lib.wrapper.CollectionWrapper._
|
||||
|
||||
/**
|
||||
* Fissile fuel rod
|
||||
*/
|
||||
object ItemFuelRod
|
||||
{
|
||||
final val decay: Int = 2500
|
||||
/**
|
||||
* Temperature at which the fuel rod will begin to re-enrich itself.
|
||||
*/
|
||||
final val breedingTemp: Int = 1100
|
||||
|
||||
/**
|
||||
* The energy in one KG of uranium is: 72PJ, 100TJ in one cell of uranium.
|
||||
*/
|
||||
final val energyDensity = 100000000000d
|
||||
/**
|
||||
* Approximately 20,000,000J per tick. 400 MW.
|
||||
*/
|
||||
final val energyPerTick = energyDensity / 50000
|
||||
}
|
||||
|
||||
class ItemFuelRod extends ItemRadioactive with IReactorComponent
|
||||
{
|
||||
//Constructor
|
||||
setMaxStackSize(1)
|
||||
setMaxDamage(ItemFuelRod.decay)
|
||||
setNoRepair()
|
||||
setUnlocalizedName(Reference.prefix + "rodBreederFuel")
|
||||
setTextureName(Reference.prefix + "breederFuel")
|
||||
setCreativeTab(EDXCreativeTab)
|
||||
|
||||
def onReact(itemStack: ItemStack, reactor: IReactor)
|
||||
{
|
||||
val tile = reactor.asInstanceOf[TileEntity]
|
||||
val world = tile.getWorldObj
|
||||
val reactors =
|
||||
ForgeDirection.VALID_DIRECTIONS
|
||||
.map(d => (new VectorWorld(tile) + d).getTileEntity)
|
||||
.filter(_.isInstanceOf[IReactor])
|
||||
.count(t => ThermalGrid.getTemperature(new VectorWorld(t)) > ItemFuelRod.breedingTemp)
|
||||
|
||||
if (reactors >= 2)
|
||||
{
|
||||
/**
|
||||
* Do fuel breeding
|
||||
*/
|
||||
if (world.rand.nextInt(1000) <= 100 && ThermalGrid.getTemperature(new VectorWorld(tile)) > (ItemFuelRod.breedingTemp / 2))
|
||||
{
|
||||
val breedAmount = world.rand.nextInt(5)
|
||||
itemStack.setItemDamage(Math.max(itemStack.getItemDamage - breedAmount, 0))
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Do fission
|
||||
*/
|
||||
reactor.heat(ItemFuelRod.energyPerTick)
|
||||
|
||||
if (reactor.world.getWorldTime % 20 == 0)
|
||||
{
|
||||
itemStack.setItemDamage(Math.min(itemStack.getItemDamage + 1, itemStack.getMaxDamage))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def getSubItems(item: Item, par2CreativeTabs: CreativeTabs, par3List: List[_])
|
||||
{
|
||||
par3List.add(new ItemStack(item, 1, 0))
|
||||
par3List.add(new ItemStack(item, 1, getMaxDamage - 1))
|
||||
}
|
||||
}
|
|
@ -27,8 +27,8 @@ class TilePlasma extends SpatialTile(Material.lava)
|
|||
private var temperature: Double = TilePlasma.plasmaMaxTemperature
|
||||
|
||||
//Constructor
|
||||
textureName_$eq("plasma")
|
||||
isOpaqueCube(false)
|
||||
textureName = "plasma"
|
||||
isOpaqueCube = false
|
||||
|
||||
override def getLightValue(access: IBlockAccess): Int =
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ class TilePlasma extends SpatialTile(Material.lava)
|
|||
override def update
|
||||
{
|
||||
super.update
|
||||
ThermalGrid.addTemperature(toVectorWorld, ((temperature - ThermalGrid.getTemperature(toVectorWorld)) * 0.1f).asInstanceOf[Float])
|
||||
ThermalGrid.addHeat(toVectorWorld, ((temperature - ThermalGrid.getTemperature(toVectorWorld)) * 0.1f).asInstanceOf[Float])
|
||||
if (ticks % 20 == 0)
|
||||
{
|
||||
temperature /= 1.5
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
package edx.quantum.machine.reactor
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import edx.core.Reference
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom}
|
||||
import org.lwjgl.opengl.GL11
|
||||
import resonant.lib.render.RenderUtility
|
||||
import resonant.lib.render.model.ModelCube
|
||||
|
||||
@SideOnly(Side.CLIENT) object RenderReactorCell
|
||||
{
|
||||
final val MODEL_TOP: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellTop.tcn"))
|
||||
final val MODEL_MIDDLE: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellMiddle.tcn"))
|
||||
final val MODEL_BOTTOM: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellBottom.tcn"))
|
||||
final val TEXTURE_TOP: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellTop.png")
|
||||
final val TEXTURE_MIDDLE: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellMiddle.png")
|
||||
final val TEXTURE_BOTTOM: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellBottom.png")
|
||||
final val TEXTURE_FISSILE: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "fissileMaterial.png")
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) class RenderReactorCell extends TileEntitySpecialRenderer
|
||||
{
|
||||
def renderTileEntityAt(t: TileEntity, x: Double, y: Double, z: Double, f: Float)
|
||||
{
|
||||
val tileEntity: TileReactorCell = t.asInstanceOf[TileReactorCell]
|
||||
GL11.glPushMatrix
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
||||
var meta: Int = 2
|
||||
if (tileEntity.world != null)
|
||||
{
|
||||
meta = tileEntity.getBlockMetadata
|
||||
}
|
||||
val hasBelow: Boolean = tileEntity.world != null && t.getWorldObj.getTileEntity(t.xCoord, t.yCoord - 1, t.zCoord).isInstanceOf[TileReactorCell]
|
||||
|
||||
if (meta == 0)
|
||||
{
|
||||
bindTexture(RenderReactorCell.TEXTURE_BOTTOM)
|
||||
RenderReactorCell.MODEL_BOTTOM.renderAll
|
||||
}
|
||||
else if (meta == 1)
|
||||
{
|
||||
bindTexture(RenderReactorCell.TEXTURE_MIDDLE)
|
||||
GL11.glTranslatef(0, 0.075f, 0)
|
||||
GL11.glScalef(1f, 1.15f, 1f)
|
||||
RenderReactorCell.MODEL_MIDDLE.renderAll
|
||||
}
|
||||
else
|
||||
{
|
||||
bindTexture(RenderReactorCell.TEXTURE_TOP)
|
||||
if (hasBelow)
|
||||
{
|
||||
GL11.glScalef(1f, 1.32f, 1f)
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef(0, 0.1f, 0)
|
||||
GL11.glScalef(1f, 1.2f, 1f)
|
||||
}
|
||||
if (hasBelow)
|
||||
{
|
||||
RenderReactorCell.MODEL_TOP.renderAllExcept("BottomPad", "BaseDepth", "BaseWidth", "Base")
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderReactorCell.MODEL_TOP.renderAll
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix
|
||||
if (tileEntity.getStackInSlot(0) != null)
|
||||
{
|
||||
val height: Float = tileEntity.getHeight * ((tileEntity.getStackInSlot(0).getMaxDamage - tileEntity.getStackInSlot(0).getItemDamage).asInstanceOf[Float] / tileEntity.getStackInSlot(0).getMaxDamage.asInstanceOf[Float])
|
||||
GL11.glPushMatrix
|
||||
GL11.glTranslatef(x.asInstanceOf[Float] + 0.5F, y.asInstanceOf[Float] + 0.5F * height, z.asInstanceOf[Float] + 0.5F)
|
||||
GL11.glScalef(0.4f, 0.9f * height, 0.4f)
|
||||
bindTexture(RenderReactorCell.TEXTURE_FISSILE)
|
||||
RenderUtility.disableLighting
|
||||
ModelCube.INSTNACE.render
|
||||
RenderUtility.enableLighting
|
||||
GL11.glPopMatrix
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,492 +0,0 @@
|
|||
package edx.quantum.machine.reactor
|
||||
|
||||
import java.util.{ArrayList, List}
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import edx.core.Reference
|
||||
import edx.quantum.QuantumContent
|
||||
import edx.quantum.machine.plasma.TilePlasma
|
||||
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.MinecraftForge
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.{Fluid, FluidContainerRegistry, FluidStack, FluidTank, FluidTankInfo, IFluidHandler}
|
||||
import resonant.api.event.PlasmaEvent
|
||||
import resonant.api.tile.{IReactor, IReactorComponent}
|
||||
import resonant.lib.grid.thermal.{ThermalGrid, ThermalPhysics}
|
||||
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.mixed.TileInventory
|
||||
import resonant.lib.prefab.tile.multiblock.reference.{IMultiBlockStructure, MultiBlockHandler}
|
||||
import resonant.lib.transform.vector.{Vector3, VectorWorld}
|
||||
import resonant.lib.utility.inventory.InventoryUtility
|
||||
|
||||
import scala.collection.convert.wrapAll._
|
||||
|
||||
/** The primary reactor component cell used to build reactors with.
|
||||
*
|
||||
* @author Calclavia */
|
||||
object TileReactorCell
|
||||
{
|
||||
final val RADIUS: Int = 2
|
||||
final val MELTING_POINT: Int = 2000
|
||||
}
|
||||
|
||||
class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStructure[TileReactorCell] with IReactor with IFluidHandler
|
||||
{
|
||||
|
||||
private final val specificHeatCapacity: Int = 1000
|
||||
private final val mass: Float = ThermalPhysics.getMass(1000, 7)
|
||||
var tank: FluidTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 15)
|
||||
@Synced var temperature: Float = 295
|
||||
private var previousTemperature: Float = 295
|
||||
private var shouldUpdate: Boolean = false
|
||||
private var prevInternalEnergy: Long = 0
|
||||
private var internalEnergy: Long = 0
|
||||
private var meltdownCounter: Int = 0
|
||||
private var meltdownCounterMaximum: Int = 1000
|
||||
/** Multiblock Methods. */
|
||||
private var multiBlock: MultiBlockHandler[TileReactorCell] = null
|
||||
|
||||
textureName = "machine"
|
||||
isOpaqueCube = false
|
||||
normalRender = false
|
||||
|
||||
override def getSizeInventory: Int = 1
|
||||
|
||||
override def onWorldJoin
|
||||
{
|
||||
updatePositionStatus
|
||||
}
|
||||
|
||||
override def onNeighborChanged(block: Block)
|
||||
{
|
||||
updatePositionStatus
|
||||
}
|
||||
|
||||
/** Multiblock Methods */
|
||||
def updatePositionStatus
|
||||
{
|
||||
val mainTile: TileReactorCell = getLowest
|
||||
mainTile.getMultiBlock.deconstruct
|
||||
mainTile.getMultiBlock.construct
|
||||
val top: Boolean = (toVector3 + new Vector3(0, 1, 0)).getTileEntity(worldObj).isInstanceOf[TileReactorCell]
|
||||
val bottom: Boolean = (toVector3 + new Vector3(0, -1, 0)).getTileEntity(worldObj).isInstanceOf[TileReactorCell]
|
||||
if (top && bottom)
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 3)
|
||||
}
|
||||
else if (top)
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3)
|
||||
}
|
||||
else
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 2, 3)
|
||||
}
|
||||
}
|
||||
|
||||
def getLowest: TileReactorCell =
|
||||
{
|
||||
var lowest: TileReactorCell = this
|
||||
val checkPosition: Vector3 = toVector3
|
||||
while (true)
|
||||
{
|
||||
val t: TileEntity = checkPosition.getTileEntity(this.worldObj)
|
||||
if (t.isInstanceOf[TileReactorCell])
|
||||
{
|
||||
lowest = t.asInstanceOf[TileReactorCell]
|
||||
}
|
||||
else
|
||||
{
|
||||
return lowest;
|
||||
}
|
||||
checkPosition.y -= 1
|
||||
}
|
||||
return lowest
|
||||
}
|
||||
|
||||
override def getMultiBlock: MultiBlockHandler[TileReactorCell] =
|
||||
{
|
||||
if (multiBlock == null)
|
||||
{
|
||||
multiBlock = new MultiBlockHandler[TileReactorCell](this)
|
||||
}
|
||||
return multiBlock
|
||||
}
|
||||
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
if (!getMultiBlock.isPrimary)
|
||||
{
|
||||
if (getStackInSlot(0) != null)
|
||||
{
|
||||
if (getMultiBlock.get.getStackInSlot(0) == null)
|
||||
{
|
||||
getMultiBlock.get.setInventorySlotContents(0, getStackInSlot(0))
|
||||
setInventorySlotContents(0, null)
|
||||
}
|
||||
}
|
||||
if (tank.getFluidAmount > 0)
|
||||
{
|
||||
getMultiBlock.get.tank.fill(tank.drain(tank.getCapacity, true), true)
|
||||
}
|
||||
}
|
||||
if (!getWorld.isRemote)
|
||||
{
|
||||
if (getMultiBlock().isPrimary() && tank.getFluid != null && tank.getFluid.fluidID == QuantumContent.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)
|
||||
val spawnPos: Vector3 = toVector3 + spawnDir + spawnDir
|
||||
spawnPos.add(0, Math.max(worldObj.rand.nextInt(getHeight) - 1, 0), 0)
|
||||
if (worldObj.isAirBlock(spawnPos.xi, spawnPos.yi, spawnPos.zi))
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PlasmaEvent.SpawnPlasmaEvent(worldObj, spawnPos.xi, spawnPos.yi, spawnPos.zi, TilePlasma.plasmaMaxTemperature))
|
||||
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prevInternalEnergy = internalEnergy
|
||||
val fuelRod: ItemStack = getMultiBlock.get.getStackInSlot(0)
|
||||
if (fuelRod != null)
|
||||
{
|
||||
if (fuelRod.getItem.isInstanceOf[IReactorComponent])
|
||||
{
|
||||
(fuelRod.getItem.asInstanceOf[IReactorComponent]).onReact(fuelRod, this)
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (fuelRod.getItemDamage >= fuelRod.getMaxDamage)
|
||||
{
|
||||
getMultiBlock.get.setInventorySlotContents(0, null)
|
||||
}
|
||||
}
|
||||
if (ticks % 20 == 0)
|
||||
{
|
||||
if (worldObj.rand.nextFloat > 0.65)
|
||||
{
|
||||
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(toVector3, entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
temperature = ThermalGrid.getTemperature(toVectorWorld)
|
||||
if (internalEnergy - prevInternalEnergy > 0)
|
||||
{
|
||||
var deltaT: Float = ThermalPhysics.getTemperatureForEnergy(mass, specificHeatCapacity, ((internalEnergy - prevInternalEnergy) * 0.15).asInstanceOf[Long])
|
||||
var rods: Int = 0
|
||||
|
||||
for (i <- 0 to 5)
|
||||
{
|
||||
{
|
||||
val checkAdjacent: Vector3 = toVector3.add(ForgeDirection.getOrientation(i))
|
||||
if (checkAdjacent.getBlock(worldObj) == QuantumContent.blockControlRod)
|
||||
{
|
||||
deltaT /= 1.1f
|
||||
rods += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
ThermalGrid.addTemperature(toVectorWorld, 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)
|
||||
}
|
||||
if (worldObj.rand.nextInt(40) == 0 && this.getTemperature >= 373)
|
||||
{
|
||||
worldObj.playSoundEffect(this.xCoord + 0.5F, this.yCoord + 0.5F, this.zCoord + 0.5F, "Fluid.lavapop", 0.5F, 2.6F + (worldObj.rand.nextFloat - worldObj.rand.nextFloat) * 0.8F)
|
||||
}
|
||||
if (worldObj.getWorldTime % (QuantumContent.SECOND_IN_TICKS * 5.0F) == 0 && this.getTemperature >= 373)
|
||||
{
|
||||
val percentage: Float = Math.min(this.getTemperature / TileReactorCell.MELTING_POINT, 1.0F)
|
||||
worldObj.playSoundEffect(this.xCoord + 0.5F, this.yCoord + 0.5F, this.zCoord + 0.5F, Reference.prefix + "reactorcell", percentage, 1.0F)
|
||||
}
|
||||
if (previousTemperature != temperature && !shouldUpdate)
|
||||
{
|
||||
shouldUpdate = true
|
||||
previousTemperature = temperature
|
||||
}
|
||||
if (previousTemperature >= TileReactorCell.MELTING_POINT && meltdownCounter < meltdownCounterMaximum)
|
||||
{
|
||||
shouldUpdate = true
|
||||
meltdownCounter += 1
|
||||
}
|
||||
else if (previousTemperature >= TileReactorCell.MELTING_POINT && meltdownCounter >= meltdownCounterMaximum)
|
||||
{
|
||||
meltdownCounter = 0
|
||||
meltDown
|
||||
return
|
||||
}
|
||||
if (previousTemperature < TileReactorCell.MELTING_POINT && meltdownCounter < meltdownCounterMaximum && meltdownCounter > 0)
|
||||
{
|
||||
meltdownCounter -= 1
|
||||
}
|
||||
}
|
||||
internalEnergy = 0
|
||||
if (isOverToxic)
|
||||
{
|
||||
val leakPos: VectorWorld = toVectorWorld.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(world, QuantumContent.blockRadioactive)
|
||||
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true)
|
||||
}
|
||||
else if (block == null)
|
||||
{
|
||||
if (tank.getFluid != null)
|
||||
{
|
||||
leakPos.setBlock(world, tank.getFluid.getFluid.getBlock)
|
||||
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ticks % 60 == 0 || shouldUpdate)
|
||||
{
|
||||
shouldUpdate = false
|
||||
notifyChange
|
||||
//sendPacket(getDescPacket)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (worldObj.rand.nextInt(5) == 0 && this.getTemperature >= 373)
|
||||
{
|
||||
worldObj.spawnParticle("cloud", this.xCoord + worldObj.rand.nextInt(2), this.yCoord + 1.0F, this.zCoord + worldObj.rand.nextInt(2), 0, 0.1D, 0)
|
||||
worldObj.spawnParticle("bubble", this.xCoord + worldObj.rand.nextInt(5), this.yCoord, this.zCoord + worldObj.rand.nextInt(5), 0, 0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def isOverToxic: Boolean =
|
||||
{
|
||||
return tank.getFluid != null && tank.getFluid.fluidID == QuantumContent.getFluidToxicWaste.getID && tank.getFluid.amount >= tank.getCapacity
|
||||
}
|
||||
|
||||
def getWorld: World =
|
||||
{
|
||||
return worldObj
|
||||
}
|
||||
|
||||
def getHeight: Int =
|
||||
{
|
||||
var height: Int = 0
|
||||
val checkPosition: Vector3 = toVector3
|
||||
var tile: TileEntity = this
|
||||
while (tile.isInstanceOf[TileReactorCell])
|
||||
{
|
||||
checkPosition.y += 1
|
||||
height += 1
|
||||
tile = checkPosition.getTileEntity(worldObj)
|
||||
}
|
||||
return height
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
def getTemperature: Float =
|
||||
{
|
||||
return temperature
|
||||
}
|
||||
|
||||
override def getDescPacket: PacketAnnotation =
|
||||
{
|
||||
return new PacketAnnotation(this)
|
||||
}
|
||||
|
||||
def onMultiBlockChanged
|
||||
{
|
||||
}
|
||||
|
||||
override def getMultiBlockVectors: java.lang.Iterable[Vector3] =
|
||||
{
|
||||
val vectors: List[Vector3] = new ArrayList[Vector3]
|
||||
val checkPosition: Vector3 = toVector3
|
||||
while (true)
|
||||
{
|
||||
val t: TileEntity = checkPosition.getTileEntity(this.worldObj)
|
||||
if (t.isInstanceOf[TileReactorCell])
|
||||
{
|
||||
vectors.add(checkPosition - getPosition)
|
||||
}
|
||||
else
|
||||
{
|
||||
return vectors
|
||||
}
|
||||
checkPosition.y += 1
|
||||
}
|
||||
return vectors
|
||||
}
|
||||
|
||||
def getPosition: Vector3 =
|
||||
{
|
||||
return toVector3
|
||||
}
|
||||
|
||||
/** Reads a tile entity from NBT. */
|
||||
@SyncedInput override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
temperature = nbt.getFloat("temperature")
|
||||
tank.readFromNBT(nbt)
|
||||
getMultiBlock.load(nbt)
|
||||
}
|
||||
|
||||
/** Writes a tile entity to NBT. */
|
||||
@SyncedOutput override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
nbt.setFloat("temperature", temperature)
|
||||
tank.writeToNBT(nbt)
|
||||
getMultiBlock.save(nbt)
|
||||
}
|
||||
|
||||
override def getInventoryStackLimit: Int =
|
||||
{
|
||||
return 1
|
||||
}
|
||||
|
||||
/** Returns true if automation can insert the given item in the given slot from the given side.
|
||||
* Args: Slot, item, side */
|
||||
override def canInsertItem(slot: Int, items: ItemStack, side: Int): Boolean =
|
||||
{
|
||||
return this.isItemValidForSlot(slot, items)
|
||||
}
|
||||
|
||||
override def isItemValidForSlot(slotID: Int, itemStack: ItemStack): Boolean =
|
||||
{
|
||||
if (getMultiBlock.isPrimary && getMultiBlock.get.getStackInSlot(0) == null)
|
||||
{
|
||||
return itemStack.getItem.isInstanceOf[IReactorComponent]
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override def isUseableByPlayer(par1EntityPlayer: EntityPlayer): Boolean =
|
||||
{
|
||||
return if (worldObj.getTileEntity(xCoord, yCoord, zCoord) ne this) false else par1EntityPlayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D
|
||||
}
|
||||
|
||||
def getInvName: String =
|
||||
{
|
||||
return getBlockType.getLocalizedName
|
||||
}
|
||||
|
||||
/** Fluid Functions. */
|
||||
override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int =
|
||||
{
|
||||
return getMultiBlock.get.tank.fill(resource, doFill)
|
||||
}
|
||||
|
||||
override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
return tank.drain(maxDrain, doDrain)
|
||||
}
|
||||
|
||||
override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
if (resource == null || !resource.isFluidEqual(tank.getFluid))
|
||||
{
|
||||
return null
|
||||
}
|
||||
return tank.drain(resource.amount, doDrain)
|
||||
}
|
||||
|
||||
override def canFill(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return fluid == QuantumContent.FLUID_PLASMA
|
||||
}
|
||||
|
||||
override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return fluid == QuantumContent.getFluidToxicWaste
|
||||
}
|
||||
|
||||
override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] =
|
||||
{
|
||||
return Array[FluidTankInfo](tank.getInfo)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def getRenderBoundingBox: AxisAlignedBB =
|
||||
{
|
||||
if (getMultiBlock.isPrimary && getMultiBlock.isConstructed)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(x - 5, y - 5, z - 5, x + 5, y + 5, z + 5);
|
||||
}
|
||||
return super.getRenderBoundingBox
|
||||
}
|
||||
|
||||
def heat(energy: Long)
|
||||
{
|
||||
internalEnergy = Math.max(internalEnergy + energy, 0)
|
||||
}
|
||||
|
||||
/** Called when the block is right clicked by the player */
|
||||
override protected def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
val tile: TileReactorCell = getMultiBlock.get()
|
||||
if (player.inventory.getCurrentItem != null)
|
||||
{
|
||||
if (tile.getStackInSlot(0) == null)
|
||||
{
|
||||
if (player.inventory.getCurrentItem.getItem.isInstanceOf[IReactorComponent])
|
||||
{
|
||||
val itemStack: ItemStack = player.inventory.getCurrentItem.copy
|
||||
itemStack.stackSize = 1
|
||||
tile.setInventorySlotContents(0, itemStack)
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (player.isSneaking && tile.getStackInSlot(0) != null)
|
||||
{
|
||||
InventoryUtility.dropItemStack(world, new Vector3(player), tile.getStackInSlot(0), 0)
|
||||
tile.setInventorySlotContents(0, null)
|
||||
return true
|
||||
}
|
||||
else
|
||||
{
|
||||
player.openGui(QuantumContent, 0, world, tile.xCoord, tile.yCoord, tile.zCoord)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override protected def markUpdate
|
||||
{
|
||||
super.markUpdate
|
||||
shouldUpdate = true
|
||||
}
|
||||
}
|
|
@ -1,193 +0,0 @@
|
|||
package edx.quantum.machine.reactor
|
||||
|
||||
import java.util.{ArrayList, HashSet, List, Set}
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraft.entity.EntityLivingBase
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.{IIcon, MathHelper}
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids._
|
||||
import resonant.lib.prefab.tile.spatial.{SpatialBlock, SpatialTile}
|
||||
import resonant.lib.prefab.tile.traits.TRotatable
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
import resonant.lib.utility.path.{IPathCallBack, Pathfinder}
|
||||
|
||||
/**
|
||||
* Reactor Drain
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
class TileReactorDrain extends SpatialTile(Material.iron) with IFluidHandler with TRotatable
|
||||
{
|
||||
private final val tanks: Set[IFluidTank] = new HashSet[IFluidTank]
|
||||
private var lastFindTime: Long = -1
|
||||
|
||||
override def canUpdate: Boolean =
|
||||
{
|
||||
return false
|
||||
}
|
||||
|
||||
def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int =
|
||||
{
|
||||
return 0
|
||||
}
|
||||
|
||||
def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
if (this.getOptimalTank != null)
|
||||
{
|
||||
return this.getOptimalTank.drain(maxDrain, doDrain)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
return null
|
||||
}
|
||||
|
||||
def canFill(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return false
|
||||
}
|
||||
|
||||
def canDrain(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return true
|
||||
}
|
||||
|
||||
def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] =
|
||||
{
|
||||
val tankInfoList: List[FluidTankInfo] = new ArrayList[FluidTankInfo]
|
||||
this.getOptimalTank
|
||||
import scala.collection.JavaConversions._
|
||||
for (tank <- this.tanks)
|
||||
{
|
||||
tankInfoList.add(tank.getInfo)
|
||||
}
|
||||
return tankInfoList.toArray(new Array[FluidTankInfo](0))
|
||||
}
|
||||
|
||||
def getOptimalTank: IFluidTank =
|
||||
{
|
||||
if (this.lastFindTime == -1 || this.worldObj.getWorldTime - this.lastFindTime > 20)
|
||||
{
|
||||
this.find
|
||||
}
|
||||
if (this.tanks.size > 0)
|
||||
{
|
||||
var optimalTank: IFluidTank = null
|
||||
import scala.collection.JavaConversions._
|
||||
for (tank <- this.tanks)
|
||||
{
|
||||
if (tank != null)
|
||||
{
|
||||
if (optimalTank == null || (optimalTank != null && getFluidSafe(tank.getFluid) > getFluidSafe(optimalTank.getFluid)))
|
||||
{
|
||||
optimalTank = tank
|
||||
}
|
||||
}
|
||||
}
|
||||
return optimalTank
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
def find
|
||||
{
|
||||
this.tanks.clear
|
||||
val world: World = this.worldObj
|
||||
val position: Vector3 = toVector3
|
||||
val finder: Pathfinder = new Pathfinder(new IPathCallBack
|
||||
{
|
||||
def getConnectedNodes(finder: Pathfinder, currentNode: Vector3): Set[Vector3] =
|
||||
{
|
||||
val neighbors: Set[Vector3] = new HashSet[Vector3]
|
||||
|
||||
for (i <- 0 to 6)
|
||||
{
|
||||
val direction: ForgeDirection = ForgeDirection.getOrientation(i)
|
||||
val position: Vector3 = currentNode.clone.add(direction)
|
||||
val block: Block = position.getBlock(world)
|
||||
if (block == null || block.isInstanceOf[IFluidBlock] || position.getTileEntity(world).isInstanceOf[TileReactorCell])
|
||||
{
|
||||
neighbors.add(position)
|
||||
}
|
||||
}
|
||||
return neighbors
|
||||
}
|
||||
|
||||
def onSearch(finder: Pathfinder, start: Vector3, node: Vector3): Boolean =
|
||||
{
|
||||
if (node.getTileEntity(world).isInstanceOf[TileReactorCell])
|
||||
{
|
||||
finder.results.add(node)
|
||||
}
|
||||
if (node.distance(position) > 6)
|
||||
{
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}).init(toVector3.add(ForgeDirection.getOrientation(this.getBlockMetadata).getOpposite))
|
||||
import scala.collection.JavaConversions._
|
||||
for (node <- finder.results)
|
||||
{
|
||||
val tileEntity: TileEntity = node.getTileEntity(this.worldObj)
|
||||
if (tileEntity.isInstanceOf[TileReactorCell])
|
||||
{
|
||||
this.tanks.add((tileEntity.asInstanceOf[TileReactorCell]).tank)
|
||||
}
|
||||
}
|
||||
this.lastFindTime = this.worldObj.getWorldTime
|
||||
}
|
||||
|
||||
def getFluidSafe(stack: FluidStack): Int =
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
return stack.amount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def registerIcons(iconRegister: IIconRegister)
|
||||
{
|
||||
super.registerIcons(iconRegister)
|
||||
SpatialBlock.icon.put("ReactorDrain_front", iconRegister.registerIcon("ReactorDrain_front"))
|
||||
}
|
||||
|
||||
override def getIcon(side: Int, metadata: Int): IIcon =
|
||||
{
|
||||
if (side == metadata)
|
||||
{
|
||||
return SpatialBlock.icon.get("ReactorDrain_front")
|
||||
}
|
||||
return super.getIcon(side, metadata)
|
||||
}
|
||||
|
||||
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
|
||||
{
|
||||
if (MathHelper.abs(entityLiving.posX.asInstanceOf[Float] - xi) < 2.0F && MathHelper.abs(entityLiving.posZ.asInstanceOf[Float] - zi) < 2.0F)
|
||||
{
|
||||
val d0: Double = entityLiving.posY + 1.82D - entityLiving.yOffset
|
||||
if (d0 - y > 2.0D)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(xi, yi, zi, 1, 3)
|
||||
return
|
||||
}
|
||||
if (y - d0 > 0.0D)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(xi, yi, zi, 0, 3)
|
||||
return
|
||||
}
|
||||
}
|
||||
super.onPlaced(entityLiving, itemStack)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package edx.quantum.machine.reactor
|
||||
package edx.quantum.reactor
|
||||
|
||||
import edx.quantum.items.{ItemBreederFuel, ItemFissileFuel}
|
||||
import edx.quantum.items.{ItemBreederFuel, ItemFuelRod}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.inventory.Slot
|
||||
import net.minecraft.item.ItemStack
|
||||
|
@ -10,8 +10,8 @@ import resonant.lib.prefab.gui.slot.SlotSpecific
|
|||
class ContainerReactorCell(player: EntityPlayer, tileEntity: TileReactorCell) extends ContainerBase(tileEntity)
|
||||
{
|
||||
//Constructor
|
||||
this.addSlotToContainer(new SlotSpecific(tileEntity, 0, 79, 17, classOf[ItemFissileFuel], classOf[ItemBreederFuel]))
|
||||
this.addPlayerInventory(player)
|
||||
addSlotToContainer(new SlotSpecific(tileEntity, 0, 79, 17, classOf[ItemFuelRod], classOf[ItemBreederFuel]))
|
||||
addPlayerInventory(player)
|
||||
|
||||
/**
|
||||
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
|
|
@ -1,4 +1,4 @@
|
|||
package edx.quantum.machine.reactor
|
||||
package edx.quantum.reactor
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
@ -16,7 +16,7 @@ class GuiReactorCell(inventory: InventoryPlayer, tileEntity: TileReactorCell) ex
|
|||
if (tileEntity.getStackInSlot(0) != null)
|
||||
{
|
||||
fontRendererObj.drawString(LanguageUtility.getLocal("tooltip.temperature"), 9, 45, 4210752)
|
||||
fontRendererObj.drawString(String.valueOf(tileEntity.getTemperature.asInstanceOf[Int]) + "/" + String.valueOf(TileReactorCell.MELTING_POINT) + " K", 9, 58, 4210752)
|
||||
// fontRendererObj.drawString(String.valueOf(tileEntity.getTemperature.asInstanceOf[Int]) + "/" + String.valueOf(TileReactorCell.meltingPoint) + " K", 9, 58, 4210752)
|
||||
val secondsLeft: Int = (tileEntity.getStackInSlot(0).getMaxDamage - tileEntity.getStackInSlot(0).getItemDamage)
|
||||
fontRendererObj.drawString(LanguageUtility.getLocal("tooltip.remainingTime"), 100, 45, 4210752)
|
||||
fontRendererObj.drawString(secondsLeft + " seconds", 100, 58, 4210752)
|
||||
|
@ -31,13 +31,13 @@ class GuiReactorCell(inventory: InventoryPlayer, tileEntity: TileReactorCell) ex
|
|||
{
|
||||
super.drawGuiContainerBackgroundLayer(par1, x, y)
|
||||
drawSlot(78, 16)
|
||||
drawMeter(80, 36, tileEntity.tank.getFluidAmount.asInstanceOf[Float] / tileEntity.tank.getCapacity.asInstanceOf[Float], tileEntity.tank.getFluid)
|
||||
// drawMeter(80, 36, tileEntity.tank.getFluidAmount.asInstanceOf[Float] / tileEntity.tank.getCapacity.asInstanceOf[Float], tileEntity.tank.getFluid)
|
||||
if (tileEntity.getStackInSlot(0) != null)
|
||||
{
|
||||
GL11.glPushMatrix
|
||||
GL11.glTranslatef(32 * 2, 0, 0)
|
||||
GL11.glScalef(0.5f, 1, 1)
|
||||
drawForce(20, 70, (tileEntity.getTemperature) / (TileReactorCell.MELTING_POINT))
|
||||
// drawForce(20, 70, (tileEntity.getTemperature) / (TileReactorCell.meltingPoint))
|
||||
GL11.glPopMatrix
|
||||
GL11.glPushMatrix
|
||||
GL11.glTranslatef(68 * 2, 0, 0)
|
|
@ -1,4 +1,4 @@
|
|||
package edx.quantum.machine.reactor
|
||||
package edx.quantum.reactor
|
||||
|
||||
import net.minecraft.block.material.Material
|
||||
import resonant.lib.prefab.tile.spatial.SpatialBlock
|
||||
|
@ -9,6 +9,6 @@ import resonant.lib.transform.region.Cuboid
|
|||
*/
|
||||
class TileControlRod extends SpatialBlock(Material.iron)
|
||||
{
|
||||
bounds(new Cuboid(0.3f, 0f, 0.3f, 0.7f, 1f, 0.7f))
|
||||
isOpaqueCube(false)
|
||||
bounds = new Cuboid(0.3f, 0f, 0.3f, 0.7f, 1f, 0.7f)
|
||||
isOpaqueCube = true
|
||||
}
|
455
src/main/scala/edx/quantum/reactor/TileReactorCell.scala
Normal file
455
src/main/scala/edx/quantum/reactor/TileReactorCell.scala
Normal file
|
@ -0,0 +1,455 @@
|
|||
package edx.quantum.reactor
|
||||
|
||||
import java.util
|
||||
import java.util.List
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import edx.core.{Electrodynamics, Reference}
|
||||
import edx.quantum.QuantumContent
|
||||
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, ResourceLocation}
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import org.lwjgl.opengl.GL11
|
||||
import resonant.api.tile.{IReactor, IReactorComponent}
|
||||
import resonant.lib.grid.thermal.{ThermalGrid, ThermalPhysics}
|
||||
import resonant.lib.network.handle.{TPacketReceiver, TPacketSender}
|
||||
import resonant.lib.prefab.poison.PoisonRadiation
|
||||
import resonant.lib.prefab.tile.mixed.TileInventory
|
||||
import resonant.lib.prefab.tile.multiblock.reference.{IMultiBlockStructure, MultiBlockHandler}
|
||||
import resonant.lib.render.RenderUtility
|
||||
import resonant.lib.render.model.ModelCube
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
import resonant.lib.utility.inventory.InventoryUtility
|
||||
|
||||
import scala.collection.convert.wrapAll._
|
||||
|
||||
/** The primary reactor component cell used to build reactors with.
|
||||
*
|
||||
* @author Calclavia */
|
||||
object TileReactorCell
|
||||
{
|
||||
final val radius = 2
|
||||
final val meltingPoint = 3000
|
||||
final val specificHeatCapacity = 1000
|
||||
final val mass = ThermalPhysics.getMass(1000, 7)
|
||||
|
||||
final val modelTop = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellTop.tcn"))
|
||||
final val modelMiddle = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellMiddle.tcn"))
|
||||
final val modelBottom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellBottom.tcn"))
|
||||
final val textureTop = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellTop.png")
|
||||
final val textureMiddle = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellMiddle.png")
|
||||
final val textureBottom = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellBottom.png")
|
||||
final val textureFuel = new ResourceLocation(Reference.domain, Reference.modelPath + "fissileMaterial.png")
|
||||
}
|
||||
|
||||
class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStructure[TileReactorCell] with IReactor with TPacketSender with TPacketReceiver
|
||||
{
|
||||
/** Multiblock Methods. */
|
||||
private val multiBlock = new MultiBlockHandler[TileReactorCell](this)
|
||||
private var internalEnergy = 0d
|
||||
|
||||
textureName = "machine"
|
||||
isOpaqueCube = false
|
||||
normalRender = false
|
||||
|
||||
override def getSizeInventory = 1
|
||||
|
||||
override def onWorldJoin()
|
||||
{
|
||||
updatePositionStatus()
|
||||
}
|
||||
|
||||
override def onNeighborChanged(block: Block)
|
||||
{
|
||||
updatePositionStatus()
|
||||
}
|
||||
|
||||
/** Multiblock Methods */
|
||||
def updatePositionStatus()
|
||||
{
|
||||
val mainTile = getLowest
|
||||
mainTile.getMultiBlock.deconstruct()
|
||||
mainTile.getMultiBlock.construct()
|
||||
|
||||
val top = (toVector3 + new Vector3(0, 1, 0)).getTileEntity(worldObj).isInstanceOf[TileReactorCell]
|
||||
val bottom = (toVector3 + new Vector3(0, -1, 0)).getTileEntity(worldObj).isInstanceOf[TileReactorCell]
|
||||
|
||||
if (top && bottom)
|
||||
{
|
||||
setMeta(1)
|
||||
}
|
||||
else if (top)
|
||||
{
|
||||
setMeta(0)
|
||||
}
|
||||
else
|
||||
{
|
||||
setMeta(2)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gets the lowest reactor cell in this "tower"
|
||||
*/
|
||||
def getLowest: TileReactorCell =
|
||||
{
|
||||
var lowest: TileReactorCell = this
|
||||
val checkPosition: Vector3 = toVector3
|
||||
while (true)
|
||||
{
|
||||
val t: TileEntity = checkPosition.getTileEntity(this.worldObj)
|
||||
if (t.isInstanceOf[TileReactorCell])
|
||||
{
|
||||
lowest = t.asInstanceOf[TileReactorCell]
|
||||
}
|
||||
else
|
||||
{
|
||||
return lowest
|
||||
}
|
||||
checkPosition.y -= 1
|
||||
}
|
||||
return lowest
|
||||
}
|
||||
|
||||
override def update()
|
||||
{
|
||||
super.update()
|
||||
|
||||
/**
|
||||
* Move the fuel rod down into the main reactor.
|
||||
*/
|
||||
if (!getMultiBlock.isPrimary)
|
||||
{
|
||||
if (getStackInSlot(0) != null)
|
||||
{
|
||||
if (getMultiBlock.get.getStackInSlot(0) == null)
|
||||
{
|
||||
getMultiBlock.get.setInventorySlotContents(0, getStackInSlot(0))
|
||||
setInventorySlotContents(0, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!getWorld.isRemote)
|
||||
{
|
||||
/*
|
||||
if (getMultiBlock().isPrimary() && tank.getFluid != null && tank.getFluid.fluidID == QuantumContent.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)
|
||||
val spawnPos: Vector3 = toVector3 + spawnDir + spawnDir
|
||||
spawnPos.add(0, Math.max(worldObj.rand.nextInt(getHeight) - 1, 0), 0)
|
||||
if (worldObj.isAirBlock(spawnPos.xi, spawnPos.yi, spawnPos.zi))
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PlasmaEvent.SpawnPlasmaEvent(worldObj, spawnPos.xi, spawnPos.yi, spawnPos.zi, TilePlasma.plasmaMaxTemperature))
|
||||
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
|
||||
/**
|
||||
* Fission reaction
|
||||
*/
|
||||
val fuelRod = getMultiBlock.get.getStackInSlot(0)
|
||||
|
||||
if (fuelRod != null)
|
||||
{
|
||||
if (fuelRod.getItem.isInstanceOf[IReactorComponent])
|
||||
{
|
||||
fuelRod.getItem.asInstanceOf[IReactorComponent].onReact(fuelRod, this)
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (fuelRod.getItemDamage >= fuelRod.getMaxDamage)
|
||||
{
|
||||
getMultiBlock.get.setInventorySlotContents(0, null)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Radiation
|
||||
*/
|
||||
//TODO: Raycast radiation code
|
||||
if (ticks % 20 == 0)
|
||||
{
|
||||
if (worldObj.rand.nextFloat > 0.65)
|
||||
{
|
||||
val entities = 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(toVector3, entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Heats up the surroundings. Control rods absorbs neutrons, reducing the heat produced.
|
||||
*/
|
||||
val controlRodCount = ForgeDirection.VALID_DIRECTIONS.map(toVectorWorld + _).count(_.getBlock == QuantumContent.blockControlRod)
|
||||
ThermalGrid.addHeat(toVectorWorld, internalEnergy / ((controlRodCount + 1) * 0.3))
|
||||
|
||||
val temperature = ThermalGrid.getTemperature(toVectorWorld)
|
||||
|
||||
/**
|
||||
* Play sound effects
|
||||
*/
|
||||
if (temperature >= 373)
|
||||
{
|
||||
if (world.rand.nextInt(80) == 0)
|
||||
{
|
||||
world.playSoundEffect(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F, "Fluid.lava", 0.5F, 2.1F + (worldObj.rand.nextFloat - worldObj.rand.nextFloat) * 0.85F)
|
||||
}
|
||||
if (world.rand.nextInt(40) == 0)
|
||||
{
|
||||
world.playSoundEffect(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F, "Fluid.lavapop", 0.5F, 2.6F + (worldObj.rand.nextFloat - worldObj.rand.nextFloat) * 0.8F)
|
||||
}
|
||||
|
||||
if (ticks % (20 * 5) == 0)
|
||||
{
|
||||
world.playSoundEffect(this.xCoord + 0.5F, this.yCoord + 0.5F, this.zCoord + 0.5F, Reference.prefix + "reactorcell", temperature / TileReactorCell.meltingPoint, 1.0F)
|
||||
}
|
||||
}
|
||||
|
||||
if (temperature > TileReactorCell.meltingPoint)
|
||||
{
|
||||
meltDown()
|
||||
}
|
||||
internalEnergy = 0
|
||||
}
|
||||
else
|
||||
{
|
||||
val temperature = ThermalGrid.getTemperature(toVectorWorld)
|
||||
|
||||
if (world.rand.nextInt(5) == 0 && temperature >= 373)
|
||||
{
|
||||
world.spawnParticle("cloud", this.xCoord + worldObj.rand.nextInt(2), this.yCoord + 1.0F, this.zCoord + worldObj.rand.nextInt(2), 0, 0.1D, 0)
|
||||
world.spawnParticle("bubble", this.xCoord + worldObj.rand.nextInt(5), this.yCoord, this.zCoord + worldObj.rand.nextInt(5), 0, 0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def getMultiBlock: MultiBlockHandler[TileReactorCell] = multiBlock
|
||||
|
||||
override def getWorld: World =
|
||||
{
|
||||
return worldObj
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
def onMultiBlockChanged()
|
||||
{
|
||||
}
|
||||
|
||||
override def getMultiBlockVectors: java.lang.Iterable[Vector3] =
|
||||
{
|
||||
val vectors: List[Vector3] = new util.ArrayList[Vector3]
|
||||
val checkPosition: Vector3 = toVector3
|
||||
while (true)
|
||||
{
|
||||
val t: TileEntity = checkPosition.getTileEntity(this.worldObj)
|
||||
if (t.isInstanceOf[TileReactorCell])
|
||||
{
|
||||
vectors.add(checkPosition - getPosition)
|
||||
}
|
||||
else
|
||||
{
|
||||
return vectors
|
||||
}
|
||||
checkPosition.y += 1
|
||||
}
|
||||
return vectors
|
||||
}
|
||||
|
||||
def getPosition: Vector3 =
|
||||
{
|
||||
return toVector3
|
||||
}
|
||||
|
||||
override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
getMultiBlock.load(nbt)
|
||||
}
|
||||
|
||||
override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
getMultiBlock.save(nbt)
|
||||
}
|
||||
|
||||
override def getInventoryStackLimit: Int = 1
|
||||
|
||||
/** Returns true if automation can insert the given item in the given slot from the given side.
|
||||
* Args: Slot, item, side */
|
||||
override def canInsertItem(slot: Int, items: ItemStack, side: Int): Boolean =
|
||||
{
|
||||
return this.isItemValidForSlot(slot, items)
|
||||
}
|
||||
|
||||
override def isItemValidForSlot(slotID: Int, itemStack: ItemStack): Boolean =
|
||||
{
|
||||
if (getMultiBlock.isPrimary && getMultiBlock.get.getStackInSlot(0) == null)
|
||||
{
|
||||
return itemStack.getItem.isInstanceOf[IReactorComponent]
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override def isUseableByPlayer(par1EntityPlayer: EntityPlayer): Boolean =
|
||||
{
|
||||
return if (worldObj.getTileEntity(xCoord, yCoord, zCoord) ne this) false else par1EntityPlayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D
|
||||
}
|
||||
|
||||
def getInvName: String =
|
||||
{
|
||||
return getBlockType.getLocalizedName
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def getRenderBoundingBox: AxisAlignedBB =
|
||||
{
|
||||
if (getMultiBlock.isPrimary && getMultiBlock.isConstructed)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(x - 5, y - 5, z - 5, x + 5, y + 5, z + 5);
|
||||
}
|
||||
return super.getRenderBoundingBox
|
||||
}
|
||||
|
||||
override def heat(energy: Double)
|
||||
{
|
||||
internalEnergy = Math.max(internalEnergy + energy, 0)
|
||||
}
|
||||
|
||||
override def renderDynamic(pos: Vector3, frame: Float, pass: Int): Unit =
|
||||
{
|
||||
GL11.glPushMatrix()
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
||||
val meta = if (frame != 0) metadata else 2
|
||||
|
||||
val hasBelow = if (frame != 0) world.getTileEntity(xi, yi - 1, zi).isInstanceOf[TileReactorCell] else false
|
||||
|
||||
if (meta == 0)
|
||||
{
|
||||
RenderUtility.bind(TileReactorCell.textureBottom)
|
||||
TileReactorCell.modelBottom.renderAll
|
||||
}
|
||||
else if (meta == 1)
|
||||
{
|
||||
RenderUtility.bind(TileReactorCell.textureMiddle)
|
||||
GL11.glTranslatef(0, 0.075f, 0)
|
||||
GL11.glScalef(1f, 1.15f, 1f)
|
||||
TileReactorCell.modelMiddle.renderAll
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderUtility.bind(TileReactorCell.textureTop)
|
||||
|
||||
if (hasBelow)
|
||||
{
|
||||
GL11.glScalef(1f, 1.32f, 1f)
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef(0, 0.1f, 0)
|
||||
GL11.glScalef(1f, 1.2f, 1f)
|
||||
}
|
||||
|
||||
if (hasBelow)
|
||||
{
|
||||
TileReactorCell.modelTop.renderAllExcept("BottomPad", "BaseDepth", "BaseWidth", "Base")
|
||||
}
|
||||
else
|
||||
{
|
||||
TileReactorCell.modelTop.renderAll()
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix()
|
||||
|
||||
if (getStackInSlot(0) != null)
|
||||
{
|
||||
val height = getHeight * ((getStackInSlot(0).getMaxDamage - getStackInSlot(0).getItemDamage).toFloat / getStackInSlot(0).getMaxDamage.toFloat)
|
||||
GL11.glPushMatrix()
|
||||
GL11.glTranslated(x + 0.5, y + 0.5 * height, z + 0.5)
|
||||
GL11.glScalef(0.4f, 0.9f * height, 0.4f)
|
||||
RenderUtility.bind(TileReactorCell.textureFuel)
|
||||
RenderUtility.disableLighting()
|
||||
ModelCube.INSTNACE.render()
|
||||
RenderUtility.enableLighting()
|
||||
GL11.glPopMatrix()
|
||||
}
|
||||
}
|
||||
|
||||
def getHeight: Int =
|
||||
{
|
||||
var height: Int = 0
|
||||
val checkPosition: Vector3 = toVector3
|
||||
var tile: TileEntity = this
|
||||
while (tile.isInstanceOf[TileReactorCell])
|
||||
{
|
||||
checkPosition.y += 1
|
||||
height += 1
|
||||
tile = checkPosition.getTileEntity(worldObj)
|
||||
}
|
||||
return height
|
||||
}
|
||||
|
||||
/** Called when the block is right clicked by the player */
|
||||
override protected def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
val tile: TileReactorCell = getMultiBlock.get()
|
||||
if (player.inventory.getCurrentItem != null)
|
||||
{
|
||||
if (tile.getStackInSlot(0) == null)
|
||||
{
|
||||
if (player.inventory.getCurrentItem.getItem.isInstanceOf[IReactorComponent])
|
||||
{
|
||||
val itemStack: ItemStack = player.inventory.getCurrentItem.copy
|
||||
itemStack.stackSize = 1
|
||||
tile.setInventorySlotContents(0, itemStack)
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (player.isSneaking && tile.getStackInSlot(0) != null)
|
||||
{
|
||||
InventoryUtility.dropItemStack(world, new Vector3(player), tile.getStackInSlot(0), 0)
|
||||
tile.setInventorySlotContents(0, null)
|
||||
return true
|
||||
}
|
||||
else
|
||||
{
|
||||
player.openGui(Electrodynamics, 0, world, tile.xCoord, tile.yCoord, tile.zCoord)
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue