BloodMagic/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java

103 lines
2.6 KiB
Java
Raw Normal View History

2014-01-17 19:12:49 +00:00
package WayofTime.alchemicalWizardry.common.tileEntity;
2014-01-24 15:21:10 +00:00
import WayofTime.alchemicalWizardry.common.PacketHandler;
2014-01-17 19:12:49 +00:00
import WayofTime.alchemicalWizardry.common.block.IOrientable;
import net.minecraft.nbt.NBTTagCompound;
2014-01-24 15:21:10 +00:00
import net.minecraft.network.packet.Packet;
2014-01-17 19:12:49 +00:00
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public class TEOrientable extends TileEntity implements IOrientable
{
protected ForgeDirection inputFace;
protected ForgeDirection outputFace;
public TEOrientable()
{
this.inputFace = ForgeDirection.DOWN;
this.outputFace = ForgeDirection.UP;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.setInputDirection(ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("inputFace")));
this.setOutputDirection(ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("outputFace")));
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("inputFace", TEOrientable.getIntForForgeDirection(this.getInputDirection()));
par1NBTTagCompound.setInteger("outputFace", TEOrientable.getIntForForgeDirection(this.getOutputDirection()));
}
@Override
public ForgeDirection getInputDirection()
{
return this.inputFace;
}
@Override
public ForgeDirection getOutputDirection()
{
return this.outputFace;
}
@Override
public void setInputDirection(ForgeDirection direction)
{
this.inputFace = direction;
}
@Override
public void setOutputDirection(ForgeDirection direction)
{
this.outputFace = direction;
}
public static int getIntForForgeDirection(ForgeDirection direction)
{
switch (direction)
{
case DOWN:
return 0;
case UP:
return 1;
case NORTH:
return 2;
case SOUTH:
return 3;
case WEST:
return 4;
case EAST:
return 5;
default:
return 0;
}
}
2014-01-24 15:21:10 +00:00
@Override
public Packet getDescriptionPacket()
{
return PacketHandler.getBlockOrientationPacket(this);
}
2014-02-02 13:48:11 +00:00
public boolean isSideRendered(ForgeDirection side)
{
if(side.equals(this.getInputDirection()) || side.equals(this.getOutputDirection()))
{
return true;
}
return false;
}
2014-01-17 19:12:49 +00:00
}