resonant-induction/APIs/universalelectricity/prefab/tile/TileEntityAdvanced.java

60 lines
1.2 KiB
Java
Raw Normal View History

package universalelectricity.prefab.tile;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
2013-08-06 17:29:56 +02:00
/** A TileEntity with some pre-added functionalities.
*
* @author Calclavia */
public abstract class TileEntityAdvanced extends TileEntity
{
2013-08-06 17:29:56 +02:00
protected long ticks = 0;
@Override
public void updateEntity()
{
if (this.ticks == 0)
{
this.initiate();
}
if (this.ticks >= Long.MAX_VALUE)
{
this.ticks = 1;
}
this.ticks++;
}
/** Called on the TileEntity's first tick. */
public void initiate()
{
}
@Override
public int getBlockMetadata()
{
if (this.worldObj == null)
{
return 0;
}
else if (this.blockMetadata == -1)
{
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
}
return this.blockMetadata;
}
@Override
public Block getBlockType()
{
if (this.blockType == null)
{
this.blockType = Block.blocksList[this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord)];
}
return this.blockType;
}
}