From a11a3313023623de382d2a21db04a2e35b9d6961 Mon Sep 17 00:00:00 2001 From: trinsdar <30245301+Trinsdar@users.noreply.github.com> Date: Wed, 20 Sep 2023 00:18:16 -0400 Subject: [PATCH] fixed buffer and filter blocks not saving to nbt properly, added other 2 buttons to buffer --- .../blockentity/single/BlockEntityBuffer.java | 21 ++++++++++++++++--- .../single/BlockEntityItemFilter.java | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityBuffer.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityBuffer.java index e53b0fad2..e66e07a72 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityBuffer.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityBuffer.java @@ -39,6 +39,8 @@ public class BlockEntityBuffer extends BlockEntityMachine { protected int stackLimit = 1; boolean emitEnergy = false; + boolean outputRedstone = false; + boolean invertRedstone = false; public BlockEntityBuffer(Machine type, BlockPos pos, BlockState state) { super(type, pos, state); @@ -117,12 +119,18 @@ public static boolean transferItems(PlatformItemHandler from, PlatformItemHandle public void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); tag.putInt("stackLimit", stackLimit); + outputRedstone = tag.getBoolean("outputRedstone"); + invertRedstone = tag.getBoolean("invertRedstone"); + emitEnergy = tag.getBoolean("emitEnergy"); } @Override public void load(CompoundTag tag) { super.load(tag); stackLimit = tag.getInt("stackLimit"); + tag.putBoolean("outputRedstone", outputRedstone); + tag.putBoolean("invertRedstone", invertRedstone); + tag.putBoolean("emitEnergy", emitEnergy); } @Override @@ -136,9 +144,14 @@ public void onGuiEvent(IGuiEvent event, Player playerEntity) { AntimatterPlatformUtils.markAndNotifyBlock(level, this.getBlockPos(), this.level.getChunkAt(this.getBlockPos()), this.getBlockState(), this.getBlockState(), 1, 512); } case 1 -> { - /*outputRedstone = !outputRedstone; - playerEntity.sendMessage(Utils.literal((outputRedstone ? "Emit redstone if slots contain something" : "Don't emit redstone")), playerEntity.getUUID()); - AntimatterPlatformUtils.markAndNotifyBlock(level, this.getBlockPos(), this.level.getChunkAt(this.getBlockPos()), this.getBlockState(), this.getBlockState(), 1, 512);*/ + outputRedstone = !outputRedstone; + playerEntity.sendMessage(Utils.literal( (outputRedstone ? "Emit redstone if slots contain something" : "Don't emit redstone")), playerEntity.getUUID()); + AntimatterPlatformUtils.markAndNotifyBlock(level, this.getBlockPos(), this.level.getChunkAt(this.getBlockPos()), this.getBlockState(), this.getBlockState(), 1, 512); + } + case 2 -> { + invertRedstone = !invertRedstone; + playerEntity.sendMessage(Utils.literal( (invertRedstone ? "I" : "Don't i") + "nvert redstone"), playerEntity.getUUID()); + AntimatterPlatformUtils.markAndNotifyBlock(level, this.getBlockPos(), this.level.getChunkAt(this.getBlockPos()), this.getBlockState(), this.getBlockState(), 1, 512); } } } @@ -148,6 +161,8 @@ public void onGuiEvent(IGuiEvent event, Player playerEntity) { public void addWidgets(GuiInstance instance, IGuiElement parent) { super.addWidgets(instance, parent); instance.addSwitchButton(8, 63, 16, 16, ButtonOverlays.ENERGY_OFF, ButtonOverlays.ENERGY_ON, h -> ((BlockEntityBuffer)h).emitEnergy); + instance.addSwitchButton(26, 63, 16, 16, ButtonOverlays.REDSTONE_CONTROL_OFF, ButtonOverlays.REDSTONE_CONTROL_ON, h -> ((BlockEntityBuffer)h).outputRedstone); + instance.addSwitchButton(44, 63, 16, 16, ButtonOverlays.INVERT_REDSTONE_OFF, ButtonOverlays.INVERT_REDSTONE_ON, h -> ((BlockEntityBuffer)h).invertRedstone); } public static class BufferItemHandler extends MachineItemHandler { diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityItemFilter.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityItemFilter.java index bdc16c79b..0716d8ffd 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityItemFilter.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityItemFilter.java @@ -152,7 +152,7 @@ public void load(CompoundTag tag) { nbt = tag.getBoolean("nbt"); outputRedstone = tag.getBoolean("outputRedstone"); invertRedstone = tag.getBoolean("invertRedstone"); - emitEnergy = tag.getBoolean("emitsEnergy"); + emitEnergy = tag.getBoolean("emitEnergy"); } @Override