2016-02-18 17:25:11 +01:00
|
|
|
package WayofTime.bloodmagic.tile;
|
|
|
|
|
2016-02-25 08:54:18 -05:00
|
|
|
import WayofTime.bloodmagic.ritual.RitualPortal;
|
|
|
|
import com.google.common.base.Strings;
|
2016-09-07 17:12:25 -07:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2016-09-07 17:12:25 -07:00
|
|
|
import net.minecraft.network.NetworkManager;
|
|
|
|
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-09-07 17:12:25 -07:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2016-02-18 17:25:11 +01:00
|
|
|
|
|
|
|
public class TileDimensionalPortal extends TileEntity
|
|
|
|
{
|
2016-02-23 22:47:28 -08:00
|
|
|
public String portalID = "";
|
2016-02-18 17:25:11 +01:00
|
|
|
public int masterStoneX;
|
|
|
|
public int masterStoneY;
|
|
|
|
public int masterStoneZ;
|
|
|
|
|
|
|
|
public TileDimensionalPortal()
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void readFromNBT(NBTTagCompound tagCompound)
|
|
|
|
{
|
|
|
|
super.readFromNBT(tagCompound);
|
|
|
|
|
|
|
|
portalID = tagCompound.getString(RitualPortal.PORTAL_ID_TAG);
|
|
|
|
|
|
|
|
masterStoneX = tagCompound.getInteger("masterStoneX");
|
|
|
|
masterStoneY = tagCompound.getInteger("masterStoneY");
|
|
|
|
masterStoneZ = tagCompound.getInteger("masterStoneZ");
|
|
|
|
}
|
|
|
|
|
2016-05-19 17:43:33 -07:00
|
|
|
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
2016-02-18 17:25:11 +01:00
|
|
|
{
|
|
|
|
super.writeToNBT(tagCompound);
|
|
|
|
|
2016-02-23 22:47:28 -08:00
|
|
|
tagCompound.setString(RitualPortal.PORTAL_ID_TAG, Strings.isNullOrEmpty(portalID) ? "" : portalID);
|
2016-02-18 17:25:11 +01:00
|
|
|
|
|
|
|
tagCompound.setInteger("masterStoneX", masterStoneX);
|
|
|
|
tagCompound.setInteger("masterStoneY", masterStoneY);
|
|
|
|
tagCompound.setInteger("masterStoneZ", masterStoneZ);
|
2016-05-19 17:43:33 -07:00
|
|
|
return tagCompound;
|
2016-02-18 17:25:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public BlockPos getMasterStonePos()
|
|
|
|
{
|
|
|
|
return new BlockPos(masterStoneX, masterStoneY, masterStoneZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMasterStonePos(BlockPos blockPos)
|
|
|
|
{
|
|
|
|
this.masterStoneX = blockPos.getX();
|
|
|
|
this.masterStoneY = blockPos.getY();
|
|
|
|
this.masterStoneZ = blockPos.getZ();
|
|
|
|
}
|
2016-09-07 17:12:25 -07:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public SPacketUpdateTileEntity getUpdatePacket()
|
|
|
|
{
|
|
|
|
NBTTagCompound nbt = new NBTTagCompound();
|
|
|
|
writeToNBT(nbt);
|
|
|
|
return new SPacketUpdateTileEntity(getPos(), -999, nbt);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
|
|
|
|
{
|
|
|
|
super.onDataPacket(net, pkt);
|
|
|
|
readFromNBT(pkt.getNbtCompound());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public NBTTagCompound getUpdateTag()
|
|
|
|
{
|
|
|
|
return writeToNBT(new NBTTagCompound());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleUpdateTag(NBTTagCompound tag)
|
|
|
|
{
|
|
|
|
readFromNBT(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
|
|
|
|
{
|
|
|
|
return oldState.getBlock() != newState.getBlock();
|
|
|
|
}
|
2016-02-18 17:25:11 +01:00
|
|
|
}
|