Skip to content

Commit

Permalink
feat: No need for disable button
Browse files Browse the repository at this point in the history
  • Loading branch information
supersimple33 committed Jul 18, 2023
1 parent 45c7557 commit bf19214
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/main/java/dev/galacticraft/mod/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ public OxygenSealerScreen(MachineMenu<OxygenSealerBlockEntity> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit bf19214

Please sign in to comment.