Merge branch 'development' of https://bitbucket.org/calclavia/resonant-induction into development

This commit is contained in:
Calclavia 2014-11-17 21:07:05 +08:00
commit 91322ed394
3 changed files with 251 additions and 239 deletions

View file

@ -88,12 +88,14 @@ class TileEngineeringTable extends TileInventory(Material.wood) with IPacketRece
isOpaqueCube(false)
itemBlock(classOf[ItemBlockSaved])
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): IIcon =
@SideOnly(Side.CLIENT)
override def getIcon(side: Int, meta: Int): IIcon =
{
return if (side == 1) TileEngineeringTable.iconTop else (if (side == meta) TileEngineeringTable.iconFront else TileEngineeringTable.iconSide)
}
@SideOnly(Side.CLIENT) override def registerIcons(iconRegister: IIconRegister)
@SideOnly(Side.CLIENT)
override def registerIcons(iconRegister: IIconRegister)
{
TileEngineeringTable.iconTop = iconRegister.registerIcon(getTextureName + "_top")
TileEngineeringTable.iconFront = iconRegister.registerIcon(getTextureName + "_front")

View file

@ -4,7 +4,6 @@ import java.util.List
import cpw.mods.fml.relauncher.{Side, SideOnly}
import io.netty.buffer.ByteBuf
import net.minecraft.block.Block
import net.minecraft.block.material.Material
import net.minecraft.client.renderer.texture.IIconRegister
import net.minecraft.creativetab.CreativeTabs
@ -19,13 +18,12 @@ import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids._
import resonant.api.electric.EnergyStorage
import resonant.content.spatial.block.SpatialBlock
import resonant.content.spatial.block.{SpatialBlock, SpatialTile}
import resonant.engine.grid.thermal.{BoilEvent, ThermalPhysics}
import resonant.lib.content.prefab.TEnergyStorage
import resonant.lib.content.prefab.java.TileElectricInventory
import resonant.lib.network.Synced
import resonant.lib.network.discriminator.{PacketAnnotation, PacketType}
import resonant.lib.network.handle.IPacketReceiver
import resonant.lib.content.prefab.{TElectric, TInventory}
import resonant.lib.network.ByteBufWrapper._
import resonant.lib.network.discriminator.PacketType
import resonant.lib.network.handle.{TPacketReceiver, TPacketSender}
import resonant.lib.transform.vector.Vector3
import resonant.lib.utility.FluidUtility
import resonant.lib.wrapper.WrapList._
@ -36,7 +34,7 @@ import resonantinduction.core.Reference
*
* @author Calclavia
*/
class TileFirebox extends TileElectricInventory(Material.rock) with IPacketReceiver with IFluidHandler with TEnergyStorage
class TileFirebox extends SpatialTile(Material.rock) with IFluidHandler with TInventory with TElectric with TPacketSender with TPacketReceiver
{
/**
* 1KG of coal ~= 24MJ
@ -45,30 +43,32 @@ class TileFirebox extends TileElectricInventory(Material.rock) with IPacketRecei
* The power of the firebox in terms of thermal energy. The thermal energy can be transfered
* into fluids to increase their internal energy.
*/
private final val POWER: Long = 100000
private final val power: Long = 100000
protected var tank: FluidTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME)
@Synced private var burnTime: Int = 0
private var burnTime: Int = 0
private var heatEnergy: Long = 0
private var boiledVolume: Int = 0
//TODO: Dummy
energy = new EnergyStorage(0)
energy.setCapacity(POWER)
energy.setMaxTransfer((POWER * 2) / 20)
val energy = new EnergyStorage(0)
energy.setCapacity(power)
energy.setMaxTransfer((power * 2) / 20)
setIO(ForgeDirection.UP, 0)
override def update
override def update()
{
super.update()
if (!worldObj.isRemote)
{
val drainFluid: FluidStack = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false)
val drainFluid = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false)
if (drainFluid != null && drainFluid.amount == FluidContainerRegistry.BUCKET_VOLUME && drainFluid.fluidID == FluidRegistry.LAVA.getID)
{
if (burnTime == 0)
{
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true)
burnTime += 20000
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
sendPacket(0)
}
}
else if (isElectrical && energy.checkExtract)
@ -76,7 +76,7 @@ class TileFirebox extends TileElectricInventory(Material.rock) with IPacketRecei
energy.extractEnergy
if (burnTime == 0)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
sendPacket(0)
}
burnTime += 2
}
@ -86,17 +86,19 @@ class TileFirebox extends TileElectricInventory(Material.rock) with IPacketRecei
{
burnTime += TileEntityFurnace.getItemBurnTime(this.getStackInSlot(0))
decrStackSize(0, 1)
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
sendPacket(0)
}
}
val block: Block = worldObj.getBlock(xCoord, yCoord + 1, zCoord)
val block = worldObj.getBlock(xCoord, yCoord + 1, zCoord)
if (burnTime > 0)
{
if (block == null)
{
worldObj.setBlock(xCoord, yCoord + 1, zCoord, Blocks.fire)
}
heatEnergy += POWER / 20
heatEnergy += power / 20
var usedHeat: Boolean = false
if (block eq Blocks.water)
{
@ -121,21 +123,24 @@ class TileFirebox extends TileElectricInventory(Material.rock) with IPacketRecei
{
heatEnergy = 0
}
if (({
burnTime -= 1;
burnTime
}) == 0)
burnTime -= 1
if (burnTime == 0)
{
if (block eq Blocks.fire)
if (block == Blocks.fire)
{
worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord)
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
sendPacket(0)
}
}
}
}
override def getSizeInventory = 1
/**
* Approximately 327600 + 2257000 = 2584600.
*
@ -174,14 +179,20 @@ class TileFirebox extends TileElectricInventory(Material.rock) with IPacketRecei
return i == 0 && canBurn(itemStack)
}
override def getDescPacket: PacketAnnotation =
/**
* Override this method
* Be sure to super this method or manually write the ID into the packet when sending
*/
override def write(buf: ByteBuf, id: Int)
{
return new PacketAnnotation(this)
super.write(buf, id)
buf <<< burnTime
}
def read(data: ByteBuf, player: EntityPlayer, `type`: PacketType)
override def read(buf: ByteBuf, id: Int, packetType: PacketType)
{
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord)
super.read(buf, id, packetType)
markRender()
}
override def readFromNBT(nbt: NBTTagCompound)
@ -232,7 +243,8 @@ class TileFirebox extends TileElectricInventory(Material.rock) with IPacketRecei
return Array[FluidTankInfo](tank.getInfo)
}
@SideOnly(Side.CLIENT) override def registerIcons(iconReg: IIconRegister)
@SideOnly(Side.CLIENT)
override def registerIcons(iconReg: IIconRegister)
{
super.registerIcons(iconReg)
SpatialBlock.icon.put("firebox_side_on", iconReg.registerIcon(Reference.prefix + "firebox_side_on"))
@ -245,7 +257,8 @@ class TileFirebox extends TileElectricInventory(Material.rock) with IPacketRecei
SpatialBlock.icon.put("firebox_electric_top_off", iconReg.registerIcon(Reference.prefix + "firebox_electric_top_off"))
}
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): IIcon =
@SideOnly(Side.CLIENT)
override def getIcon(side: Int, meta: Int): IIcon =
{
if (side == 0)
{

View file

@ -11,15 +11,14 @@ import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.item.crafting.FurnaceRecipes
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.IIcon
import resonant.content.spatial.block.SpatialBlock
import resonant.lib.content.prefab.java.TileInventory
import resonant.lib.network.discriminator.{PacketTile, PacketType}
import resonant.lib.network.handle.IPacketReceiver
import resonantinduction.core.Reference
import resonant.lib.transform.region.Cuboid
import resonant.lib.transform.vector.{Vector2, Vector3}
import resonantinduction.core.Reference
/**
* For smelting items.
@ -40,15 +39,16 @@ class TileHotPlate extends TileInventory(Material.iron) with IPacketReceiver
//Constructor
setSizeInventory(4)
bounds(new Cuboid(0, 0, 0, 1, 0.2f, 1))
normalRender(false)
forceStandardRender(true)
isOpaqueCube(false)
forceItemToRenderAsBlock = true
isOpaqueCube = false
override def update
override def update()
{
super.update()
if (canRun)
{
var didSmelt: Boolean = false
var didSmelt = false
for (i <- 0 to getSizeInventory)
{
@ -62,7 +62,7 @@ class TileHotPlate extends TileInventory(Material.iron) with IPacketReceiver
}
else if (smeltTime(i) > 0)
{
smeltTime(i) -= 1;
smeltTime(i) -= 1
if (smeltTime(i) == 0)
{
if (!worldObj.isRemote)
@ -84,9 +84,9 @@ class TileHotPlate extends TileInventory(Material.iron) with IPacketReceiver
}
}
override def onInventoryChanged
override def onInventoryChanged()
{
for (i <- 0 to getSizeInventory)
for (i <- 0 until getSizeInventory)
{
if (getStackInSlot(i) != null)
{
@ -112,7 +112,8 @@ class TileHotPlate extends TileInventory(Material.iron) with IPacketReceiver
def canRun: Boolean =
{
val tileEntity: TileEntity = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord)
val tileEntity = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord)
if (tileEntity.isInstanceOf[TileFirebox])
{
if ((tileEntity.asInstanceOf[TileFirebox]).isBurning)
@ -130,22 +131,16 @@ class TileHotPlate extends TileInventory(Material.iron) with IPacketReceiver
def isSmelting: Boolean =
{
{
var i: Int = 0
while (i < getSizeInventory)
{
for (i <- 0 until getSizeInventory)
{
if (getSmeltTime(i) > 0)
{
return true
}
}
({
i += 1;
i - 1
})
}
}
return false
}
@ -197,7 +192,7 @@ class TileHotPlate extends TileInventory(Material.iron) with IPacketReceiver
override def readFromNBT(nbt: NBTTagCompound)
{
super.readFromNBT(nbt)
for (i <- 0 to getSizeInventory)
for (i <- 0 until getSizeInventory)
{
smeltTime(i) = nbt.getInteger("smeltTime" + i)
}
@ -207,19 +202,21 @@ class TileHotPlate extends TileInventory(Material.iron) with IPacketReceiver
{
super.writeToNBT(nbt)
for (i <- 0 to getSizeInventory)
for (i <- 0 until getSizeInventory)
{
nbt.setInteger("smeltTime" + i, smeltTime(i))
}
}
@SideOnly(Side.CLIENT) override def registerIcons(iconReg: IIconRegister)
@SideOnly(Side.CLIENT)
override def registerIcons(iconReg: IIconRegister)
{
super.registerIcons(iconReg)
SpatialBlock.icon.put("electricHotPlate", iconReg.registerIcon(Reference.prefix + "electricHotPlate"))
}
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): IIcon =
@SideOnly(Side.CLIENT)
override def getIcon(side: Int, meta: Int): IIcon =
{
return if (meta == 1) SpatialBlock.icon.get("electricHotPlate") else SpatialBlock.icon.get(getTextureName)
}
@ -239,16 +236,16 @@ class TileHotPlate extends TileInventory(Material.iron) with IPacketReceiver
val hitVector: Vector2 = new Vector2(hit.x, hit.z)
val regionLength: Double = 1d / 2d
var j: Int = 0
for (j <- 0 to 2)
for (j <- 0 until 2)
{
for (k <- 0 to 2)
for (k <- 0 until 2)
{
val check: Vector2 = new Vector2(j, k).multiply(regionLength)
val check = new Vector2(j, k) * regionLength
if (check.distance(hitVector) < regionLength)
{
val slotID: Int = j * 2 + k
val slotID = j * 2 + k
interactCurrentItem(this, slotID, player)
onInventoryChanged
onInventoryChanged()
return true
}
}