Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TileEntityCPU extends TileEntity{
- //string list (replace references of this with yours)
- public List<String> stringList = new ArrayList<String>(9);
- public TileEntityCPU() {
- super();
- this.stringList.add(0, "1");
- this.stringList.add(1, "2");
- this.stringList.add(2, "3");
- this.stringList.add(3, "4");
- this.stringList.add(4, "5");
- this.stringList.add(5, "6");
- this.stringList.add(6, "7");
- this.stringList.add(7, "8");
- this.stringList.add(8, "9");
- System.out.println(this.stringList);
- }
- public String getLine(int line) {
- return this.stringList.get(line);
- }
- public void setLine(String code, int line) {
- this.stringList.set(line, code);
- }
- public void writeToNBT(NBTTagCompound comp)
- {
- super.writeToNBT(comp);
- NBTTagList tagList = new NBTTagList();
- for(int i = 0; i < stringList.size(); i++)
- {
- String s = stringList.get(i);
- if(s != null)
- {
- NBTTagCompound tag = new NBTTagCompound();
- tag.setString("Code" + i, s);
- tagList.appendTag(tag);
- }
- }
- comp.setTag("CodeList", tagList);
- }
- public void readFromNBT(NBTTagCompound comp)
- {
- super.readFromNBT(comp);
- NBTTagList tagList = comp.getTagList("CodeList", Constants.NBT.TAG_COMPOUND);
- for(int i = 0; i < tagList.tagCount(); i++)
- {
- NBTTagCompound tag = tagList.getCompoundTagAt(i);
- String s = tag.getString("Code" + i);
- stringList.add(i, s);
- }
- }
- public Container createContainer() {
- return new ContainerCPU();
- }
- @Override
- public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
- {
- this.readFromNBT(pkt.getNbtCompound());
- this.markDirty();
- }
- public void update(World world) {
- worldObj.markBlockForUpdate(this.pos);
- }
- }
Add Comment
Please, Sign In to add comment