Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.JV.WTTI.GearBed.Block;
- import java.util.ArrayList;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.nbt.NBTTagList;
- import net.minecraft.server.gui.IUpdatePlayerListBox;
- import net.minecraft.tileentity.TileEntity;
- public class GearBedTileEntity extends TileEntity implements IUpdatePlayerListBox {
- private boolean aBoolean;
- private byte aByte;
- private short aShort;
- private int anInt;
- private long aLong;
- private float aFloat;
- private double aDouble;
- private String aString;
- private byte[] aByteArray;
- private int[] anIntArray;
- private ItemStack anItemStack;
- private ArrayList aList = new ArrayList();
- private String Owner;
- @Override
- public void update() {
- // if (!this.worldObj.isRemote)
- // System.out.println("Hello, I'm a TileEntity!");
- }
- @Override
- public void writeToNBT(NBTTagCompound compound) {
- super.writeToNBT(compound);
- //Primitives:
- compound.setBoolean("aBoolean", this.aBoolean);
- compound.setByte("aByte", this.aByte);
- compound.setShort("aShort", this.aShort);
- compound.setInteger("anInt", this.anInt);
- compound.setLong("aLong", this.aLong);
- compound.setFloat("aFloat", this.aFloat);
- compound.setDouble("aDouble", this.aDouble);
- compound.setString("aString", this.aString);
- compound.setByteArray("aByteArray", this.aByteArray);
- compound.setIntArray("anIntArray", this.anIntArray);
- compound.setString("Owner", this.Owner);
- //Item Stack:
- NBTTagCompound stack = new NBTTagCompound();
- this.anItemStack.writeToNBT(stack);
- compound.setTag("anItemStack", stack);
- //TagList of Integer Tags:
- NBTTagList list = new NBTTagList();
- for (int i = 0; i < this.aList.size(); i++) {
- NBTTagCompound nbt = new NBTTagCompound();
- nbt.setInteger("id", i);
- nbt.setInteger("value", (Integer) this.aList.get(i));
- list.appendTag(nbt);
- }
- compound.setTag("aList", list);
- }
- @Override
- public void readFromNBT(NBTTagCompound compound) {
- super.readFromNBT(compound);
- //Primitives:
- this.aBoolean = compound.getBoolean("aBoolean");
- this.aByte = compound.getByte("aByte");
- this.aShort = compound.getShort("aShort");
- this.anInt = compound.getInteger("anInt");
- this.aLong = compound.getLong("aLong");
- this.aFloat = compound.getFloat("aFloat");
- this.aDouble = compound.getDouble("aDouble");
- this.aString = compound.getString("aString");
- this.aByteArray = compound.getByteArray("aByteArray");
- this.anIntArray = compound.getIntArray("anIntArray");
- this.Owner = compound.getString("Owner");
- //ItemStack:
- this.anItemStack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("anItemStack"));
- //TagList of Integer Tags:
- NBTTagList list = compound.getTagList("aList", 10);
- this.aList.clear();
- for (int i = 0; i < list.tagCount(); i++) {
- NBTTagCompound nbt = list.getCompoundTagAt(i);
- int id = nbt.getInteger("id");
- int value = nbt.getInteger("value");
- this.aList.ensureCapacity(id);
- this.aList.set(id, value);
- }
- }
- public String GetOwner(){
- return this.Owner;
- }
- public void SetOwner(String S){
- this.Owner = S;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement