From c06097f2871d98adf0bacec782f485f23a3c0511 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 4 Dec 2021 13:07:18 +0100 Subject: [PATCH] fixed stuff not saving in block entities Closes #101 --- src/main/java/de/ellpeck/prettypipes/Utility.java | 2 +- .../java/de/ellpeck/prettypipes/pipe/PipeBlockEntity.java | 6 +++--- .../prettypipes/pressurizer/PressurizerBlockEntity.java | 6 +++--- .../prettypipes/terminal/CraftingTerminalBlockEntity.java | 4 ++-- .../prettypipes/terminal/ItemTerminalBlockEntity.java | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/ellpeck/prettypipes/Utility.java b/src/main/java/de/ellpeck/prettypipes/Utility.java index 01a0d1d..f851dac 100644 --- a/src/main/java/de/ellpeck/prettypipes/Utility.java +++ b/src/main/java/de/ellpeck/prettypipes/Utility.java @@ -113,7 +113,7 @@ public final class Utility { public static void sendBlockEntityToClients(BlockEntity tile) { var world = (ServerLevel) tile.getLevel(); 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) e.connection.send(packet); } diff --git a/src/main/java/de/ellpeck/prettypipes/pipe/PipeBlockEntity.java b/src/main/java/de/ellpeck/prettypipes/pipe/PipeBlockEntity.java index 505c532..7d29092 100644 --- a/src/main/java/de/ellpeck/prettypipes/pipe/PipeBlockEntity.java +++ b/src/main/java/de/ellpeck/prettypipes/pipe/PipeBlockEntity.java @@ -88,7 +88,8 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC } @Override - public CompoundTag save(CompoundTag compound) { + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); compound.put("modules", this.modules.serializeNBT()); compound.putInt("module_drop_check", this.moduleDropCheck); compound.put("requests", Utility.serializeAll(this.craftIngredientRequests)); @@ -102,7 +103,6 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC results.add(nbt); } compound.put("craft_results", results); - return super.save(compound); } @Override @@ -126,7 +126,7 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC @Override public CompoundTag getUpdateTag() { // sync pipe items on load - var nbt = this.save(new CompoundTag()); + var nbt = this.saveWithoutMetadata(); nbt.put("items", Utility.serializeAll(this.getItems())); return nbt; } diff --git a/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlockEntity.java b/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlockEntity.java index d05e4d4..17315cf 100644 --- a/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlockEntity.java +++ b/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlockEntity.java @@ -58,9 +58,9 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider, } @Override - public CompoundTag save(CompoundTag compound) { + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); compound.putInt("energy", this.getEnergy()); - return super.save(compound); } @Override @@ -71,7 +71,7 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider, @Override public CompoundTag getUpdateTag() { - return this.save(new CompoundTag()); + return this.saveWithoutMetadata(); } @Override diff --git a/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalBlockEntity.java b/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalBlockEntity.java index 41c8df0..35ceb2a 100644 --- a/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalBlockEntity.java +++ b/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalBlockEntity.java @@ -135,9 +135,9 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity { } @Override - public CompoundTag save(CompoundTag compound) { + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); compound.put("craft_items", this.craftItems.serializeNBT()); - return super.save(compound); } @Override diff --git a/src/main/java/de/ellpeck/prettypipes/terminal/ItemTerminalBlockEntity.java b/src/main/java/de/ellpeck/prettypipes/terminal/ItemTerminalBlockEntity.java index 636c8c0..cc61949 100644 --- a/src/main/java/de/ellpeck/prettypipes/terminal/ItemTerminalBlockEntity.java +++ b/src/main/java/de/ellpeck/prettypipes/terminal/ItemTerminalBlockEntity.java @@ -224,10 +224,10 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect } @Override - public CompoundTag save(CompoundTag compound) { + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); compound.put("items", this.items.serializeNBT()); compound.put("requests", Utility.serializeAll(this.existingRequests)); - return super.save(compound); } @Override