Updated to new packet system
This commit is contained in:
parent
c98e3ffe72
commit
77ddba7c89
|
@ -14,8 +14,8 @@ import resonant.api.IFilterable
|
|||
import resonant.api.IRemovable.ISneakPickup
|
||||
import resonant.lib.content.prefab.java.TileInventory
|
||||
import resonant.lib.network.ByteBufWrapper._
|
||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.TPacketReceiver
|
||||
import resonant.lib.network.discriminator.PacketType
|
||||
import resonant.lib.network.handle.{TPacketReceiver, TPacketSender}
|
||||
import resonantinduction.archaic.ArchaicContent
|
||||
|
||||
/** Basic single stack inventory.
|
||||
|
@ -43,7 +43,7 @@ object TileCrate
|
|||
}
|
||||
}
|
||||
|
||||
class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with IFilterable with ISneakPickup
|
||||
class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with TPacketSender with IFilterable with ISneakPickup
|
||||
{
|
||||
|
||||
override protected lazy val inventory = new InventoryCrate(this)
|
||||
|
@ -57,9 +57,10 @@ class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with I
|
|||
private var updateTick: Long = 1
|
||||
private var doUpdate: Boolean = false
|
||||
|
||||
override def update
|
||||
override def update()
|
||||
{
|
||||
super.update
|
||||
super.update()
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
this.writeToNBT(new NBTTagCompound)
|
||||
|
@ -71,7 +72,7 @@ class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with I
|
|||
if (doUpdate)
|
||||
{
|
||||
doUpdate = false
|
||||
sendPacket(getDescPacket)
|
||||
sendDescPacket()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,34 +161,37 @@ class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with I
|
|||
{
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (data.readBoolean)
|
||||
{
|
||||
this.sampleStack = ItemStack.loadItemStackFromNBT(data.readTag())
|
||||
this.sampleStack.stackSize = data.readInt
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sampleStack = null
|
||||
}
|
||||
if (data.readBoolean)
|
||||
{
|
||||
this.sampleStack = ItemStack.loadItemStackFromNBT(data.readTag())
|
||||
this.sampleStack.stackSize = data.readInt
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sampleStack = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def getDescPacket: PacketTile =
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
var packet: PacketTile = new PacketTile(this)
|
||||
this.buildSampleStack
|
||||
val stack: ItemStack = this.getSampleStack
|
||||
this.buildSampleStack()
|
||||
|
||||
val stack = this.getSampleStack
|
||||
if (stack != null)
|
||||
{
|
||||
packet <<< true
|
||||
packet <<< stack
|
||||
packet <<< stack.stackSize
|
||||
buf <<< true
|
||||
buf <<< stack
|
||||
buf <<< stack.stackSize
|
||||
}
|
||||
else
|
||||
{
|
||||
packet <<< false
|
||||
buf <<< false
|
||||
}
|
||||
return packet
|
||||
}
|
||||
|
||||
/** NBT Data */
|
||||
|
@ -237,7 +241,7 @@ class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with I
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings(Array("unchecked")) def getRemovedItems(entity: EntityPlayer): List[ItemStack] =
|
||||
def getRemovedItems(entity: EntityPlayer): List[ItemStack] =
|
||||
{
|
||||
val list = new util.ArrayList[ItemStack]()
|
||||
val sampleStack: ItemStack = getSampleStack
|
||||
|
@ -255,14 +259,14 @@ class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with I
|
|||
{
|
||||
if (this.sampleStack == null)
|
||||
{
|
||||
this.buildSampleStack
|
||||
this.buildSampleStack()
|
||||
}
|
||||
return this.sampleStack
|
||||
}
|
||||
|
||||
/** Builds the sample stack using the inventory as a point of reference. Assumes all items match
|
||||
* each other, and only takes into account stack sizes */
|
||||
def buildSampleStack
|
||||
def buildSampleStack()
|
||||
{
|
||||
buildSampleStack(true)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package resonantinduction.archaic.fluid.grate
|
|||
import java.util.{Collections, Comparator, HashMap, PriorityQueue}
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import io.netty.buffer.ByteBuf
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
|
@ -13,6 +14,7 @@ import net.minecraftforge.common.util.ForgeDirection
|
|||
import net.minecraftforge.fluids.{Fluid, FluidContainerRegistry, FluidRegistry, FluidStack}
|
||||
import resonant.api.IRotatable
|
||||
import resonant.lib.config.Config
|
||||
import resonant.lib.network.discriminator.PacketType
|
||||
import resonant.lib.prefab.fluid.NodeFluid
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
import resonant.lib.utility.FluidUtility
|
||||
|
@ -97,8 +99,8 @@ class TileGrate extends TileFluidProvider(Material.rock) with IRotatable
|
|||
{
|
||||
val pressure = fluidNode.pressure(getDirection)
|
||||
val blockEffect = Math.abs(pressure * grateEffectMultiplier).toInt
|
||||
setCapacity(Math.max(blockEffect * FluidContainerRegistry.BUCKET_VOLUME * grateDrainSpeedMultiplier,
|
||||
FluidContainerRegistry.BUCKET_VOLUME).toInt)
|
||||
fluidNode.getPrimaryTank.setCapacity(Math.max(blockEffect * FluidContainerRegistry.BUCKET_VOLUME * grateDrainSpeedMultiplier, FluidContainerRegistry.BUCKET_VOLUME).toInt)
|
||||
|
||||
if (pressure > 0)
|
||||
{
|
||||
if (getFluidAmount >= FluidContainerRegistry.BUCKET_VOLUME)
|
||||
|
|
|
@ -45,6 +45,8 @@ class TileGutter extends TileFluidProvider(Material.rock)
|
|||
normalRender = false
|
||||
bounds = new Cuboid(0, 0, 0, 1, 0.99, 1)
|
||||
|
||||
nodes.add(fluidNode)
|
||||
|
||||
override def getCollisionBoxes: java.lang.Iterable[Cuboid] =
|
||||
{
|
||||
val list: List[Cuboid] = new ArrayList[Cuboid]
|
||||
|
|
|
@ -8,11 +8,11 @@ import net.minecraft.item.{ItemBlock, ItemStack}
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.fluids.{FluidStack, IFluidContainerItem}
|
||||
import net.minecraftforge.fluids.{FluidContainerRegistry, FluidStack, IFluidContainerItem}
|
||||
import resonant.lib.science.UnitDisplay
|
||||
import resonant.lib.science.UnitDisplay.Unit
|
||||
import resonant.lib.utility.LanguageUtility
|
||||
import resonant.lib.wrapper.WrapList._
|
||||
import UnitDisplay.Unit
|
||||
|
||||
/**
|
||||
* @author Darkguardsman
|
||||
|
@ -142,9 +142,9 @@ class ItemBlockTank(block: Block) extends ItemBlock(block: Block) with IFluidCon
|
|||
return filled
|
||||
}
|
||||
|
||||
def getCapacity(container: ItemStack): Int =
|
||||
override def getCapacity(container: ItemStack): Int =
|
||||
{
|
||||
return TileTank.volume
|
||||
return 16 * FluidContainerRegistry.BUCKET_VOLUME
|
||||
}
|
||||
|
||||
def drain(container: ItemStack, maxDrain: Int, doDrain: Boolean): FluidStack =
|
||||
|
|
|
@ -10,11 +10,10 @@ import net.minecraft.item.ItemStack
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.world.IBlockAccess
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.{FluidContainerRegistry, FluidStack, FluidTank, IFluidTank}
|
||||
import net.minecraftforge.fluids.{FluidStack, FluidTank, IFluidTank}
|
||||
import org.lwjgl.opengl.GL11
|
||||
import resonant.api.IRemovable.ISneakPickup
|
||||
import resonant.content.prefab.RenderConnectedTexture
|
||||
import resonant.lib.prefab.fluid.NodeFluid
|
||||
import resonant.lib.render.{FluidRenderUtility, RenderUtility}
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
import resonant.lib.utility.FluidUtility
|
||||
|
@ -27,22 +26,17 @@ import resonantinduction.core.prefab.node.{NodePressure, TileFluidProvider}
|
|||
*
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
object TileTank
|
||||
{
|
||||
val volume = 16
|
||||
}
|
||||
|
||||
class TileTank extends TileFluidProvider(Material.iron) with ISneakPickup with RenderConnectedTexture
|
||||
{
|
||||
isOpaqueCube = false
|
||||
normalRender = false
|
||||
forceStandardRender (true)
|
||||
itemBlock = classOf[ItemBlockTank]
|
||||
setCapacity(TileTank.volume * FluidContainerRegistry.BUCKET_VOLUME)
|
||||
|
||||
override protected val fluidNode = new NodePressure(this)
|
||||
override val edgeTexture = Reference.prefix + "tankEdge"
|
||||
|
||||
isOpaqueCube = false
|
||||
normalRender = false
|
||||
forceStandardRender(true)
|
||||
itemBlock = classOf[ItemBlockTank]
|
||||
nodes.add(fluidNode)
|
||||
|
||||
override def shouldSideBeRendered(access: IBlockAccess, x: Int, y: Int, z: Int, side: Int): Boolean = access.getBlock(x, y, z) != getBlockType
|
||||
|
||||
override def use(player: EntityPlayer, side: Int, vector3: Vector3): Boolean =
|
||||
|
@ -111,7 +105,7 @@ class TileTank extends TileFluidProvider(Material.iron) with ISneakPickup with R
|
|||
|
||||
if (itemStack.getTagCompound != null && itemStack.getTagCompound.hasKey("fluid"))
|
||||
{
|
||||
renderTank(0, 0, 0, FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound.getCompoundTag("fluid")), TileTank.volume * FluidContainerRegistry.BUCKET_VOLUME)
|
||||
renderTank(0, 0, 0, FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound.getCompoundTag("fluid")), fluidNode.getPrimaryTank.getCapacity)
|
||||
}
|
||||
|
||||
GL11.glPopMatrix()
|
||||
|
|
|
@ -14,7 +14,7 @@ import resonant.api.{IElectromagnet, IRotatable}
|
|||
import resonant.lib.content.prefab.TEnergyStorage
|
||||
import resonant.lib.content.prefab.java.TileElectricInventory
|
||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.TPacketIDReceiver
|
||||
import resonant.lib.network.handle.{TPacketIDReceiver, TPacketSender}
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
import resonant.lib.utility.BlockUtility
|
||||
import resonantinduction.atomic.AtomicContent
|
||||
|
@ -23,7 +23,7 @@ import resonantinduction.core.{Reference, ResonantInduction, Settings}
|
|||
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
class TileAccelerator extends TileElectricInventory(Material.iron) with IElectromagnet with IRotatable with TPacketIDReceiver with TEnergyStorage
|
||||
class TileAccelerator extends TileElectricInventory(Material.iron) with IElectromagnet with IRotatable with TPacketIDReceiver with TPacketSender with TEnergyStorage
|
||||
{
|
||||
final val DESC_PACKET_ID = 2;
|
||||
/**
|
||||
|
@ -136,7 +136,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
|
|||
{
|
||||
for (player <- getPlayersUsing)
|
||||
{
|
||||
sendPacketToPlayer(player, getDescPacket)
|
||||
sendPacket(getDescPacket, player)
|
||||
}
|
||||
}
|
||||
lastSpawnTick += 1
|
||||
|
@ -221,13 +221,14 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
|
|||
if (id == DESC_PACKET_ID)
|
||||
{
|
||||
this.velocity = buf.readFloat()
|
||||
this.totalEnergyConsumed = buf.readDouble();
|
||||
this.antimatter = buf.readInt();
|
||||
this.totalEnergyConsumed = buf.readDouble()
|
||||
this.antimatter = buf.readInt()
|
||||
this.energy.setEnergy(buf.readDouble())
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.read(buf, id, player, packet);
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override def getDescPacket: PacketTile =
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
package resonantinduction.core.prefab.node
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils
|
||||
import io.netty.buffer.ByteBuf
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids._
|
||||
import resonant.api.grid.{INode, INodeProvider}
|
||||
import resonant.content.prefab.java.TileAdvanced
|
||||
import resonant.lib.grid.node.TSpatialNodeProvider
|
||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.TPacketIDReceiver
|
||||
import resonant.lib.network.ByteBufWrapper._
|
||||
import resonant.lib.network.discriminator.PacketType
|
||||
import resonant.lib.network.handle.{TPacketReceiver, TPacketSender}
|
||||
import resonant.lib.prefab.fluid.NodeFluid
|
||||
|
||||
/**
|
||||
|
@ -20,16 +17,17 @@ import resonant.lib.prefab.fluid.NodeFluid
|
|||
*
|
||||
* @author DarkGuardsman, Calclavia
|
||||
*/
|
||||
abstract class TileFluidProvider(material: Material) extends TileAdvanced(material) with TSpatialNodeProvider with IFluidHandler with TPacketIDReceiver
|
||||
abstract class TileFluidProvider(material: Material) extends TileAdvanced(material) with TSpatialNodeProvider with IFluidHandler with TPacketReceiver with TPacketSender
|
||||
{
|
||||
val descriptionPacket = 0
|
||||
val renderPacket = 1
|
||||
|
||||
protected val fluidNode: NodeFluid
|
||||
protected var colorID: Int = 0
|
||||
protected var clientRenderMask = 0x00
|
||||
|
||||
nodes.add(fluidNode)
|
||||
override def start()
|
||||
{
|
||||
fluidNode.onConnectionChanged = () => sendPacket(1)
|
||||
super.start()
|
||||
}
|
||||
|
||||
def getFluid: FluidStack = getTank.getFluid
|
||||
|
||||
|
@ -49,46 +47,44 @@ abstract class TileFluidProvider(material: Material) extends TileAdvanced(materi
|
|||
nbt.setInteger("colorID", colorID)
|
||||
}
|
||||
|
||||
def sendRenderUpdate
|
||||
override def write(buf: ByteBuf, id: Int)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
super.write(buf, id)
|
||||
|
||||
id match
|
||||
{
|
||||
val packet: PacketTile = new PacketTile(this);
|
||||
packet <<< renderPacket
|
||||
packet <<< colorID
|
||||
packet <<< fluidNode.connectedBitmask
|
||||
sendPacket(packet)
|
||||
case 0 =>
|
||||
{
|
||||
buf <<< colorID
|
||||
buf <<< fluidNode.connectedBitmask
|
||||
buf <<< fluidNode.getPrimaryTank
|
||||
}
|
||||
case 1 =>
|
||||
{
|
||||
buf <<< colorID
|
||||
buf <<< fluidNode.connectedBitmask
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def getDescPacket(): PacketTile =
|
||||
override def read(buf: ByteBuf, id: Int, packet: PacketType)
|
||||
{
|
||||
val packet: PacketTile = new PacketTile(this);
|
||||
packet <<< descriptionPacket
|
||||
packet <<< colorID
|
||||
packet <<< fluidNode.connectedBitmask
|
||||
val tag: NBTTagCompound = new NBTTagCompound()
|
||||
fluidNode.save(tag)
|
||||
packet <<< tag
|
||||
sendPacket(packet)
|
||||
return packet
|
||||
}
|
||||
super.read(buf, id, packet)
|
||||
|
||||
override def read(buf: ByteBuf, id: Int, player: EntityPlayer, t: PacketType): Boolean =
|
||||
{
|
||||
if (id == descriptionPacket)
|
||||
id match
|
||||
{
|
||||
colorID = buf.readInt()
|
||||
clientRenderMask = buf.readByte()
|
||||
fluidNode.load(ByteBufUtils.readTag(buf))
|
||||
case 0 =>
|
||||
{
|
||||
colorID = buf.readInt()
|
||||
clientRenderMask = buf.readInt()
|
||||
fluidNode.setPrimaryTank(buf.readTank())
|
||||
}
|
||||
case 1 =>
|
||||
{
|
||||
colorID = buf.readInt()
|
||||
clientRenderMask = buf.readInt()
|
||||
}
|
||||
}
|
||||
else if (id == renderPacket)
|
||||
{
|
||||
colorID = buf.readInt()
|
||||
clientRenderMask = buf.readByte()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack = fluidNode.drain(from, resource, doDrain)
|
||||
|
@ -103,10 +99,5 @@ abstract class TileFluidProvider(material: Material) extends TileAdvanced(materi
|
|||
|
||||
override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = fluidNode.getTankInfo(from)
|
||||
|
||||
def setCapacity(capacity: Int)
|
||||
{
|
||||
fluidNode.setCapacity(capacity)
|
||||
}
|
||||
|
||||
def getFluidAmount: Int = fluidNode.getFluidAmount
|
||||
}
|
|
@ -23,7 +23,7 @@ import resonant.lib.content.prefab.TEnergyStorage
|
|||
import resonant.lib.content.prefab.java.TileElectric
|
||||
import resonant.lib.multiblock.reference.{IMultiBlockStructure, MultiBlockHandler}
|
||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.TPacketIDReceiver
|
||||
import resonant.lib.network.handle.{TPacketSender, TPacketIDReceiver}
|
||||
import resonant.lib.render.EnumColor
|
||||
import resonant.lib.transform.vector.{Vector3, VectorWorld}
|
||||
import resonant.lib.utility.{LanguageUtility, LinkUtility}
|
||||
|
@ -45,7 +45,7 @@ object TileTesla
|
|||
final val DEFAULT_COLOR: Int = 12
|
||||
}
|
||||
|
||||
class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[TileTesla] with ITesla with TPacketIDReceiver with TEnergyStorage
|
||||
class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[TileTesla] with ITesla with TPacketIDReceiver with TPacketSender with TEnergyStorage
|
||||
{
|
||||
|
||||
final val TRANSFER_CAP: Double = 10000D
|
||||
|
@ -224,11 +224,6 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
|
|||
return canReceive && tileEntity != getMultiBlock.get && !this.outputBlacklist.contains(tileEntity)
|
||||
}
|
||||
|
||||
def sendPacket(id: Int)
|
||||
{
|
||||
super.sendPacket(new PacketTile(xi, yi, zi, this.getPacketData(id).toArray))
|
||||
}
|
||||
|
||||
override def getDescPacket: PacketTile =
|
||||
{
|
||||
return new PacketTile(this, this.getPacketData(1).toArray)
|
||||
|
|
|
@ -3,6 +3,7 @@ package resonantinduction.mechanical.machine.edit
|
|||
import java.util.EnumSet
|
||||
|
||||
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
|
||||
|
@ -15,12 +16,12 @@ import net.minecraftforge.common.util.ForgeDirection
|
|||
import org.lwjgl.opengl.GL11
|
||||
import resonant.api.IRotatable
|
||||
import resonant.lib.content.prefab.java.TileInventory
|
||||
import resonant.lib.network.discriminator.PacketTile
|
||||
import resonant.lib.network.handle.TPacketReceiver
|
||||
import resonant.lib.network.discriminator.{PacketType, PacketTile}
|
||||
import resonant.lib.network.handle.{TPacketSender, TPacketReceiver}
|
||||
import resonant.lib.render.RenderItemOverlayUtility
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
import resonant.lib.utility.LanguageUtility
|
||||
import resonant.lib.utility.inventory.{InternalInventoryHandler, InventoryUtility}
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
|
||||
/**
|
||||
* @author tgame14
|
||||
|
@ -28,193 +29,192 @@ import resonant.lib.transform.vector.Vector3
|
|||
*/
|
||||
object TilePlacer
|
||||
{
|
||||
@SideOnly(Side.CLIENT) private var iconFront: IIcon = null
|
||||
@SideOnly(Side.CLIENT) private var iconBack: IIcon = null
|
||||
@SideOnly(Side.CLIENT) private var iconFront: IIcon = null
|
||||
@SideOnly(Side.CLIENT) private var iconBack: IIcon = null
|
||||
}
|
||||
|
||||
class TilePlacer extends TileInventory(Material.rock) with IRotatable with TPacketReceiver
|
||||
class TilePlacer extends TileInventory(Material.rock) with IRotatable with TPacketSender
|
||||
{
|
||||
private var _doWork: Boolean = false
|
||||
private var autoPullItems: Boolean = false
|
||||
private var placeDelay: Int = 0
|
||||
private var invHandler: InternalInventoryHandler = null
|
||||
private var _doWork: Boolean = false
|
||||
private var autoPullItems: Boolean = false
|
||||
private var placeDelay: Int = 0
|
||||
private var invHandler: InternalInventoryHandler = null
|
||||
|
||||
//Constructor
|
||||
setSizeInventory(1)
|
||||
normalRender = false
|
||||
forceItemToRenderAsBlock = true
|
||||
renderStaticBlock = true
|
||||
this.rotationMask = 63
|
||||
//Constructor
|
||||
setSizeInventory(1)
|
||||
normalRender = false
|
||||
forceItemToRenderAsBlock = true
|
||||
renderStaticBlock = true
|
||||
this.rotationMask = 63
|
||||
|
||||
|
||||
def getInvHandler: InternalInventoryHandler =
|
||||
def getInvHandler: InternalInventoryHandler =
|
||||
{
|
||||
if (invHandler == null)
|
||||
{
|
||||
if (invHandler == null)
|
||||
{
|
||||
invHandler = new InternalInventoryHandler(this)
|
||||
}
|
||||
return invHandler
|
||||
invHandler = new InternalInventoryHandler(this)
|
||||
}
|
||||
return invHandler
|
||||
}
|
||||
|
||||
override def onAdded
|
||||
{
|
||||
work
|
||||
}
|
||||
override def onAdded
|
||||
{
|
||||
work
|
||||
}
|
||||
|
||||
override def onNeighborChanged(block: Block)
|
||||
{
|
||||
work
|
||||
}
|
||||
override def onNeighborChanged(block: Block)
|
||||
{
|
||||
work
|
||||
}
|
||||
|
||||
override def start
|
||||
{
|
||||
super.start
|
||||
}
|
||||
override def start
|
||||
{
|
||||
super.start
|
||||
}
|
||||
|
||||
override def update
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
if (autoPullItems && this.ticks % 5 == 0)
|
||||
{
|
||||
super.update
|
||||
if (autoPullItems && this.ticks % 5 == 0)
|
||||
{
|
||||
if (getStackInSlot(0) == null)
|
||||
{
|
||||
this.setInventorySlotContents(0, this.getInvHandler.tryGrabFromPosition(this.getDirection.getOpposite, 1))
|
||||
}
|
||||
}
|
||||
if (_doWork)
|
||||
{
|
||||
if (placeDelay < java.lang.Byte.MAX_VALUE)
|
||||
{
|
||||
placeDelay += 1
|
||||
}
|
||||
if (placeDelay >= 5)
|
||||
{
|
||||
doWork
|
||||
_doWork = false
|
||||
}
|
||||
}
|
||||
if (getStackInSlot(0) == null)
|
||||
{
|
||||
this.setInventorySlotContents(0, this.getInvHandler.tryGrabFromPosition(this.getDirection.getOpposite, 1))
|
||||
}
|
||||
}
|
||||
if (_doWork)
|
||||
{
|
||||
if (placeDelay < java.lang.Byte.MAX_VALUE)
|
||||
{
|
||||
placeDelay += 1
|
||||
}
|
||||
if (placeDelay >= 5)
|
||||
{
|
||||
doWork
|
||||
_doWork = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def work
|
||||
def work
|
||||
{
|
||||
if (isIndirectlyPowered)
|
||||
{
|
||||
if (isIndirectlyPowered)
|
||||
{
|
||||
_doWork = true
|
||||
placeDelay = 0
|
||||
}
|
||||
_doWork = true
|
||||
placeDelay = 0
|
||||
}
|
||||
}
|
||||
|
||||
def doWork
|
||||
def doWork
|
||||
{
|
||||
val side: Int = 0
|
||||
val placePos: Vector3 = asVector3.add(getDirection)
|
||||
val placeStack: ItemStack = getStackInSlot(0)
|
||||
if (InventoryUtility.placeItemBlock(world, placePos.xi, placePos.yi, placePos.zi, placeStack, side))
|
||||
{
|
||||
val side: Int = 0
|
||||
val placePos: Vector3 = asVector3.add(getDirection)
|
||||
val placeStack: ItemStack = getStackInSlot(0)
|
||||
if (InventoryUtility.placeItemBlock(world, placePos.xi, placePos.yi, placePos.zi, placeStack, side))
|
||||
{
|
||||
if (placeStack.stackSize <= 0)
|
||||
{
|
||||
setInventorySlotContents(0, null)
|
||||
}
|
||||
markUpdate
|
||||
_doWork = false
|
||||
}
|
||||
if (placeStack.stackSize <= 0)
|
||||
{
|
||||
setInventorySlotContents(0, null)
|
||||
}
|
||||
markUpdate
|
||||
_doWork = false
|
||||
}
|
||||
}
|
||||
|
||||
override def use(player: EntityPlayer, hitSide: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
interactCurrentItem(this, 0, player)
|
||||
return true
|
||||
}
|
||||
override def use(player: EntityPlayer, hitSide: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
interactCurrentItem(this, 0, player)
|
||||
return true
|
||||
}
|
||||
|
||||
override def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
override def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
if (player.isSneaking)
|
||||
{
|
||||
if (player.isSneaking)
|
||||
{
|
||||
this.autoPullItems = !this.autoPullItems
|
||||
player.addChatComponentMessage(new ChatComponentText("AutoExtract: " + this.autoPullItems))
|
||||
return true
|
||||
}
|
||||
return super.configure(player, side, hit)
|
||||
this.autoPullItems = !this.autoPullItems
|
||||
player.addChatComponentMessage(new ChatComponentText("AutoExtract: " + this.autoPullItems))
|
||||
return true
|
||||
}
|
||||
return super.configure(player, side, hit)
|
||||
}
|
||||
|
||||
override def getDescPacket: PacketTile =
|
||||
{
|
||||
val nbt: NBTTagCompound = new NBTTagCompound
|
||||
writeToNBT(nbt)
|
||||
return new PacketTile(this, nbt)
|
||||
}
|
||||
override def getDescPacket: PacketTile =
|
||||
{
|
||||
val nbt: NBTTagCompound = new NBTTagCompound
|
||||
writeToNBT(nbt)
|
||||
return new PacketTile(this, nbt)
|
||||
}
|
||||
|
||||
override def onInventoryChanged
|
||||
{
|
||||
sendPacket(getDescPacket)
|
||||
}
|
||||
override def onInventoryChanged
|
||||
{
|
||||
sendDescPacket()
|
||||
}
|
||||
|
||||
override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
this.autoPullItems = nbt.getBoolean("autoPull")
|
||||
}
|
||||
override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
this.autoPullItems = nbt.getBoolean("autoPull")
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
nbt.setBoolean("autoPull", this.autoPullItems)
|
||||
}
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
nbt.setBoolean("autoPull", this.autoPullItems)
|
||||
}
|
||||
|
||||
override def canStore(stack: ItemStack, slot: Int, side: ForgeDirection): Boolean =
|
||||
{
|
||||
return side == this.getDirection.getOpposite && slot == 0
|
||||
}
|
||||
override def canStore(stack: ItemStack, slot: Int, side: ForgeDirection): Boolean =
|
||||
{
|
||||
return side == this.getDirection.getOpposite && slot == 0
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def getIcon(access: IBlockAccess, side: Int): IIcon =
|
||||
@SideOnly(Side.CLIENT) override def getIcon(access: IBlockAccess, side: Int): IIcon =
|
||||
{
|
||||
val meta: Int = access.getBlockMetadata(xi, yi, zi)
|
||||
if (side == meta)
|
||||
{
|
||||
val meta: Int = access.getBlockMetadata(xi, yi, zi)
|
||||
if (side == meta)
|
||||
{
|
||||
return TilePlacer.iconFront
|
||||
}
|
||||
else if (side == (meta ^ 1))
|
||||
{
|
||||
return TilePlacer.iconBack
|
||||
}
|
||||
return getIcon
|
||||
return TilePlacer.iconFront
|
||||
}
|
||||
else if (side == (meta ^ 1))
|
||||
{
|
||||
return TilePlacer.iconBack
|
||||
}
|
||||
return getIcon
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): IIcon =
|
||||
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): IIcon =
|
||||
{
|
||||
if (side == (meta ^ 1))
|
||||
{
|
||||
if (side == (meta ^ 1))
|
||||
{
|
||||
return TilePlacer.iconFront
|
||||
}
|
||||
else if (side == meta)
|
||||
{
|
||||
return TilePlacer.iconBack
|
||||
}
|
||||
return getIcon
|
||||
return TilePlacer.iconFront
|
||||
}
|
||||
else if (side == meta)
|
||||
{
|
||||
return TilePlacer.iconBack
|
||||
}
|
||||
return getIcon
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def registerIcons(iconRegister: IIconRegister)
|
||||
{
|
||||
super.registerIcons(iconRegister)
|
||||
TilePlacer.iconFront = iconRegister.registerIcon(getTextureName + "_front")
|
||||
TilePlacer.iconBack = iconRegister.registerIcon(getTextureName + "_back")
|
||||
}
|
||||
@SideOnly(Side.CLIENT) override def registerIcons(iconRegister: IIconRegister)
|
||||
{
|
||||
super.registerIcons(iconRegister)
|
||||
TilePlacer.iconFront = iconRegister.registerIcon(getTextureName + "_front")
|
||||
TilePlacer.iconBack = iconRegister.registerIcon(getTextureName + "_back")
|
||||
}
|
||||
|
||||
override def renderDynamic(position: Vector3, frame: Float, pass: Int)
|
||||
override def renderDynamic(position: Vector3, frame: Float, pass: Int)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
val set: EnumSet[ForgeDirection] = EnumSet.allOf(classOf[ForgeDirection])
|
||||
set.remove(getDirection)
|
||||
set.remove(getDirection.getOpposite)
|
||||
set.remove(ForgeDirection.UP)
|
||||
set.remove(ForgeDirection.DOWN)
|
||||
GL11.glPushMatrix
|
||||
RenderItemOverlayUtility.renderItemOnSides(this, getStackInSlot(0), position.x, position.y, position.z, LanguageUtility.getLocal("tooltip.noOutput"), set)
|
||||
GL11.glPopMatrix
|
||||
}
|
||||
val set: EnumSet[ForgeDirection] = EnumSet.allOf(classOf[ForgeDirection])
|
||||
set.remove(getDirection)
|
||||
set.remove(getDirection.getOpposite)
|
||||
set.remove(ForgeDirection.UP)
|
||||
set.remove(ForgeDirection.DOWN)
|
||||
GL11.glPushMatrix
|
||||
RenderItemOverlayUtility.renderItemOnSides(this, getStackInSlot(0), position.x, position.y, position.z, LanguageUtility.getLocal("tooltip.noOutput"), set)
|
||||
GL11.glPopMatrix
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue