use of net.minecraft.util.registry.RegistryKey in project EtherealInventories by EnnuiL.
the class EtherinvStorageComponent method readFromNbt.
@Override
public void readFromNbt(NbtCompound nbt) {
map.clear();
if (nbt.contains("EtherinvStorage", NbtCompound.LIST_TYPE)) {
NbtList nbtList = nbt.getList("EtherinvStorage", NbtCompound.COMPOUND_TYPE);
for (int i = 0; i < nbtList.size(); i++) {
NbtCompound compound = nbtList.getCompound(i);
if (compound.containsUuid("UUID") && compound.contains("BlockPos", NbtCompound.INT_ARRAY_TYPE) && compound.contains("Dimension", NbtCompound.STRING_TYPE) && compound.contains("IsLoaded", NbtCompound.BYTE_TYPE)) {
int[] blockPosList = compound.getIntArray("BlockPos");
BlockPos blockPos = new BlockPos(blockPosList[0], MathHelper.clamp(blockPosList[1], -2.0E7, 2.0E7), blockPosList[2]);
Optional<RegistryKey<World>> optionalDimension = World.CODEC.parse(NbtOps.INSTANCE, compound.get("Dimension")).result();
RegistryKey<World> dimension = null;
if (optionalDimension.isPresent()) {
dimension = optionalDimension.get();
}
Optional<UUID> owner = Optional.empty();
if (compound.containsUuid("Owner")) {
owner = Optional.of(compound.getUuid("Owner"));
}
boolean loaded = compound.getBoolean("IsLoaded");
map.put(compound.getUuid("UUID"), new EtherinvStorage(blockPos, dimension, owner, loaded));
}
}
}
// World.CODEC.parse(NbtOps.INSTANCE, nbt.get("LodestoneDimension")).result();
}
Aggregations