From bf192145a9fa31be3d58d933a6f05a9e8785418f Mon Sep 17 00:00:00 2001 From: supersimple33 <40609224+supersimple33@users.noreply.github.com> Date: Tue, 18 Jul 2023 16:14:42 -0400 Subject: [PATCH] feat: No need for disable button --- .../java/dev/galacticraft/mod/Constant.java | 1 - .../gui/screen/ingame/OxygenSealerScreen.java | 6 ------ .../machine/OxygenSealerBlockEntity.java | 21 ++++++------------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/main/java/dev/galacticraft/mod/Constant.java b/src/main/java/dev/galacticraft/mod/Constant.java index 9cf909c1b..323cf3598 100644 --- a/src/main/java/dev/galacticraft/mod/Constant.java +++ b/src/main/java/dev/galacticraft/mod/Constant.java @@ -917,7 +917,6 @@ interface Packet { ResourceLocation BUBBLE_SIZE = id("bubble_size"); ResourceLocation BUBBLE_MAX = id("bubble_max"); ResourceLocation BUBBLE_VISIBLE = id("bubble_visible"); - ResourceLocation DISABLE_SEAL = id("toggle_seal"); ResourceLocation OPEN_GC_INVENTORY = id("open_gc_inv"); ResourceLocation OPEN_GC_ROCKET = id("open_gc_rocket"); ResourceLocation CREATE_SATELLITE = id("create_satellite"); diff --git a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/OxygenSealerScreen.java b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/OxygenSealerScreen.java index 9f7f42a2d..362befb44 100644 --- a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/OxygenSealerScreen.java +++ b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/OxygenSealerScreen.java @@ -45,12 +45,6 @@ public OxygenSealerScreen(MachineMenu handler, Inventor super(handler, title, Constant.ScreenTexture.OXYGEN_SEALER_SCREEN); } - @Override - protected void init() { - super.init(); - addRenderableWidget(Button.builder(Component.literal("Disable Seal"), button -> ClientPlayNetworking.send(Constant.Packet.DISABLE_SEAL, PacketByteBufs.create())).pos(this.leftPos + 60, this.topPos + 50).size(80, 15).build()); - } - @Override protected void renderForeground(GuiGraphics graphics, int mouseX, int mouseY, float delta) { super.renderForeground(graphics, mouseX, mouseY, delta); diff --git a/src/main/java/dev/galacticraft/mod/content/block/entity/machine/OxygenSealerBlockEntity.java b/src/main/java/dev/galacticraft/mod/content/block/entity/machine/OxygenSealerBlockEntity.java index f81fda1d9..cfe75efa9 100644 --- a/src/main/java/dev/galacticraft/mod/content/block/entity/machine/OxygenSealerBlockEntity.java +++ b/src/main/java/dev/galacticraft/mod/content/block/entity/machine/OxygenSealerBlockEntity.java @@ -93,9 +93,6 @@ protected void tickConstant(@NotNull ServerLevel world, @NotNull BlockPos pos, @ @Override protected @NotNull MachineStatus tick(@NotNull ServerLevel world, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ProfilerFiller profiler) { assert world != null; - if (this.disabled != (this.disabled = false)) { - ((ServerLevelAccessor) world).addSealer(this); - } if (this.energyStorage().canExtract(Galacticraft.CONFIG_MANAGER.get().oxygenCompressorEnergyConsumptionRate())) { if (!this.fluidStorage().getGroup(GCSlotGroupTypes.OXYGEN_INPUT).isEmpty()) { @@ -169,38 +166,32 @@ protected void tickConstant(@NotNull ServerLevel world, @NotNull BlockPos pos, @ profiler.pop(); return GCMachineStatuses.SEALED; } else { - resetForLowResource(world); + this.tryClearSeal(world); return GCMachineStatuses.NOT_ENOUGH_OXYGEN; } } else { - resetForLowResource(world); + this.tryClearSeal(world); return MachineStatuses.NOT_ENOUGH_ENERGY; } } - private void resetForLowResource(@NotNull ServerLevel world) { + private void tryClearSeal(@NotNull ServerLevel world) { if (this.sealed) { for (BlockPos pos1 : this.breathablePositions) { world.setBreathable(pos1, false); } this.breathablePositions.clear(); this.watching.clear(); - this.updateQueued = true; + this.sealed = false; } + this.updateQueued = true; this.sealCheckTime = 0; } @Override protected MachineStatus tickDisabled(@NotNull ServerLevel world, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ProfilerFiller profiler) { - this.disabled = true; - ((ServerLevelAccessor) world).removeSealer(this); - for (BlockPos pos1 : this.breathablePositions) { - world.setBreathable(pos1, false); - } - this.breathablePositions.clear(); - this.watching.clear(); - + this.tryClearSeal(world); return super.tickDisabled(world, pos, state, profiler); }