Posted August 28, 20187 yr Hello! I have an issue with a TileEntity writing to nbt but cant quite figure out where the issue lies. Beneath is the runtime exception. Spoiler [23:37:09] [Server thread/ERROR] [FML]: A TileEntity type chokemonster.gleam.objects.blocks.infuser.te.TileEntityInfuser has throw an exception trying to write state. It will not persist. Report this to the mod author java.lang.RuntimeException: class chokemonster.gleam.objects.blocks.infuser.te.TileEntityInfuser is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:89) ~[TileEntity.class:?] at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:80) ~[TileEntity.class:?] at chokemonster.gleam.objects.blocks.infuser.te.TileEntityInfuser.writeToNBT(TileEntityInfuser.java:89) ~[TileEntityInfuser.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:414) [AnvilChunkLoader.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:185) [AnvilChunkLoader.class:?] at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:214) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:242) [ChunkProviderServer.class:?] at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:1061) [WorldServer.class:?] at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:468) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.saveAllWorlds(IntegratedServer.java:274) [IntegratedServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:177) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_181] I've gone through the class for this TileEntity and it seems to be as it should. Beneath is the class for the TileEntity. Spoiler package chokemonster.gleam.objects.blocks.infuser.te; import javax.annotation.Nullable; import chokemonster.gleam.init.BlockInit; import chokemonster.gleam.init.ItemInit; import net.minecraft.client.particle.Particle; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityInfuser extends TileEntity implements ITickable { private ItemStackHandler inventory = new ItemStackHandler(1) { @Override public int getSlotLimit(int slot) { return 1; }; }; int tick = 0; boolean initialized = false; boolean enabled = false; @Override public void update() { if(enabled) { if (!world.isRemote) { BlockPos cagePos = findCage(); WorldServer newWorld = (WorldServer) world; newWorld.spawnParticle(EnumParticleTypes.END_ROD, pos.getX() + .5D, pos.getY() + .5D, pos.getZ() + .5D, 1, 0, 0, 0, 0.1D, cagePos.getX(), cagePos.getY(), cagePos.getZ()); } tick++; if(tick == 100) { tick = 0; execute(); enabled = false; } } } private BlockPos findCage() { BlockPos[] cardinals = {pos.north(2), pos.east(2), pos.south(2), pos.west(2)}; for (int i = 0; i < cardinals.length; i++) { if(world.getBlockState(cardinals) == BlockInit.CAGE) return cardinals; } return pos.up(); } private void execute() { inventory.extractItem(0, 1, false); } public void setEnabled(boolean state) { enabled = state; } public boolean getEnabled() { return enabled; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("inventory", inventory.serializeNBT()); return super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { inventory.deserializeNBT(compound.getCompoundTag("inventory")); super.readFromNBT(compound); } @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T)inventory : super.getCapability(capability, facing); }} I would really appreciate any help or even a look at these files. Thank you in advance! Edited August 28, 20187 yr by DiscardedMarrow
August 28, 20187 yr Author Sorry! Forgot to register the tile entity, the TileEntity doesn't seem tothrow an error anymore and this topic can be closed.
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.