Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dk.adventures.AdvScreen.TileEntity;
- //import cofh.api.energy.EnergyStorage;
- //import cofh.api.energy.IEnergyHandler;
- import dk.adventures.AdvScreen.Utils.Logger;
- import net.minecraft.client.Minecraft;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.network.NetworkManager;
- import net.minecraft.network.Packet;
- import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraftforge.common.util.ForgeDirection;
- /**
- * Created by rem on 03-08-2014.
- */
- public class TileEntityScreen extends TileEntity
- {
- //The direction the "front" of the screen is facing.
- //0=north, 1=east, 2=south, 3=west, 4,5,6,7=Up/NESW, 8,9,10,11=Down/NESW
- public int Orientation = 0;
- public float Depth = 1.0f;
- public static final class TAGS
- {
- public static String Orientation = "Orientation";
- public static String Depth = "Depth";
- }//class
- public TileEntityScreen()
- {
- }
- @Override
- public void readFromNBT(NBTTagCompound nbt)
- {
- super.readFromNBT(nbt);
- if (nbt.hasKey(TAGS.Orientation))
- this.Orientation = nbt.getByte(TAGS.Orientation);
- if (nbt.hasKey(TAGS.Depth))
- this.Depth = nbt.getFloat(TAGS.Depth);
- }
- @Override
- public void writeToNBT(NBTTagCompound nbt)
- {
- super.writeToNBT(nbt);
- nbt.setByte(TAGS.Orientation, (byte)this.Orientation);
- nbt.setFloat(TAGS.Depth, this.Depth);
- }
- int m_iTimer = 0;
- @Override
- public void updateEntity()
- {
- m_iTimer++;
- if (m_iTimer >= 20)
- {
- if (!getWorldObj().isRemote)
- {
- //Minecraft.getMinecraft().thePlayer.sendChatMessage(String.format("Hej!"));
- }
- m_iTimer = 0;
- }
- }
- @Override
- public Packet getDescriptionPacket()
- {
- Logger.Debug("getDescriptionPacket");
- NBTTagCompound nbtTag = new NBTTagCompound();
- this.writeToNBT(nbtTag);
- return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
- }
- @Override
- public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
- {
- Logger.Debug("onDataPacket");
- readFromNBT(packet.func_148857_g());
- }
- }//class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement