Jump to content

[1.7.10] Save TileEntity data to NBT


shadowfacts

Recommended Posts

In my mod, EnFusion (http://github.com/shadowfacts/enfusion), I have a RF generating block which is a solar panel. For some unknown reason the data in my TileEntity won't get saved to NBT. Here's the TileEntitySolarPanel class: http://github.com/shadowfacts/EnFusion/blob/master/src/main/java/net/shadowfacts/enfusion/machine/generator/solar/TileEntitySolarPanel.java.

 

Every time the addDataToNBT is called, Minecraft spews out this message to the log:

[21:33:53] [server thread/ERROR] [FML]: A TileEntity type net.shadowfacts.enfusion.machine.generator.solar.TileEntitySolarPanel has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.RuntimeException: class net.shadowfacts.enfusion.machine.generator.solar.TileEntitySolarPanel is missing a mapping! This is a bug!
at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:96) ~[TileEntity.class:?]
at net.shadowfacts.shadowcore.tileentity.BaseModTileEntity.writeToNBT(BaseModTileEntity.java:20) ~[baseModTileEntity.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.safeSaveChunk(ChunkProviderServer.java:287) [ChunkProviderServer.class:?]
at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:340) [ChunkProviderServer.class:?]
at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:862) [WorldServer.class:?]
at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:370) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:113) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]

 

Note: My tile entity class extends a custom modified TileEntity which is here: https://github.com/shadowfacts/ShadowCore/blob/master/src/main/java/net/shadowfacts/shadowcore/tileentity/BaseModTileEntity.java.

 

I'm not sure but I think the problem is when Minecraft tries to turn the name of my tile entity into a string at line 92 of the default TileEntity.java. If anyone knows what I'm doing wrong, help would be greatly appreciated :).

 

P.S. Feel free to submit a pull request on GitHub (http://github.com/shadowfacts/EnFusion/pulls).

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

GameRegistry.registerTileEntity(...)?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Hi

 

I recently looked into your code on github.

 

Since I'm new-ish, please forgive if I am wrong.

 

Personally, I use the method

public void writeToNBT(NBTTagCompound nbt)

.

Why do you use 'addNBT'?

 

Sometimes logging would help...

 

Hope this was helpful

 

Sincerely -pick

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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