2014-09-19 04:38:14 +02:00
|
|
|
package com.pahimar.ee3.tileentity;
|
|
|
|
|
2014-10-03 21:55:22 +02:00
|
|
|
import com.pahimar.ee3.api.AlchemyArray;
|
|
|
|
import com.pahimar.ee3.api.Glyph;
|
|
|
|
import com.pahimar.ee3.network.PacketHandler;
|
|
|
|
import com.pahimar.ee3.network.message.MessageTileEntityAlchemyArray;
|
2014-09-25 22:23:45 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-10-03 21:55:22 +02:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.network.Packet;
|
2014-09-25 22:23:45 +02:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
2014-09-24 22:02:45 +02:00
|
|
|
|
2014-09-19 04:38:14 +02:00
|
|
|
public class TileEntityAlchemyArray extends TileEntityEE
|
|
|
|
{
|
2014-10-03 21:55:22 +02:00
|
|
|
private AlchemyArray alchemyArray;
|
2014-10-10 20:54:07 +02:00
|
|
|
private int rotation;
|
2014-09-24 22:02:45 +02:00
|
|
|
|
|
|
|
public TileEntityAlchemyArray()
|
|
|
|
{
|
|
|
|
super();
|
2014-10-03 21:55:22 +02:00
|
|
|
alchemyArray = new AlchemyArray();
|
2014-10-10 20:54:07 +02:00
|
|
|
rotation = 0;
|
2014-09-24 22:02:45 +02:00
|
|
|
}
|
|
|
|
|
2014-10-03 21:55:22 +02:00
|
|
|
public AlchemyArray getAlchemyArray()
|
2014-09-24 22:02:45 +02:00
|
|
|
{
|
2014-10-03 21:55:22 +02:00
|
|
|
return alchemyArray;
|
2014-09-25 22:23:45 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 20:54:07 +02:00
|
|
|
public void addGlyphToAlchemyArray(Glyph glyph, int size)
|
2014-09-25 22:23:45 +02:00
|
|
|
{
|
2014-10-10 20:54:07 +02:00
|
|
|
alchemyArray.addGlyph(new Glyph(glyph, size));
|
2014-10-03 21:55:22 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 20:54:07 +02:00
|
|
|
public int getRotation()
|
2014-10-03 21:55:22 +02:00
|
|
|
{
|
2014-10-10 20:54:07 +02:00
|
|
|
return rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRotation(int rotation)
|
|
|
|
{
|
|
|
|
this.rotation = rotation;
|
|
|
|
|
|
|
|
if (this.rotation < 0)
|
|
|
|
{
|
|
|
|
this.rotation = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.rotation = this.rotation % 4;
|
|
|
|
}
|
2014-09-25 22:23:45 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 20:54:07 +02:00
|
|
|
public void rotate()
|
2014-10-07 22:20:41 +02:00
|
|
|
{
|
2014-10-10 20:54:07 +02:00
|
|
|
rotate(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param rotateClockwise true if we should rotate clockwise, false if we rotate counter clockwise
|
|
|
|
*/
|
|
|
|
public void rotate(boolean rotateClockwise)
|
|
|
|
{
|
|
|
|
if (rotateClockwise)
|
|
|
|
{
|
|
|
|
this.rotation = (rotation + 1) % 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.rotation -= 1;
|
|
|
|
|
|
|
|
if (this.rotation < 0)
|
|
|
|
{
|
|
|
|
this.rotation = 3;
|
|
|
|
}
|
|
|
|
}
|
2014-10-07 22:20:41 +02:00
|
|
|
}
|
|
|
|
|
2014-09-25 22:23:45 +02:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public AxisAlignedBB getRenderBoundingBox()
|
|
|
|
{
|
2014-10-07 22:20:41 +02:00
|
|
|
// TODO: Make this glyph size and orientation sensitive
|
|
|
|
return AxisAlignedBB.getBoundingBox(xCoord - alchemyArray.getLargestGlyphSize(), yCoord - alchemyArray.getLargestGlyphSize(), zCoord - alchemyArray.getLargestGlyphSize(), xCoord + alchemyArray.getLargestGlyphSize(), yCoord + alchemyArray.getLargestGlyphSize(), zCoord + alchemyArray.getLargestGlyphSize());
|
2014-10-03 21:55:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Packet getDescriptionPacket()
|
|
|
|
{
|
|
|
|
return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAlchemyArray(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
|
|
|
{
|
|
|
|
super.readFromNBT(nbtTagCompound);
|
|
|
|
|
|
|
|
NBTTagCompound alchemyArrayTagCompound = nbtTagCompound.getCompoundTag("alchemyArray");
|
|
|
|
alchemyArray = AlchemyArray.readAlchemyArrayFromNBT(alchemyArrayTagCompound);
|
2014-10-10 20:54:07 +02:00
|
|
|
|
|
|
|
rotation = nbtTagCompound.getInteger("rotation");
|
2014-10-03 21:55:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound nbtTagCompound)
|
|
|
|
{
|
|
|
|
super.writeToNBT(nbtTagCompound);
|
|
|
|
|
|
|
|
NBTTagCompound alchemyArrayTagCompound = new NBTTagCompound();
|
|
|
|
alchemyArray.writeToNBT(alchemyArrayTagCompound);
|
|
|
|
|
2014-10-10 20:54:07 +02:00
|
|
|
nbtTagCompound.setInteger("rotation", rotation);
|
|
|
|
|
2014-10-03 21:55:22 +02:00
|
|
|
nbtTagCompound.setTag("alchemyArray", alchemyArrayTagCompound);
|
2014-09-24 22:02:45 +02:00
|
|
|
}
|
2014-09-19 04:38:14 +02:00
|
|
|
}
|