Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions versions/1.12.2/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"pack": {
"description": "${mod_name} Resources",
"pack_format": ${
resource_pack_format
}
}
"pack_format": ${resource_pack_format}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}

Expand All @@ -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);
}

Expand 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);
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 2 additions & 4 deletions versions/1.20.1/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"pack": {
"description": "${mod_name} Resources",
"pack_format": ${
resource_pack_format
}
}
"pack_format": ${resource_pack_format}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
2 changes: 1 addition & 1 deletion versions/1.21.1/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "${mod_name} Resources",
"pack_format": " ${resource_pack_format}"
"pack_format": ${resource_pack_format}
}
}
Loading