[11:57:59] [server thread/ERROR] [FML]: A TileEntity type com.zombiesurvival.tileentity.GoldChestTileEntity has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.RuntimeException: class com.zombiesurvival.tileentity.GoldChestTileEntity is missing a mapping! This is a bug!
at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:93) ~[TileEntity.class:?]
at com.zombiesurvival.tileentity.GoldChestTileEntity.writeToNBT(GoldChestTileEntity.java:197) ~[GoldChestTileEntity.class:?]
at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:410) [AnvilChunkLoader.class:?]
at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:193) [AnvilChunkLoader.class:?]
at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:266) [ChunkProviderServer.class:?]
at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:332) [ChunkProviderServer.class:?]
at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:976) [WorldServer.class:?]
at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:419) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:454) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:356) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:593) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]
GoldChest Tile Entity
package com.zombiesurvival.tileentity;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
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;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IChatComponent;
public class GoldChestTileEntity extends TileEntity implements IUpdatePlayerListBox, IInventory
{
//Declaring Variables
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 ItemStack[] inv;
private String test;
public GoldChestTileEntity()
{
this.inv = new ItemStack[this.getSizeInventory()];
}
public String getCustomName()
{
return this.test;
}
public void setCustomName(String test)
{
this.test = test;
}
@Override
public String getName()
{
return this.hasCustomName() ? this.test : "container.goldchest_tile_entity";
}
@Override
public boolean hasCustomName()
{
return this.test != null && !this.test.equals("");
}
@Override
public IChatComponent getDisplayName()
{
return this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName());
}
@Override
public int getSizeInventory()
{
return 9;
}
@Override
public ItemStack getStackInSlot(int index)
{
if(index < 0 || index >= this.getSizeInventory())
return null;
return this.inv[index];
}
@Override
public ItemStack decrStackSize(int index, int count)
{
if(this.getStackInSlot(index) != null)
{
ItemStack itemstack;
if(this.getStackInSlot(index).stackSize <= count)
{
itemstack = this.getStackInSlot(index);
this.setInventorySlotContents(index, null);
this.markDirty();
return itemstack;
}
else
{
itemstack = this.getStackInSlot(index).splitStack(count);
if(this.getStackInSlot(index).stackSize <= 0)
{
this.setInventorySlotContents(index, null);
}
else
{
//Just to show that changes happened
this.setInventorySlotContents(index, this.getStackInSlot(index));
}
this.markDirty();
return itemstack;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int index)
{
ItemStack stack = this.getStackInSlot(index);
this.setInventorySlotContents(index, null);
return stack;
}
@Override
public void setInventorySlotContents(int index, ItemStack stack)
{
if(index < 0 || index >= this.getSizeInventory())
return;
if(stack != null && stack.stackSize > this.getInventoryStackLimit())
stack.stackSize = this.getInventoryStackLimit();
if(stack != null && stack.stackSize == 0)
stack = null;
this.inv[index] = stack;
this.markDirty();
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer p)
{
return this.worldObj.getTileEntity(this.getPos()) == this && p.getDistanceSq(this.pos.add(0.5,0.5,0.5)) <= 64;
}
@Override
public void openInventory(EntityPlayer p)
{
}
@Override
public void closeInventory(EntityPlayer p)
{
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack)
{
return true;
}
@Override
public int getField(int id)
{
return 0;
}
@Override
public void setField(int id, int value)
{
}
@Override
public int getFieldCount()
{
return 0;
}
@Override
public void clear()
{
for(int i =0; i < this.getSizeInventory(); i++)
this.setInventorySlotContents(i, null);
}
@Override
public void update()
{
}
@Override
public void writeToNBT(NBTTagCompound c)
{
super.writeToNBT(c);
/**
//Primitives
c.setBoolean("aBoolean", this.aBoolean);
c.setByte("aByte", this.aByte);
c.setShort("aShort", this.aShort);
c.setInteger("anInt", this.anInt);
c.setLong("aLong", this.aLong);
c.setFloat("aFloat", this.aFloat);
c.setDouble("aDouble", this.aDouble);
c.setString("aString", this.aString);
c.setByteArray("aByteArray", this.aByteArray);
c.setIntArray("anIntArray", this.anIntArray);
//Item Stack
NBTTagCompound s = new NBTTagCompound();
this.anItemStack.writeToNBT(s);
c.setTag("anItemStack", s);
//TagList of Integer Tags
NBTTagList l = new NBTTagList();
for(int i = 0; i < this.aList.size(); i++)
{
NBTTagCompound n = new NBTTagCompound();
n.setInteger("id", i);
n.setInteger("value", (Integer) this.aList.get(i));
l.appendTag(n);
}
c.setTag("aList", l);*/
NBTTagList list= new NBTTagList();
for (int i =0; i <this.getSizeInventory(); ++i)
{
if(this.getStackInSlot(i)!= null)
{
NBTTagCompound stackTag = new NBTTagCompound();
stackTag.setByte("Slot1", (byte)i) ;
this.getStackInSlot(i).writeToNBT(stackTag);
list.appendTag(stackTag);
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
/**Primitives
this.aBoolean = c.getBoolean("aBoolean");
this.aByte = c.getByte("aByte");
this.aShort = c.getShort("aShort");
this.anInt = c.getInteger("aInt");
this.aLong = c.getLong("aLong");
this.aFloat = c.getFloat("aFloat");
this.aDouble = c.getDouble("aDouble");
this.aString = c.getString("aString");
this.aByteArray = c.getByteArray("aByteArray");
this.anIntArray = c.getIntArray("anIntArray");
//ItemStack
this.anItemStack = ItemStack.loadItemStackFromNBT(c.getCompoundTag("anItemStack"));
//TagList of IntegerTags
NBTTagList l = c.getTagList("aList", 10);
this.aList.clear();
for(int i = 0; i < l.tagCount(); i++)
{
NBTTagCompound n = l.getCompoundTagAt(i);
int id = n.getInteger("id");
int value = n.getInteger("value");
this.aList.ensureCapacity(id);
this.aList.set(id, value);
}
*/
NBTTagList list = nbt.getTagList("Items", 10);
for(int i = 0; i < list.tagCount(); ++i)
{
NBTTagCompound stackTag = list.getCompoundTagAt(i);
int slot = stackTag.getByte("Slot") & 255;
this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag));
}
if(nbt.hasKey("gold", 9))
{
this.setCustomName(nbt.getString("gold"));
}
}
}
ModTileEntities <- Where TileEntities Are Registered
package com.zombiesurvival.tileentity;
import com.zombiesurvival.power.pipes.TileEntityPipe;
import net.minecraftforge.fml.common.registry.GameRegistry;
public final class ModTileEntities
{
public static void init()
{
GameRegistry.registerTileEntity(IronChestTileEntity.class, "ironchest_tile_entity");
GameRegistry.registerTileEntity(IronChestTileEntity.class, "goldchest_tile_entity");
GameRegistry.registerTileEntity(LargeBackpackTileEntity.class, "largebackpack_tile_entity");
GameRegistry.registerTileEntity(ElectricFurnaceTileEntity.class, "electric_furnace_tile_entity");
GameRegistry.registerTileEntity(TileEntityPipe.class, "pipe_tile_entity");
}
}
Main Class
package com.zombiesurvival;
import com.zombiesurvival.blocks.ModBlocks;
import com.zombiesurvival.gui.handlers.EventHandlerOverlay;
import com.zombiesurvival.gui.handlers.ModGuiHandler;
import com.zombiesurvival.gui.hud.ItemHUDactivator;
import com.zombiesurvival.gui.hud.StatusBarRenderer;
import com.zombiesurvival.items.ModItems;
import com.zombiesurvival.proxy.CommonProxy;
import com.zombiesurvival.utils.FuelManager;
import com.zombiesurvival.utils.KeyBindings;
import com.zombiesurvival.utils.KeyInputHandler;
import com.zombiesurvival.utils.crafting.CraftingManager;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@Mod(modid=Main.MODID, name=Main.MODNAME, version=Main.MODVER)
public class Main
{
/**TODO:
* WINDMILLS (3D Modeled with Spinning Rotor).
* Power Systems
* Energy Pipes
* Item Pipes
* Fluid Pipes
* Energy Cables
*/
public static final String MODID = "zombiesurvival";
//Set the "Name" of the mod.
public static final String MODNAME = "Main";
//Set the version of the mod.
public static final String MODVER = "0.0.1 Alpha";
@Instance(value = Main.MODID)
public static Main instance;
//Items
public static Item rifle22;
public static Item bullets22;
public static Item steelIngot;
public static Item brassIngot;
public static Item nickelIngot;
public static Item bronzeIngot;
//Creative Tabs
public static CreativeTabs test = new CreativeTabs("Test") {
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return Items.iron_ingot;
}
};
public static ItemHUDactivator itemHUDactivator;
@SidedProxy(clientSide="com.zombiesurvival.proxy.ClientProxy", serverSide="com.zombiesurvival.proxy.CommonProxy")
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent e)
{
FMLCommonHandler.instance().bus().register(new KeyInputHandler());
KeyBindings.init();
ModItems.init();
ModBlocks.init();
CraftingManager.init();
proxy.registerRenderers();
GameRegistry.registerFuelHandler(new FuelManager());
/**
* to fix
*/
// EntityRegistrar.init();
}
@EventHandler
public void Init(FMLInitializationEvent e)
{
NetworkRegistry.INSTANCE.registerGuiHandler(Main.instance, new ModGuiHandler());
}
private static StatusBarRenderer statusBarRenderer;
@EventHandler
public void postInit(FMLPostInitializationEvent e)
{
}
}
Why am i getting the error i'm really confused.