fixed stuff not saving in block entities

Closes #101
This commit is contained in:
Ell 2021-12-04 13:07:18 +01:00
parent c1695f7b78
commit c06097f287
5 changed files with 11 additions and 11 deletions

View file

@ -113,7 +113,7 @@ public final class Utility {
public static void sendBlockEntityToClients(BlockEntity tile) { public static void sendBlockEntityToClients(BlockEntity tile) {
var world = (ServerLevel) tile.getLevel(); var world = (ServerLevel) tile.getLevel();
var entities = world.getChunkSource().chunkMap.getPlayers(new ChunkPos(tile.getBlockPos()), false); var entities = world.getChunkSource().chunkMap.getPlayers(new ChunkPos(tile.getBlockPos()), false);
var packet = ClientboundBlockEntityDataPacket.create(tile, t -> t.save(new CompoundTag())); var packet = ClientboundBlockEntityDataPacket.create(tile, BlockEntity::saveWithoutMetadata);
for (var e : entities) for (var e : entities)
e.connection.send(packet); e.connection.send(packet);
} }

View file

@ -88,7 +88,8 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
} }
@Override @Override
public CompoundTag save(CompoundTag compound) { public void saveAdditional(CompoundTag compound) {
super.saveAdditional(compound);
compound.put("modules", this.modules.serializeNBT()); compound.put("modules", this.modules.serializeNBT());
compound.putInt("module_drop_check", this.moduleDropCheck); compound.putInt("module_drop_check", this.moduleDropCheck);
compound.put("requests", Utility.serializeAll(this.craftIngredientRequests)); compound.put("requests", Utility.serializeAll(this.craftIngredientRequests));
@ -102,7 +103,6 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
results.add(nbt); results.add(nbt);
} }
compound.put("craft_results", results); compound.put("craft_results", results);
return super.save(compound);
} }
@Override @Override
@ -126,7 +126,7 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
@Override @Override
public CompoundTag getUpdateTag() { public CompoundTag getUpdateTag() {
// sync pipe items on load // sync pipe items on load
var nbt = this.save(new CompoundTag()); var nbt = this.saveWithoutMetadata();
nbt.put("items", Utility.serializeAll(this.getItems())); nbt.put("items", Utility.serializeAll(this.getItems()));
return nbt; return nbt;
} }

View file

@ -58,9 +58,9 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider,
} }
@Override @Override
public CompoundTag save(CompoundTag compound) { public void saveAdditional(CompoundTag compound) {
super.saveAdditional(compound);
compound.putInt("energy", this.getEnergy()); compound.putInt("energy", this.getEnergy());
return super.save(compound);
} }
@Override @Override
@ -71,7 +71,7 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider,
@Override @Override
public CompoundTag getUpdateTag() { public CompoundTag getUpdateTag() {
return this.save(new CompoundTag()); return this.saveWithoutMetadata();
} }
@Override @Override

View file

@ -135,9 +135,9 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
} }
@Override @Override
public CompoundTag save(CompoundTag compound) { public void saveAdditional(CompoundTag compound) {
super.saveAdditional(compound);
compound.put("craft_items", this.craftItems.serializeNBT()); compound.put("craft_items", this.craftItems.serializeNBT());
return super.save(compound);
} }
@Override @Override

View file

@ -224,10 +224,10 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
} }
@Override @Override
public CompoundTag save(CompoundTag compound) { public void saveAdditional(CompoundTag compound) {
super.saveAdditional(compound);
compound.put("items", this.items.serializeNBT()); compound.put("items", this.items.serializeNBT());
compound.put("requests", Utility.serializeAll(this.existingRequests)); compound.put("requests", Utility.serializeAll(this.existingRequests));
return super.save(compound);
} }
@Override @Override