Posted March 5, 201510 yr This is the code package com.sixonethree.randomutilities.block.tile; import java.util.List; import java.util.UUID; import com.sixonethree.randomutilities.init.ModBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import cpw.mods.fml.common.FMLCommonHandler; public class TileEntityMagicChest extends TileEntity implements IInventory { private String owner; private int facing; private ItemStack stack; public TileEntityMagicChest() { super(); this.owner = ""; } @Override public boolean canUpdate() { return true; } @SuppressWarnings("unchecked") @Override public void updateEntity() { if (this.owner.isEmpty() || this.owner.equalsIgnoreCase("")) return; if (!this.worldObj.isRemote) { List<EntityPlayerMP> players = FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList; for (EntityPlayerMP player : players) { if (player.getUniqueID().equals(UUID.fromString(this.owner))) { if (this.stack != null) { stack.getItem().onUpdate(stack, this.worldObj, player, 0, false); } break; } } } } public void setOwner(String owner) { this.owner = owner; markDirty(); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.owner = compound.hasKey("owner") ? compound.getString("owner") : ""; } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setString("owner", owner); } public int getFacing() { return this.facing; } public void setFacing(int facing2) { this.facing = facing2; } /* IInventory */ @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int slot) { if (slot != 0) return null; return this.stack; } @Override public ItemStack decrStackSize(int slot, int amount) { if (this.stack != null) { this.stack.stackSize -= amount; if (this.stack.stackSize <= 0) this.stack = null; markDirty(); } return this.stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { return slot == 0 ? this.stack : null; } @Override public void setInventorySlotContents(int slot, ItemStack content) { if (slot == 0) this.stack = content; } @Override public String getInventoryName() { return "Magic Chest"; } @Override public boolean isUseableByPlayer(EntityPlayer player) { if (worldObj == null) { return true; } if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { return false; } if (player.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D) return player.getUniqueID().equals(UUID.fromString(this.owner)); return false; } @Override public void openChest() { if (worldObj == null) return; worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.magicChest, 1, 1); } @Override public void closeChest() { if (worldObj == null) return; worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.magicChest, 1, 0); } @Override public boolean isCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } } This is the error java.lang.RuntimeException: class com.sixonethree.randomutilities.block.tile.TileEntityMagicChest is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:96) ~[TileEntity.class:?] at com.sixonethree.randomutilities.block.tile.TileEntityMagicChest.writeToNBT(TileEntityMagicChest.java:55) ~[TileEntityMagicChest.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:395) [AnvilChunkLoader.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:204) [AnvilChunkLoader.class:?] at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:276) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:329) [ChunkProviderServer.class:?] at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:863) [WorldServer.class:?] at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:374) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:640) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:489) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:756) [MinecraftServer$2.class:?]
March 5, 201510 yr You need to register your TileEntity using GameRegistry.registerTileEntity . Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
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.