Skip to content

Commit

Permalink
Make whole stack of patterns in one click (holding SHIFT+CTRL) (#121)
Browse files Browse the repository at this point in the history
* Make whole stack of patterns in one click (holding SHIFT+CTRL)

* Extend batch encoding to the processing terminal
  • Loading branch information
repo-alt authored Mar 5, 2022
1 parent d933425 commit 3d263e2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/appeng/core/sync/packets/PacketValueConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit 3d263e2

Please sign in to comment.