So I recently went over from my old method of detecting items on the ground, to a painful Tile Entity method.
I was trying to make something like the Runic Altar from botania - If there are items on the altar and your hand has no item in it one of the items will be added to your inventory.
I have gotten this error (No crash), items are being taken just fine, but I couldn't make it give the items back.
Error:
[14:25:21] [Server thread/ERROR] [FML]: A TileEntity type com.outlookphone.jartm.tileentity.TileGammaInfuser has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.RuntimeException: class com.outlookphone.jartm.tileentity.TileGammaInfuser is missing a mapping! This is a bug!
at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:94) ~[TileEntity.class:?]
at com.outlookphone.jartm.common.base.TileMod.writeToNBT(TileMod.java:24) ~[TileMod.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.tick(MinecraftServer.java:691) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
TileMod.writeToNBT():
@Override
public void writeToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeToNBT(par1nbtTagCompound);
You need to register your TileEntity class using GameRegistry.registerTileEntity.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
So I recently went over from my old method of detecting items on the ground, to a painful Tile Entity method.
I was trying to make something like the Runic Altar from botania - If there are items on the altar and your hand has no item in it one of the items will be added to your inventory.
I have gotten this error (No crash), items are being taken just fine, but I couldn't make it give the items back.
Error:
java.lang.RuntimeException: class com.outlookphone.jartm.tileentity.TileGammaInfuser is missing a mapping! This is a bug!
at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:94) ~[TileEntity.class:?]
at com.outlookphone.jartm.common.base.TileMod.writeToNBT(TileMod.java:24) ~[TileMod.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.tick(MinecraftServer.java:691) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
TileMod.writeToNBT():
@Override
public void writeToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeToNBT(par1nbtTagCompound);
writeCustomNBT(par1nbtTagCompound);
}
BlockGammaInfuser.onBlockActivated()
@Override
public boolean onBlockActivated(World par1World, BlockPos pos, IBlockState state, EntityPlayer par5EntityPlayer, EnumFacing side, float par7, float par8, float par9)
{
TileGammaInfuser altar = (TileGammaInfuser) par1World.getTileEntity(pos);
boolean did = false;
for(int i = 0; i < (altar.getSizeInventory()); i++)
{
if(!did)
{
if(altar.getStackInSlot(i) == null)
{
System.out.println(i + " is not null.");
if(par5EntityPlayer.getCurrentEquippedItem() != null)
{
System.out.println("Player is not equipped with null.");
did = true;
ItemStack stackToAdd = par5EntityPlayer.getCurrentEquippedItem().copy();
ItemStack currentlyEquipped = par5EntityPlayer.getCurrentEquippedItem();
currentlyEquipped.stackSize--;
par5EntityPlayer.setCurrentItemOrArmor(0, currentlyEquipped);
stackToAdd.stackSize = 1;
altar.setInventorySlotContents(i, stackToAdd);
}
}
else if((par5EntityPlayer.getCurrentEquippedItem() == null) && (altar.getStackInSlot(i) != null))
{
System.out.println("Player is not equipped with null.");
ItemStack stackToAdd = altar.getStackInSlot(i).copy();
ItemStack stackToRemove = stackToAdd.copy();
stackToRemove.stackSize = -1;
altar.setInventorySlotContents(i, stackToRemove);
par5EntityPlayer.inventory.addItemStackToInventory(stackToAdd);
did = true;
}
}
}
return false;
}
All help, including general formatting help is all greatly appreciated.
You need to register your TileEntity class using GameRegistry.registerTileEntity.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.