From 3d263e29653dc9f37032e840bb1d9fc14602586a Mon Sep 17 00:00:00 2001 From: repo-alt Date: Sat, 5 Mar 2022 13:05:14 +0300 Subject: [PATCH] Make whole stack of patterns in one click (holding SHIFT+CTRL) (#121) * Make whole stack of patterns in one click (holding SHIFT+CTRL) * Extend batch encoding to the processing terminal --- .../client/gui/implementations/GuiPatternTerm.java | 3 ++- .../client/gui/implementations/GuiPatternTermEx.java | 3 ++- .../implementations/ContainerPatternTerm.java | 12 ++++++++++-- .../implementations/ContainerPatternTermEx.java | 12 ++++++++++-- .../appeng/core/sync/packets/PacketValueConfig.java | 8 ++++++-- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java b/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java index 392ad83a7ee..52161c0ae2f 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java @@ -78,7 +78,8 @@ protected void actionPerformed( final GuiButton btn ) } else if( this.encodeBtn == btn ) { - NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", isShiftKeyDown() ? "2" : "1" ) ); + NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", + isCtrlKeyDown() ? (isShiftKeyDown() ? "6" : "1") : (isShiftKeyDown() ? "2" : "1") ) ); } else if( this.clearBtn == btn ) { diff --git a/src/main/java/appeng/client/gui/implementations/GuiPatternTermEx.java b/src/main/java/appeng/client/gui/implementations/GuiPatternTermEx.java index 3de8a825189..8cb01781972 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiPatternTermEx.java +++ b/src/main/java/appeng/client/gui/implementations/GuiPatternTermEx.java @@ -47,7 +47,8 @@ protected void actionPerformed( final GuiButton btn ) { if( this.encodeBtn == btn ) { - NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminalEx.Encode", isShiftKeyDown() ? "2" : "1" ) ); + NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminalEx.Encode", + isCtrlKeyDown() ? (isShiftKeyDown() ? "6" : "1") : (isShiftKeyDown() ? "2" : "1") ) ); } else if( this.clearBtn == btn ) { diff --git a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java index 9f31bc1bd47..284020163fb 100644 --- a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java @@ -174,13 +174,21 @@ public void onChangeInventory( final IInventory inv, final int slot, final InvOp } - public void encodeAndMoveToInventory() + public void encodeAndMoveToInventory(boolean encodeWholeStack) { encode(); ItemStack output = this.patternSlotOUT.getStack(); if ( output != null ) { - if (!getPlayerInv().addItemStackToInventory( output )){ + if (encodeWholeStack) + { + ItemStack blanks = this.patternSlotIN.getStack(); + this.patternSlotIN.putStack(null); + if (blanks != null) + output.stackSize += blanks.stackSize; + } + if (!getPlayerInv().addItemStackToInventory( output )) + { getPlayerInv().player.entityDropItem(output, 0); } this.patternSlotOUT.putStack( null ); diff --git a/src/main/java/appeng/container/implementations/ContainerPatternTermEx.java b/src/main/java/appeng/container/implementations/ContainerPatternTermEx.java index f8645d1fdc6..acca37fdef2 100644 --- a/src/main/java/appeng/container/implementations/ContainerPatternTermEx.java +++ b/src/main/java/appeng/container/implementations/ContainerPatternTermEx.java @@ -69,13 +69,21 @@ public ContainerPatternTermEx(final InventoryPlayer ip, final ITerminalHost moni this.bindPlayerInventory( ip, 0, 0 ); } - public void encodeAndMoveToInventory() + public void encodeAndMoveToInventory(boolean encodeWholeStack) { encode(); ItemStack output = this.patternSlotOUT.getStack(); if ( output != null ) { - if (!getPlayerInv().addItemStackToInventory( output )){ + if (encodeWholeStack) + { + ItemStack blanks = this.patternSlotIN.getStack(); + this.patternSlotIN.putStack(null); + if (blanks != null) + output.stackSize += blanks.stackSize; + } + if (!getPlayerInv().addItemStackToInventory( output )) + { getPlayerInv().player.entityDropItem(output, 0); } this.patternSlotOUT.putStack( null ); diff --git a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java index c7468199b34..1b3dcad0e31 100644 --- a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java +++ b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java @@ -147,7 +147,9 @@ else if( this.Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPat else if( this.Name.equals( "PatternTerminal.Encode" ) ) { if (this.Value.equals( "2" )) - cpt.encodeAndMoveToInventory(); + cpt.encodeAndMoveToInventory(false); + else if (this.Value.equals( "6" )) + cpt.encodeAndMoveToInventory(true); else cpt.encode(); } @@ -170,7 +172,9 @@ else if( this.Name.startsWith( "PatternTerminalEx." ) && c instanceof ContainerP if( this.Name.equals( "PatternTerminalEx.Encode" ) ) { if (this.Value.equals( "2" )) - cpt.encodeAndMoveToInventory(); + cpt.encodeAndMoveToInventory(false); + else if (this.Value.equals( "6" )) + cpt.encodeAndMoveToInventory(true); else cpt.encode(); }