Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Zerahi

Members
  • Joined

  • Last visited

Everything posted by Zerahi

  1. Been working on this for hours still cant get it to work, it holds the item and displays the entity fine, just wont save inventory to and from nbt, looked up about 5 examples and most are similar so i don't get what i'm missing. public class TileEntityAltar extends TileEntity { public ItemStack display; public EntityItem entity; @Override public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new SPacketUpdateTileEntity(pos, 0, tag); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { super.onDataPacket(net, packet); readFromNBT(packet.getNbtCompound()); } @Override public NBTTagCompound getUpdateTag() { return this.writeToNBT(new NBTTagCompound()); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.display.deserializeNBT(compound.getCompoundTag("ItemHandler")); if (this.entity == null && this.display != null) this.setDisplayItem(worldObj, pos, null, null, null); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound = super.writeToNBT(compound); compound.setTag("ItemHandler", this.display.serializeNBT()); return compound; } public void change() {this.markDirty();} public void setDisplayItem(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, ItemStack heldItem) { if (!worldObj.isRemote) { entity = new EntityItemProxy(worldObj, pos.getX(), pos.getY(), pos.getZ(), display.copy()); entity.setVelocity(0, 0, 0); entity.setNoDespawn(); entity.setPositionAndRotation(pos.getX()+.5, pos.getY()+1d, pos.getZ()+.5, 0, 1); worldObj.spawnEntityInWorld(entity); } } public void removeItem(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn) { if (!worldIn.isRemote) { playerIn.entityDropItem(display, 1); if (entity != null)entity.setDead(); display = null; } } } from the block activation public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity te = worldIn.getTileEntity(pos); if (((TileEntityAltar) te).display == null) { if (Ref.altarlist(heldItem)) { ((TileEntityAltar) te).display = heldItem.copy(); --heldItem.stackSize; ((TileEntityAltar) te).setDisplayItem(worldIn, pos, state, playerIn, heldItem); ((TileEntityAltar) te).change(); } } else { ((TileEntityAltar) te).removeItem(worldIn, pos, state, playerIn); ((TileEntityAltar) te).change(); } return true; } error Failed to load data for block entity tileentityaltar java.lang.NullPointerException at com.ravvoid.init.tileentity.TileEntityAltar.readFromNBT(TileEntityAltar.java:60) ~[TileEntityAltar.class:?] at net.minecraft.tileentity.TileEntity.func_190200_a(TileEntity.java:137) [TileEntity.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:515) [AnvilChunkLoader.class:?] at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:96) [ChunkIOProvider.class:?] at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94) [ChunkIOExecutor.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:92) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:141) [ChunkProviderServer.class:?] at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:336) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) [integratedServer.class:?] at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_91] [11:34:57] [server thread/ERROR] [FML]: A TileEntity tileentityaltar(com.ravvoid.init.tileentity.TileEntityAltar) has thrown an exception during loading, its state cannot be restored. Report this to the mod author java.lang.NullPointerException at com.ravvoid.init.tileentity.TileEntityAltar.readFromNBT(TileEntityAltar.java:60) ~[TileEntityAltar.class:?] at net.minecraft.tileentity.TileEntity.func_190200_a(TileEntity.java:137) [TileEntity.class:?] at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:515) [AnvilChunkLoader.class:?] at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:96) [ChunkIOProvider.class:?] at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94) [ChunkIOExecutor.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:92) [ChunkProviderServer.class:?] at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:141) [ChunkProviderServer.class:?] at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:336) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) [integratedServer.class:?] at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
  2. i cant get mine to work either, tried setting what you said overridden in my tile entity extended from TileEntity but writeInternal is set to private. or do i have to make my own TileEentity class. cant really find any examples of working code either, im just trying to store one item and every other part of my code works but this.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.