BiomesOPlenty/common/biomesoplenty/tileentities/TileEntityAltar.java

143 lines
3.9 KiB
Java
Raw Normal View History

2013-07-03 07:51:39 +00:00
package biomesoplenty.tileentities;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
public class TileEntityAltar extends TileEntity
{
2013-11-06 22:04:21 +00:00
private boolean malachitePresent = false;
private boolean peridotPresent = false;
private boolean rubyPresent = false;
private boolean sapphirePresent = false;
private boolean tanzanitePresent = false;
private boolean topazPresent = false;
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
2013-11-06 22:04:21 +00:00
this.malachitePresent = nbt.getBoolean("malachitePresent");
this.peridotPresent = nbt.getBoolean("peridotPresent");
this.rubyPresent = nbt.getBoolean("rubyPresent");
this.sapphirePresent = nbt.getBoolean("sapphirePresent");
this.tanzanitePresent = nbt.getBoolean("tanzanitePresent");
this.topazPresent = nbt.getBoolean("topazPresent");
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
2013-11-06 22:04:21 +00:00
nbt.setBoolean("malachitePresent", malachitePresent);
nbt.setBoolean("peridotPresent", peridotPresent);
nbt.setBoolean("rubyPresent", rubyPresent);
nbt.setBoolean("sapphirePresent", sapphirePresent);
nbt.setBoolean("tanzanitePresent", tanzanitePresent);
nbt.setBoolean("topazPresent", topazPresent);
}
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound nbt = new NBTTagCompound();
2013-11-06 22:04:21 +00:00
nbt.setBoolean("malachitePresent", malachitePresent);
nbt.setBoolean("peridotPresent", peridotPresent);
nbt.setBoolean("rubyPresent", rubyPresent);
nbt.setBoolean("sapphirePresent", sapphirePresent);
nbt.setBoolean("tanzanitePresent", tanzanitePresent);
nbt.setBoolean("topazPresent", topazPresent);
return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
}
@Override
public void onDataPacket(INetworkManager var1, Packet132TileEntityData packet)
{
if (packet.actionType == 0)
{
2013-11-06 22:04:21 +00:00
this.malachitePresent = packet.data.getBoolean("malachitePresent");
this.peridotPresent = packet.data.getBoolean("peridotPresent");
this.rubyPresent = packet.data.getBoolean("rubyPresent");
this.sapphirePresent = packet.data.getBoolean("sapphirePresent");
this.tanzanitePresent = packet.data.getBoolean("tanzanitePresent");
this.topazPresent = packet.data.getBoolean("topazPresent");
}
this.worldObj.markBlockForUpdate(packet.xPosition, packet.yPosition, packet.zPosition);
}
public void setPresent(int presentGem, boolean state)
{
if (presentGem == 10)
{
rubyPresent = state;
}
else if (presentGem == 11)
{
peridotPresent = state;
}
else if (presentGem == 12)
{
topazPresent = state;
}
else if (presentGem == 13)
{
tanzanitePresent = state;
}
else if (presentGem == 14)
{
2013-11-06 22:04:21 +00:00
malachitePresent = state;
}
else if (presentGem == 15)
{
sapphirePresent = state;
}
}
public boolean getPresent(int presentGem)
{
if (presentGem == 10)
{
return rubyPresent;
}
else if (presentGem == 11)
{
return peridotPresent;
}
else if (presentGem == 12)
{
return topazPresent;
}
else if (presentGem == 13)
{
return tanzanitePresent;
}
else if (presentGem == 14)
{
2013-11-06 22:04:21 +00:00
return malachitePresent;
}
else if (presentGem == 15)
{
return sapphirePresent;
}
2013-06-08 02:50:47 +00:00
else
{
return false;
}
}
public boolean getAllPresent()
{
2013-11-06 22:04:21 +00:00
if (rubyPresent && peridotPresent && topazPresent && tanzanitePresent && malachitePresent && sapphirePresent)
{
return true;
}
2013-07-01 00:31:34 +00:00
return false;
}
}