I have spent way, way too much time of my weekend struggling through a custom-data problem.
I have managed to examine different github sources for similarities and differences, and managed to make the FakeData example work on both players and particular block-tiles, and have stored other simple data-constructs (data objects with various strings, ints, booleans) successfully on said players and tile entities, with data persisting in the map data files as expected by using mostly the FakeData code and no additional deserializers/serializers and whatever that warning message in the startup log is about not extending an abstractdatabuilder not seeming to interfereâŚ
For example, I can make a custom data with two booleans do exactly what I want, and persist across server shutdowns just fine. I can then add a string everywhere in the files necessary to add a new part, and it works fine. But, if I use a non-primative Set<UUID>, thats where the basic working system falls apart (and I sorta expected it would)
System.out.println("Creating a default lock data"); FramelockData fld = new FramelockData(ds, false, false); System.out.println("Offer=" + bs.getFinal().getLocation().get().offer(fld));
I create and then offer separately to isolate processes, and see that there is no problem with the data creation, and the offer is even returned back as a success, but then immediately the log errors:
> [04:45:00] [Server thread/ERROR] [FML/]: A TileEntity type net.minecraft.tileentity.TileEntityChest has throw an exception trying to write state. It will not persist. Report this to the mod author
> java.lang.IllegalArgumentException: Unable to translate object to NBTBase: f2657b0b-fcb6-4d74-af49-3eb629035666
> at org.spongepowered.common.data.persistence.NbtTranslator.getBaseFromObject(NbtTranslator.java:166) ~[NbtTranslator.class:1.8.9-1808-4.1.0-BETA-1250]
> at org.spongepowered.common.data.persistence.NbtTranslator.getBaseFromObject(NbtTranslator.java:142) ~[NbtTranslator.class:1.8.9-1808-4.1.0-BETA-1250]
> at org.spongepowered.common.data.persistence.NbtTranslator.getBaseFromObject(NbtTranslator.java:152) ~[NbtTranslator.class:1.8.9-1808-4.1.0-BETA-1250]
> at org.spongepowered.common.data.persistence.NbtTranslator.containerToCompound(NbtTranslator.java:91) ~[NbtTranslator.class:1.8.9-1808-4.1.0-BETA-1250]
> at org.spongepowered.common.data.persistence.NbtTranslator.containerToCompound(NbtTranslator.java:72) ~[NbtTranslator.class:1.8.9-1808-4.1.0-BETA-1250]
> at org.spongepowered.common.data.persistence.NbtTranslator.translateData(NbtTranslator.java:287) ~[NbtTranslator.class:1.8.9-1808-4.1.0-BETA-1250]
> at net.minecraft.tileentity.TileEntity.writeToNbt(TileEntity.java:247) ~[akw.class:?]
> at net.minecraft.tileentity.TileEntity.handler$onWriteToNBT$0(TileEntity.java:191) ~[akw.class:?]
> at net.minecraft.tileentity.TileEntity.func_145841_b(TileEntity.java) ~[akw.class:?]
> at net.minecraft.tileentity.TileEntityLockable.func_145841_b(TileEntityLockable.java:23) ~[alk.class:?]
> at net.minecraft.tileentity.TileEntityChest.func_145841_b(TileEntityChest.java:153) ~[aky.class:?]
> at net.minecraft.world.chunk.storage.AnvilChunkLoader.func_75820_a(AnvilChunkLoader.java:368) [anj.class:?]
> at net.minecraft.world.chunk.storage.AnvilChunkLoader.func_75816_a(AnvilChunkLoader.java:165) [anj.class:?]
> at net.minecraft.world.gen.ChunkProviderServer.func_73242_b(ChunkProviderServer.java:238) [ld.class:?]
> at net.minecraft.world.gen.ChunkProviderServer.func_73151_a(ChunkProviderServer.java:298) [ld.class:?]
> at net.minecraft.world.WorldServer.func_73044_a(WorldServer.java:905) [le.class:?]
> at net.minecraft.server.MinecraftServer.func_71267_a(MinecraftServer.java:366) [MinecraftServer.class:?]
> at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:628) [MinecraftServer.class:?]
> at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:481) [MinecraftServer.class:?]
> at java.lang.Thread.run(Unknown Source) [?:1.8.0_74]
> [04:45:45] [Server thread/DEBUG] [FML/]: Gathering id map for writing to world save world
I have deteremined from what I can find in General that it has something to do with the dataview , and the fact that a Set is of course not a primative object, but I have not found anything that addresses how to handle a set object going back or forth (No map chunk data nbt is modified so clearly its erroring when trying to save it, not just having problems decoding what a chunk of bytes means when reading)
Note that I am not married to the use of a Set<UUID> if there is some other type of collection/group object that is much easier for the custom data system to work with, I can try to change that, but I dont expect any grouping object to avoid this same problem since they are not primatives themselves, and a similar approach would be required to do whatever is necessary to convert a Set to an nbt friendly dataview/datacontainer system if it was a list, etc.
Can someone please point me in the right direction and with some sample-code to use as to what my system is missing that will let me pass that Set<UUID> back and forth in my data?
My mutable and immutable data, builder, datamanipulatorbuilder, keys and a query-constants files are shown in the pastebin link. Thank you in advanceâŚ
@Listener
public void onPreInit(GamePreInitializationEvent event) {
Sponge.getDataManager().register(FramelockData.class, ImmutableFramelockData.class, new FramelockDataManipulatorBuilder());
}
