Posted July 27, 20178 yr I want to save a list that contains all tileEntity from a specific type, but I dont know how to readFromNBT and writeToNBT the dimension(World) of my TileEntities. Here is my code : Spoiler public class ModWorldSavedData extends WorldSavedData{ private static final String TELEPORTER = Main.MODID + "_Teleporter"; public static List<TileEntityTeleporter> teleporterList = new ArrayList<TileEntityTeleporter>(); public ModWorldSavedData() { super(TELEPORTER); } public ModWorldSavedData(String name) { super(name); } @Override public void readFromNBT(NBTTagCompound nbt) { teleporterList.clear(); int j = nbt.getInteger("size"); for(int i = 0 ; i < j; i++) { TileEntityTeleporter te = null; int[] k = nbt.getIntArray("pos" + i); //Get world te.setPos(new BlockPos(k[0], k[1], k[2])); //Set world te.setWorldObj(??????????); teleporterList.add(te); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { if(this.teleporterList.size() > 0) { nbt.setInteger("size", this.teleporterList.size()); for(int i = 0 ; i < this.teleporterList.size(); i++) { TileEntityTeleporter te = teleporterList.get(i); int[] j = new int[3]; j[0] = te.getPos().getX(); j[1] = te.getPos().getY(); j[2] = te.getPos().getZ(); nbt.setIntArray("pos" + i, j); } } return nbt; } } Edited July 27, 20178 yr by personnedu13 Wrong question
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.