Move toTag/fromTag to a higher interface?
Fuyukai opened this issue ยท 2 comments
In one of my BE supertypes, I have an abstract property ala val inv: FixedItemInv
. To save the NBT in my toTag method I have to check if it's a specific subtype or few (if (inv is DirectFixedItemInv) inv.toTag(tag) else if (inv is FullFixedItemInv) inv.toTag(tag) // etc
) which is pretty unweidly (also non-future proof). It would be nice if it was somehow moved into a super interface or a higher up class.
That sounds reasonable - something like:
public interface Saveable {
default CompoundTag toTag() {
return toTag(new CompoundTag());
}
CompoundTag toTag(CompoundTag tag);
void fromTag(CompoundTag tag);
}
and then make all LBA inventory implementations (DirectFixedItemInv, FullFixedItemInv, SimpleFixedFluidInv) implement that?