Meldexun Posted February 9, 2019 Posted February 9, 2019 (edited) Hi there, I want to save 2 BlockPos for a player. They don't need to be saved when leaving and reentering the world. I thought of adding a Capability to the player but then i have to save something as NBT. Is there an easier way to save 2 BlockPos for a player? Thanks for the help. Edited July 15, 2019 by Meldexun Quote
Meldexun Posted February 10, 2019 Author Posted February 10, 2019 I just need to save the 2 BlockPos on server side temporarily. But is this really the only/best way? Quote
Meldexun Posted February 10, 2019 Author Posted February 10, 2019 Yes I don't need to save the data. But how can I stop it from saving NBT data. This is my provider class: public class StructureDataProvider implements ICapabilitySerializable<NBTBase> { @CapabilityInject(IStructureData.class) public static final Capability<IStructureData> STRUCTURE_DATA = null; private IStructureData instance = STRUCTURE_DATA.getDefaultInstance(); @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == STRUCTURE_DATA; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { return capability == STRUCTURE_DATA ? STRUCTURE_DATA.<T> cast(this.instance) : null; } @Override public NBTBase serializeNBT() { return STRUCTURE_DATA.getStorage().writeNBT(STRUCTURE_DATA, this.instance, null); } @Override public void deserializeNBT(NBTBase nbt) { STRUCTURE_DATA.getStorage().readNBT(STRUCTURE_DATA, this.instance, null, nbt); } } and this is my storage class: public class StructureDataStorage implements IStorage<IStructureData> { @Override public NBTBase writeNBT(Capability<IStructureData> capability, IStructureData instance, EnumFacing side) { return new NBTTagInt(0); } @Override public void readNBT(Capability<IStructureData> capability, IStructureData instance, EnumFacing side, NBTBase nbt) { } } What i mean is that it now saves a NBTTagInt which is pointless because i don't use/need it. But I have to return a NBTBase. Can i change something to avoid this unnecessary data saving. Quote
Meldexun Posted February 10, 2019 Author Posted February 10, 2019 Oh ok. Sounds logical. Thank you! Quote
Meldexun Posted February 10, 2019 Author Posted February 10, 2019 (edited) One last question. Do i still need my storage class? Because i don't use it but i need to pass an instance of a storage class when registering my Capability. Edited February 10, 2019 by Meldexun Quote
Recommended Posts
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.