diff --git a/versions/1.12.2/src/main/resources/pack.mcmeta b/versions/1.12.2/src/main/resources/pack.mcmeta index 531a377..da04c20 100644 --- a/versions/1.12.2/src/main/resources/pack.mcmeta +++ b/versions/1.12.2/src/main/resources/pack.mcmeta @@ -1,8 +1,6 @@ { "pack": { "description": "${mod_name} Resources", - "pack_format": ${ - resource_pack_format -} -} + "pack_format": ${resource_pack_format} + } } \ No newline at end of file diff --git a/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileEnergyPylonFlux.java b/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileEnergyPylonFlux.java index 11edcfd..f612605 100644 --- a/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileEnergyPylonFlux.java +++ b/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileEnergyPylonFlux.java @@ -28,6 +28,8 @@ public class TileEnergyPylonFlux extends TileEnergyPylon implements IFluxProxyHo private final EnergyPylonTransferHandler transferHandler = new EnergyPylonTransferHandler(); private ProxyFluxDevice fluxProxyDevice; + private CompoundTag pendingFluxTag; + private byte pendingFluxTagType; private int fluxTick; public TileEnergyPylonFlux(BlockPos pos, BlockState state) { @@ -53,6 +55,11 @@ public void tick() { @Override public void onLoad() { getOrCreateFluxProxyDevice().setLevel(); + // Process any pending flux tag data that was received before level was initialized + if (pendingFluxTag != null) { + getOrCreateFluxProxyDevice().readCustomTag(pendingFluxTag, pendingFluxTagType); + pendingFluxTag = null; + } super.onLoad(); } @@ -79,6 +86,7 @@ public void writeExtraNBT(CompoundTag tag) { @Override public void readExtraNBT(CompoundTag tag) { super.readExtraNBT(tag); + getOrCreateFluxProxyDevice().setLevel(); getOrCreateFluxProxyDevice().readCustomTag(tag, FluxConstants.NBT_SAVE_ALL); } @@ -99,6 +107,7 @@ public ClientboundBlockEntityDataPacket getUpdatePacket() { @Override public void handleUpdateTag(@NotNull CompoundTag tag) { super.handleUpdateTag(tag); + getOrCreateFluxProxyDevice().setLevel(); getOrCreateFluxProxyDevice().readCustomTag(tag, FluxConstants.NBT_TILE_UPDATE); } @@ -138,7 +147,14 @@ public void writeFluxTag(CompoundTag tag, byte type) { @Override public void readFluxTag(CompoundTag tag, byte type) { - getOrCreateFluxProxyDevice().readCustomTag(tag, type); + ProxyFluxDevice device = getOrCreateFluxProxyDevice(); + device.setLevel(); + if (device.getLevel() == null) { + pendingFluxTag = tag.copy(); + pendingFluxTagType = type; + } else { + device.readCustomTag(tag, type); + } } @NotNull diff --git a/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileFluxAccessorFlux.java b/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileFluxAccessorFlux.java index fd77ab9..382b642 100644 --- a/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileFluxAccessorFlux.java +++ b/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileFluxAccessorFlux.java @@ -32,6 +32,8 @@ public class TileFluxAccessorFlux extends AENetworkBlockEntity implements IFluxP private final FluxAccessorTransferHandler transferHandler = new FluxAccessorTransferHandler(); private ProxyFluxDevice fluxProxyDevice; + private CompoundTag pendingFluxTag; + private byte pendingFluxTagType; public TileFluxAccessorFlux(BlockPos pos, BlockState state) { super(Objects.requireNonNull(MoreFluxStorageContent.getFluxAccessorFluxBlockEntityType(), "Flux accessor block entity type is not registered"), pos, state); @@ -53,6 +55,11 @@ public void tick() { @Override public void onLoad() { getOrCreateFluxProxyDevice().setLevel(); + // Process any pending flux tag data that was received before level was initialized + if (pendingFluxTag != null) { + getOrCreateFluxProxyDevice().readCustomTag(pendingFluxTag, pendingFluxTagType); + pendingFluxTag = null; + } super.onLoad(); } @@ -98,6 +105,7 @@ public ClientboundBlockEntityDataPacket getUpdatePacket() { @Override public void handleUpdateTag(@NotNull CompoundTag tag) { super.handleUpdateTag(tag); + getOrCreateFluxProxyDevice().setLevel(); getOrCreateFluxProxyDevice().readCustomTag(tag, FluxConstants.NBT_TILE_UPDATE); } @@ -135,7 +143,14 @@ public void writeFluxTag(CompoundTag tag, byte type) { @Override public void readFluxTag(CompoundTag tag, byte type) { - getOrCreateFluxProxyDevice().readCustomTag(tag, type); + ProxyFluxDevice device = getOrCreateFluxProxyDevice(); + device.setLevel(); + if (device.getLevel() == null) { + pendingFluxTag = tag.copy(); + pendingFluxTagType = type; + } else { + device.readCustomTag(tag, type); + } } @Override diff --git a/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileInductionPortFlux.java b/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileInductionPortFlux.java index f48eb94..3d41ebe 100644 --- a/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileInductionPortFlux.java +++ b/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileInductionPortFlux.java @@ -35,6 +35,8 @@ public class TileInductionPortFlux extends TileEntityInductionPort implements IF private final InductionPortTransferHandler transferHandler = new InductionPortTransferHandler(); private ProxyFluxDevice fluxProxyDevice; + private CompoundTag pendingFluxTag; + private byte pendingFluxTagType; public TileInductionPortFlux(BlockPos pos, BlockState state) { super(Utils.trigger(pos), state); @@ -80,6 +82,11 @@ public void load(@NotNull CompoundTag tag) { @Override public void onLoad() { getOrCreateFluxProxyDevice().setLevel(); + // Process any pending flux tag data that was received before level was initialized + if (pendingFluxTag != null) { + getOrCreateFluxProxyDevice().readCustomTag(pendingFluxTag, pendingFluxTagType); + pendingFluxTag = null; + } super.onLoad(); } @@ -112,6 +119,7 @@ public ClientboundBlockEntityDataPacket getUpdatePacket() { @Override public void handleUpdateTag(@NotNull CompoundTag tag) { super.handleUpdateTag(tag); + getOrCreateFluxProxyDevice().setLevel(); getOrCreateFluxProxyDevice().readCustomTag(tag, FluxConstants.NBT_TILE_UPDATE); } @@ -151,7 +159,14 @@ public void writeFluxTag(CompoundTag tag, byte type) { @Override public void readFluxTag(CompoundTag tag, byte type) { - getOrCreateFluxProxyDevice().readCustomTag(tag, type); + ProxyFluxDevice device = getOrCreateFluxProxyDevice(); + device.setLevel(); + if (device.getLevel() == null) { + pendingFluxTag = tag.copy(); + pendingFluxTagType = type; + } else { + device.readCustomTag(tag, type); + } } public InteractionResult onSneakRightClick(Player player) { diff --git a/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/util/ProxyFluxDevice.java b/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/util/ProxyFluxDevice.java index b205177..230dba3 100644 --- a/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/util/ProxyFluxDevice.java +++ b/versions/1.20.1/src/main/java/com/circulation/more_flux_storage/util/ProxyFluxDevice.java @@ -23,9 +23,9 @@ public ProxyFluxDevice(Host host, BlockEntityType type, BlockPos pos, BlockSt } public void markChunkUnsaved() { - assert this.host.getTE().getLevel() != null; - - this.host.getTE().getLevel().getChunkAt(this.worldPosition).setUnsaved(true); + if (this.host.getTE().getLevel() != null) { + this.host.getTE().getLevel().getChunkAt(this.worldPosition).setUnsaved(true); + } } public void setLevel() { diff --git a/versions/1.20.1/src/main/resources/pack.mcmeta b/versions/1.20.1/src/main/resources/pack.mcmeta index 531a377..da04c20 100644 --- a/versions/1.20.1/src/main/resources/pack.mcmeta +++ b/versions/1.20.1/src/main/resources/pack.mcmeta @@ -1,8 +1,6 @@ { "pack": { "description": "${mod_name} Resources", - "pack_format": ${ - resource_pack_format -} -} + "pack_format": ${resource_pack_format} + } } \ No newline at end of file diff --git a/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileEnergyPylonFlux.java b/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileEnergyPylonFlux.java index d9edef8..3b03d12 100644 --- a/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileEnergyPylonFlux.java +++ b/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileEnergyPylonFlux.java @@ -28,6 +28,8 @@ public class TileEnergyPylonFlux extends TileEnergyPylon implements IFluxProxyHo private final EnergyPylonTransferHandler transferHandler = new EnergyPylonTransferHandler(); private ProxyFluxDevice fluxProxyDevice; + private CompoundTag pendingFluxTag; + private byte pendingFluxTagType; private int fluxTick; public TileEnergyPylonFlux(BlockPos pos, BlockState state) { @@ -53,6 +55,11 @@ public void tick() { @Override public void onLoad() { getOrCreateFluxProxyDevice().syncLevel(); + // Process any pending flux tag data that was received before level was initialized + if (pendingFluxTag != null) { + getOrCreateFluxProxyDevice().readCustomTag(pendingFluxTag, pendingFluxTagType); + pendingFluxTag = null; + } super.onLoad(); } @@ -139,7 +146,16 @@ public void writeFluxTag(CompoundTag tag, byte type) { @Override public void readFluxTag(CompoundTag tag, byte type) { - getOrCreateFluxProxyDevice().readCustomTag(tag, type); + // FIX: Sync level on the proxy device before reading, as ProxyFluxDevice has its own + // level field that must be explicitly synced from the host BlockEntity + ProxyFluxDevice device = getOrCreateFluxProxyDevice(); + device.syncLevel(); + if (device.getLevel() == null) { + pendingFluxTag = tag.copy(); + pendingFluxTagType = type; + } else { + device.readCustomTag(tag, type); + } } @Override diff --git a/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileFluxAccessorFlux.java b/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileFluxAccessorFlux.java index b673af5..4578c04 100644 --- a/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileFluxAccessorFlux.java +++ b/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileFluxAccessorFlux.java @@ -33,6 +33,8 @@ public class TileFluxAccessorFlux extends AENetworkedBlockEntity implements IFlu private final FluxAccessorTransferHandler transferHandler = new FluxAccessorTransferHandler(); private ProxyFluxDevice fluxProxyDevice; + private CompoundTag pendingFluxTag; + private byte pendingFluxTagType; public TileFluxAccessorFlux(BlockPos pos, BlockState state) { super(Objects.requireNonNull(MoreFluxStorageContent.getFluxAccessorFluxBlockEntityType(), "Flux accessor block entity type is not registered"), pos, state); @@ -54,6 +56,11 @@ public void tick() { @Override public void onReady() { getOrCreateFluxProxyDevice().syncLevel(); + // Process any pending flux tag data that was received before level was initialized + if (pendingFluxTag != null) { + getOrCreateFluxProxyDevice().readCustomTag(pendingFluxTag, pendingFluxTagType); + pendingFluxTag = null; + } super.onReady(); } @@ -137,7 +144,16 @@ public void writeFluxTag(CompoundTag tag, byte type) { @Override public void readFluxTag(CompoundTag tag, byte type) { - getOrCreateFluxProxyDevice().readCustomTag(tag, type); + // FIX: Sync level on the proxy device before reading, as ProxyFluxDevice has its own + // level field that must be explicitly synced from the host BlockEntity + ProxyFluxDevice device = getOrCreateFluxProxyDevice(); + device.syncLevel(); + if (device.getLevel() == null) { + pendingFluxTag = tag.copy(); + pendingFluxTagType = type; + } else { + device.readCustomTag(tag, type); + } } @Override @@ -195,6 +211,10 @@ private void syncTransferStateForTagWrite() { private final class FluxAccessorTransferHandler extends AbstractFluxTransferHandler { private void syncBufferFromStorage() { + // Only sync on server side to avoid client crashes + if (level == null || level.isClientSide) { + return; + } IStorageService storage = getStorageService(); setBuffer(storage == null ? 0L : storage.getCachedInventory().get(FluxKey.of(EnergyType.FE))); } diff --git a/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileInductionPortFlux.java b/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileInductionPortFlux.java index 43e2da3..e560ed8 100644 --- a/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileInductionPortFlux.java +++ b/versions/1.21.1/src/main/java/com/circulation/more_flux_storage/blockentity/TileInductionPortFlux.java @@ -34,6 +34,8 @@ public class TileInductionPortFlux extends TileEntityInductionPort implements IF private final InductionPortTransferHandler transferHandler = new InductionPortTransferHandler(); private ProxyFluxDevice fluxProxyDevice; + private CompoundTag pendingFluxTag; + private byte pendingFluxTagType; public TileInductionPortFlux(BlockPos pos, BlockState state) { super(Utils.trigger(pos), state); @@ -79,6 +81,11 @@ public void loadAdditional(@NotNull CompoundTag tag, @NotNull HolderLookup.Provi @Override public void onLoad() { getOrCreateFluxProxyDevice().syncLevel(); + // Process any pending flux tag data that was received before level was initialized + if (pendingFluxTag != null) { + getOrCreateFluxProxyDevice().readCustomTag(pendingFluxTag, pendingFluxTagType); + pendingFluxTag = null; + } super.onLoad(); } @@ -150,7 +157,16 @@ public void writeFluxTag(CompoundTag tag, byte type) { @Override public void readFluxTag(CompoundTag tag, byte type) { - getOrCreateFluxProxyDevice().readCustomTag(tag, type); + // FIX: Sync level on the proxy device before reading, as ProxyFluxDevice has its own + // level field that must be explicitly synced from the host BlockEntity + ProxyFluxDevice device = getOrCreateFluxProxyDevice(); + device.syncLevel(); + if (device.getLevel() == null) { + pendingFluxTag = tag.copy(); + pendingFluxTagType = type; + } else { + device.readCustomTag(tag, type); + } } public InteractionResult onSneakRightClick(Player player) { diff --git a/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/energy_pylon_flux.json b/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/energy_pylon_flux.json new file mode 100644 index 0000000..7d5196a --- /dev/null +++ b/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/energy_pylon_flux.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "more_flux_storage:energy_pylon_flux" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/flux_accessor_flux.json b/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/flux_accessor_flux.json new file mode 100644 index 0000000..9070174 --- /dev/null +++ b/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/flux_accessor_flux.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "more_flux_storage:flux_accessor_flux" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/induction_port_flux.json b/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/induction_port_flux.json new file mode 100644 index 0000000..b4f2488 --- /dev/null +++ b/versions/1.21.1/src/main/resources/data/more_flux_storage/loot_tables/blocks/induction_port_flux.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "more_flux_storage:induction_port_flux" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/versions/1.21.1/src/main/resources/pack.mcmeta b/versions/1.21.1/src/main/resources/pack.mcmeta index b95bcce..da04c20 100644 --- a/versions/1.21.1/src/main/resources/pack.mcmeta +++ b/versions/1.21.1/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "${mod_name} Resources", - "pack_format": " ${resource_pack_format}" + "pack_format": ${resource_pack_format} } } \ No newline at end of file