I want to offer persistant data to an itemstack, but getting npe from some sponge internal.
java.lang.NullPointerException: null
at org.spongepowered.common.data.MemoryDataView.set(MemoryDataView.java:266) ~[MemoryDataView.class:1.12.2-7.0.0-BETA-369]
at org.spongepowered.common.data.MemoryDataView.setMap(MemoryDataView.java:401) ~[MemoryDataView.class:1.12.2-7.0.0-BETA-369]
at org.spongepowered.common.data.MemoryDataView.set(MemoryDataView.java:280) ~[MemoryDataView.class:1.12.2-7.0.0-BETA-369]
at org.spongepowered.common.data.MemoryDataView.set(MemoryDataView.java:256) ~[MemoryDataView.class:1.12.2-7.0.0-BETA-369]
at org.spongepowered.common.data.MemoryDataContainer.set(MemoryDataContainer.java:77) ~[MemoryDataContainer.class:1.12.2-7.0.0-BETA-369]
at org.spongepowered.common.data.MemoryDataContainer.set(MemoryDataContainer.java:82) ~[MemoryDataContainer.class:1.12.2-7.0.0-BETA-369]
at cz.neumimto.rpg.inventory.data.manipulators.EffectsData.toContainer(EffectsData.java:103) ~[EffectsData.class:1.0.10]
at org.spongepowered.common.data.util.DataUtil.getSerializedManipulatorList(DataUtil.java:141) ~[DataUtil.class:1.12.2-7.0.0-BETA-369]
at org.spongepowered.common.data.util.DataUtil.getSerializedManipulatorList(DataUtil.java:127) ~[DataUtil.class:1.12.2-7.0.0-BETA-369]
at net.minecraft.item.ItemStack.resyncCustomToTag(SourceFile:2388) ~[aip.class:?]
at net.minecraft.item.ItemStack.offerCustom(SourceFile:2357) ~[aip.class:?]
at net.minecraft.item.ItemStack.offer(SourceFile:1194) ~[aip.class:?]
at net.minecraft.item.ItemStack.offer(SourceFile:1065) ~[aip.class:?]
at org.spongepowered.api.data.value.mutable.CompositeValueStore.offer(CompositeValueStore.java:270) ~[CompositeValueStore.class:1.12.2-7.0.0-BETA-369]
All relevant code -
Could anyone point out why am i getting this npe?
Please do not link that datamanipulator generator tool, thats not a feedback i want to see, nor its relevant to my question.
May or may not be related but your constructor doesn’t defend against a null argument.
Just change it to this.effects = checkNotNull(effects, "effects");
Also, it probably makes more sense here to use AbstractMappedData since your data is a mapping.
Oh hmm, from the stack trace it looked like it was a DataSerializable class.
I’m wondering whether it could be the data query DataQuery.of(".", "ntrpg:itemeffects"),
maybe just make that DataQuery.of("ItemEffects"), instead
I updated my datamanipulator which now inherits from AbstractMappedData+ your’s suggested changes remove the first parameter from dataquery#of
still getting an error which is not really helpful
Sponge found an unregistered DataRegistration id. Don't worry though!Sponge will
attempt to persist the failed data for future attempts, unlessthe id is added in
'data-to-purge' in the sponge/custom-data.cnf
Unregistered Id : nt-rpg:item_effects
org.spongepowered.api.data.persistence.InvalidDataException: Could not deserialize nt-rpg:item_effects!