I’ve created my own custom data classes and have successfully been able to store custom data to an item stack.
I now also want to store custom data to a block.
I know blocks themselves can’t store custom data themselves (unless they are tile entities), so as far as I am aware the best way to do this is to store data to the chunk instead and just include info about the block’s coordinates in your data somehow.
However I don’t know how to do this.
At first I noticed that Chunk seems to have methods similar to the ones I used to store data in ItemStack - namely getOrCreate, offer, and get(Key). The chunk’s methods looked exactly the same as for itemstack except they take in a Vector3i named “coordinates” as a parameter as well. I assumed this means that Sponge themselves implemented a system where you can store data in a chunk that also includes coordinates.
Note: Are the coordinates absolute block coordinates or relative coordinates within the chunk? I tried both and had the same issue I’m about to describe.
However, when I use the getOrCreateMethod, I got an AbstractMethodError.
net/minecraft/world/chunk/Chunk.getOrCreate(IIILjava/lang/Class;)Ljava/util/Optional; is abstract
Can anyone explain why I’m getting this error and how I should be storing custom data inside a chunk?
Edit: I get the same error when using the Chunk.get(coordinates, key) method.