diff --git a/src/main/java/techreborn/blockentity/storage/AdjustableSUBlockEntity.java b/src/main/java/techreborn/blockentity/storage/AdjustableSUBlockEntity.java index d4fd089d8..7a157d023 100644 --- a/src/main/java/techreborn/blockentity/storage/AdjustableSUBlockEntity.java +++ b/src/main/java/techreborn/blockentity/storage/AdjustableSUBlockEntity.java @@ -68,29 +68,19 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements } public void handleGuiInputFromClient(int id, boolean shift, boolean ctrl) { - if (id == 300) { - OUTPUT += shift ? 4096 : 256; - if(ctrl){ - //Set to max, limited to the max later - OUTPUT = Integer.MAX_VALUE; - } + if(shift){ + id *= 4; } - if (id == 301) { - OUTPUT += shift ? 512 : 64; - } - if (id == 302) { - OUTPUT -= shift ? 512 : 64; - } - if (id == 303) { - OUTPUT -= shift ? 4096 : 256; - if(ctrl){ - OUTPUT = 1; - } + if(ctrl){ + id *= 8; } + + OUTPUT += id; + if (OUTPUT > getMaxConfigOutput()) { OUTPUT = getMaxConfigOutput(); } - if (OUTPUT <= -1) { + if (OUTPUT <= 0) { OUTPUT = 0; } } diff --git a/src/main/java/techreborn/client/gui/GuiAESU.java b/src/main/java/techreborn/client/gui/GuiAESU.java index 190a4d7cb..bf73036e6 100644 --- a/src/main/java/techreborn/client/gui/GuiAESU.java +++ b/src/main/java/techreborn/client/gui/GuiAESU.java @@ -25,6 +25,7 @@ package techreborn.client.gui; import com.mojang.blaze3d.platform.GlStateManager; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -44,6 +45,12 @@ public class GuiAESU extends GuiBase { this.blockEntity = aesu; } + @Override + public void init() { + super.init(); + + } + @Override protected void drawBackground(final float f, final int mouseX, final int mouseY) { super.drawBackground(f, mouseX, mouseY); @@ -52,7 +59,7 @@ public class GuiAESU extends GuiBase { this.drawSlot(62, 45, layer); this.drawSlot(98, 45, layer); this.drawArmourSlots(8, 18, layer); - this.builder.drawEnergyOutput(this, 171, 61, this.blockEntity.getCurrentOutput(), layer); + this.builder.drawEnergyOutput(this, 155, 61, this.blockEntity.getCurrentOutput(), layer); this.builder.drawUpDownButtons(this, 121, 79, layer); } @@ -71,14 +78,16 @@ public class GuiAESU extends GuiBase { } builder.drawMultiEnergyBar(this, 81, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer); + + addButton(new GuiButtonUpDown(left + 121, top + 79, this, b -> onClick(256))); + addButton(new GuiButtonUpDown(left + 121 + 12, top + 79, this, b -> onClick(64))); + addButton(new GuiButtonUpDown(left + 121 + 24, top + 79, this, b -> onClick(-64))); + addButton(new GuiButtonUpDown(left + 121 + 36, top + 79, this, b -> onClick(-256))); - buttons.add(new GuiButtonUpDown(121, 79, this, layer, this::onClick)); - buttons.add(new GuiButtonUpDown(121 + 12, 79, this, layer, this::onClick)); - buttons.add(new GuiButtonUpDown(121 + 24, 79, this, layer, this::onClick)); - buttons.add(new GuiButtonUpDown(121 + 36, 79, this, layer, this::onClick)); + } - public void onClick(ButtonWidget button){ - NetworkManager.sendToServer(ServerboundPackets.createPacketAesu(1, blockEntity)); + public void onClick(int amount){ + NetworkManager.sendToServer(ServerboundPackets.createPacketAesu(amount, Screen.hasShiftDown(), Screen.hasControlDown(), blockEntity)); } } diff --git a/src/main/java/techreborn/client/gui/GuiFusionReactor.java b/src/main/java/techreborn/client/gui/GuiFusionReactor.java index a3e368d9f..4b27bc009 100644 --- a/src/main/java/techreborn/client/gui/GuiFusionReactor.java +++ b/src/main/java/techreborn/client/gui/GuiFusionReactor.java @@ -72,7 +72,7 @@ public class GuiFusionReactor extends GuiBase { } } - + @Override protected void drawForeground(final int mouseX, final int mouseY) { super.drawForeground(mouseX, mouseY); @@ -105,10 +105,10 @@ public class GuiFusionReactor extends GuiBase { drawString("Size: " + blockEntity.size, 83, 81, 0xFFFFFF, layer); drawString("" + blockEntity.getPowerMultiplier() + "x", 10, 81, 0xFFFFFF, layer); - buttons.add(new GuiButtonUpDown(121, 79, this, GuiBase.Layer.FOREGROUND, (ButtonWidget buttonWidget) -> sendSizeChange(5))); - buttons.add(new GuiButtonUpDown(121 + 12, 79, this, GuiBase.Layer.FOREGROUND, (ButtonWidget buttonWidget) -> sendSizeChange(1))); - buttons.add(new GuiButtonUpDown(121 + 24, 79, this, GuiBase.Layer.FOREGROUND, (ButtonWidget buttonWidget) -> sendSizeChange(-5))); - buttons.add(new GuiButtonUpDown(121 + 36, 79, this, GuiBase.Layer.FOREGROUND, (ButtonWidget buttonWidget) -> sendSizeChange(-1))); + addButton(new GuiButtonUpDown(left + 121, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(5))); + addButton(new GuiButtonUpDown(left + 121 + 12, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(1))); + addButton(new GuiButtonUpDown(left + 121 + 24, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-5))); + addButton(new GuiButtonUpDown(left + 121 + 36, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-1))); builder.drawMultiEnergyBar(this, 9, 19, (int) this.blockEntity.getEnergy(), (int) this.blockEntity.getMaxPower(), mouseX, mouseY, 0, layer); } diff --git a/src/main/java/techreborn/packets/ServerboundPackets.java b/src/main/java/techreborn/packets/ServerboundPackets.java index 2b3f094b8..b3fe5c62e 100644 --- a/src/main/java/techreborn/packets/ServerboundPackets.java +++ b/src/main/java/techreborn/packets/ServerboundPackets.java @@ -58,11 +58,13 @@ public class ServerboundPackets { registerPacketHandler(AESU, (extendedPacketBuffer, context) -> { BlockPos pos = extendedPacketBuffer.readBlockPos(); int buttonID = extendedPacketBuffer.readInt(); + boolean shift = extendedPacketBuffer.readBoolean(); + boolean ctrl = extendedPacketBuffer.readBoolean(); context.getTaskQueue().execute(() -> { BlockEntity blockEntity = context.getPlayer().world.getBlockEntity(pos); if (blockEntity instanceof AdjustableSUBlockEntity) { - ((AdjustableSUBlockEntity) blockEntity).handleGuiInputFromClient(buttonID, false, false); + ((AdjustableSUBlockEntity) blockEntity).handleGuiInputFromClient(buttonID, shift, ctrl); } }); }); @@ -139,10 +141,12 @@ public class ServerboundPackets { ServerSidePacketRegistry.INSTANCE.register(identifier, (packetContext, packetByteBuf) -> consumer.accept(new ExtendedPacketBuffer(packetByteBuf), packetContext)); } - public static Packet createPacketAesu(int buttonID, AdjustableSUBlockEntity blockEntity) { + public static Packet createPacketAesu(int buttonID, boolean shift, boolean ctrl, AdjustableSUBlockEntity blockEntity) { return NetworkManager.createServerBoundPacket(AESU, extendedPacketBuffer -> { extendedPacketBuffer.writeBlockPos(blockEntity.getPos()); extendedPacketBuffer.writeInt(buttonID); + extendedPacketBuffer.writeBoolean(shift); + extendedPacketBuffer.writeBoolean(ctrl); }); }