buttons work and set quantities properly
This commit is contained in:
@@ -105,13 +105,35 @@ public class GuiPatternTerm extends GuiMEMonitorable
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MultiplyByTwo", "1" ) );
|
||||
}
|
||||
|
||||
if( this.x3Btn == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MultiplyByThree", "1" ) );
|
||||
}
|
||||
|
||||
if( this.divTwoBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DivideByTwo", "1" ) );
|
||||
}
|
||||
|
||||
if( this.divThreeBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DivideByThree", "1" ) );
|
||||
}
|
||||
|
||||
if( this.plusOneBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.IncreaseByOne", "1" ) );
|
||||
}
|
||||
|
||||
if( this.minusOneBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DecreaseByOne", "1" ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( this.maxCountBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MaximizeCount", "1" ) );
|
||||
}
|
||||
|
||||
if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
|
||||
{
|
||||
@@ -151,33 +173,33 @@ public class GuiPatternTerm extends GuiMEMonitorable
|
||||
this.clearBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.clearBtn );
|
||||
|
||||
this.x2Btn = new GuiImgButton( this.guiLeft + 106, this.guiTop + this.ySize - 152, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO );
|
||||
this.x3Btn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE );
|
||||
this.x3Btn.setHalfSize( true );
|
||||
this.buttonList.add( this.x3Btn );
|
||||
|
||||
this.x2Btn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO );
|
||||
this.x2Btn.setHalfSize( true );
|
||||
this.buttonList.add( this.x2Btn );
|
||||
|
||||
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.clearBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.clearBtn );
|
||||
this.plusOneBtn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 138, Settings.ACTIONS, ActionItems.INCREASE_BY_ONE );
|
||||
this.plusOneBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.plusOneBtn );
|
||||
|
||||
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.clearBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.clearBtn );
|
||||
this.divThreeBtn = new GuiImgButton( this.guiLeft + 100, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE );
|
||||
this.divThreeBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.divThreeBtn );
|
||||
|
||||
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.clearBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.clearBtn );
|
||||
this.divTwoBtn = new GuiImgButton( this.guiLeft + 100, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO );
|
||||
this.divTwoBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.divTwoBtn );
|
||||
|
||||
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.clearBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.clearBtn );
|
||||
this.minusOneBtn = new GuiImgButton( this.guiLeft + 100, this.guiTop + this.ySize - 138, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE );
|
||||
this.minusOneBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.minusOneBtn );
|
||||
|
||||
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.clearBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.clearBtn );
|
||||
|
||||
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.clearBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.clearBtn );
|
||||
this.maxCountBtn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 108, Settings.ACTIONS, ActionItems.MAX_COUNT );
|
||||
this.maxCountBtn.setHalfSize( true );
|
||||
this.buttonList.add( this.maxCountBtn );
|
||||
|
||||
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
|
||||
this.buttonList.add( this.encodeBtn );
|
||||
@@ -190,6 +212,13 @@ public class GuiPatternTerm extends GuiMEMonitorable
|
||||
{
|
||||
this.tabCraftButton.visible = true;
|
||||
this.tabProcessButton.visible = false;
|
||||
this.x2Btn.visible = false;
|
||||
this.x3Btn.visible = false;
|
||||
this.divTwoBtn.visible = false;
|
||||
this.divThreeBtn.visible = false;
|
||||
this.plusOneBtn.visible = false;
|
||||
this.minusOneBtn.visible = false;
|
||||
this.maxCountBtn.visible = false;
|
||||
|
||||
if( this.container.substitute )
|
||||
{
|
||||
@@ -208,6 +237,13 @@ public class GuiPatternTerm extends GuiMEMonitorable
|
||||
this.tabProcessButton.visible = true;
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
this.substitutionsDisabledBtn.visible = false;
|
||||
this.x2Btn.visible = true;
|
||||
this.x3Btn.visible = true;
|
||||
this.divTwoBtn.visible = true;
|
||||
this.divThreeBtn.visible = true;
|
||||
this.plusOneBtn.visible = true;
|
||||
this.minusOneBtn.visible = true;
|
||||
this.maxCountBtn.visible = true;
|
||||
}
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
|
||||
@@ -272,69 +272,207 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
public void multiply(int multiple)
|
||||
{
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
ItemStack[] output = new ItemStack[3];
|
||||
|
||||
input = getInputs();
|
||||
output = getOutputs();
|
||||
boolean canMultiplyInputs = true;
|
||||
boolean canMultiplyOutputs = true;
|
||||
|
||||
for( int x = 0; x < this.craftingSlots.length; x++ )
|
||||
{
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if( input[x].getCount() * multiple > 64 )
|
||||
if( !input[x].isEmpty() && input[x].getCount() * multiple > 64 )
|
||||
{
|
||||
canMultiplyInputs = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( this.isCraftingMode() )
|
||||
for( final OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
output[0] = this.outputSlots[0].getStack();
|
||||
if( output[0].getCount() * multiple > 64 )
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if( !out.isEmpty() && out.getCount() * multiple > 64 )
|
||||
{
|
||||
canMultiplyOutputs = false;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int outSlot=0;
|
||||
for( final OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if( out.getCount() * multiple > 64 )
|
||||
{
|
||||
canMultiplyOutputs = false;
|
||||
}
|
||||
outSlot++;
|
||||
}
|
||||
}
|
||||
|
||||
if( canMultiplyInputs && canMultiplyOutputs )
|
||||
{
|
||||
for( int x = 0; x < this.craftingSlots.length; x++ )
|
||||
for( SlotFakeCraftingMatrix craftingSlot : this.craftingSlots )
|
||||
{
|
||||
ItemStack stack = this.craftingSlots[x].getStack();
|
||||
this.craftingSlots[x].getStack().setCount( stack.getCount() * multiple );
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
craftingSlot.getStack().setCount( stack.getCount() * multiple );
|
||||
}
|
||||
|
||||
if( this.isCraftingMode() )
|
||||
for( OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
ItemStack stackOut = this.craftingSlots[0].getStack();
|
||||
|
||||
this.outputSlots[0].getStack().setCount( stackOut.getCount() * multiple);
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int x = 0; x < this.outputSlots.length; x++ )
|
||||
{
|
||||
ItemStack stack = this.outputSlots[x].getStack();
|
||||
this.outputSlots[x].getStack().setCount( stack.getCount() * multiple );
|
||||
}
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
outputSlot.getStack().setCount( stack.getCount() * multiple );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void divide(int divide)
|
||||
{
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canDivideInputs = true;
|
||||
boolean canDivideOutputs = true;
|
||||
|
||||
for( int x = 0; x < this.craftingSlots.length; x++ )
|
||||
{
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if( !input[x].isEmpty() && input[x].getCount() % divide != 0 )
|
||||
{
|
||||
canDivideInputs = false;
|
||||
}
|
||||
}
|
||||
for( final OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if( !out.isEmpty() && out.getCount() % divide != 0 )
|
||||
{
|
||||
canDivideOutputs = false;
|
||||
}
|
||||
}
|
||||
if( canDivideInputs && canDivideOutputs )
|
||||
{
|
||||
for( SlotFakeCraftingMatrix craftingSlot : this.craftingSlots )
|
||||
{
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
craftingSlot.getStack().setCount( stack.getCount() / divide );
|
||||
}
|
||||
for( OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
outputSlot.getStack().setCount( stack.getCount() / divide );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void increase(int increase)
|
||||
{
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canIncreaseInputs = true;
|
||||
boolean canIncreaseOutputs = true;
|
||||
|
||||
for( int x = 0; x < this.craftingSlots.length; x++ )
|
||||
{
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if( !input[x].isEmpty() && input[x].getCount() + increase > 64 )
|
||||
{
|
||||
canIncreaseInputs = false;
|
||||
}
|
||||
}
|
||||
for( final OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if( !out.isEmpty() && out.getCount() + increase > 64 )
|
||||
{
|
||||
canIncreaseOutputs = false;
|
||||
}
|
||||
}
|
||||
if( canIncreaseInputs && canIncreaseOutputs )
|
||||
{
|
||||
for( SlotFakeCraftingMatrix craftingSlot : this.craftingSlots )
|
||||
{
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
craftingSlot.getStack().setCount( stack.getCount() + increase );
|
||||
}
|
||||
for( OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
outputSlot.getStack().setCount( stack.getCount() + increase );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decrease(int decrease)
|
||||
{
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canDecreaseInputs = true;
|
||||
boolean canDecreaseOutputs = true;
|
||||
|
||||
for( int x = 0; x < this.craftingSlots.length; x++ )
|
||||
{
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if( !input[x].isEmpty() && input[x].getCount() - decrease < 1 )
|
||||
{
|
||||
canDecreaseInputs = false;
|
||||
}
|
||||
}
|
||||
for( final OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if( !out.isEmpty() && out.getCount() - decrease < 1 )
|
||||
{
|
||||
canDecreaseOutputs = false;
|
||||
}
|
||||
}
|
||||
if( canDecreaseInputs && canDecreaseOutputs )
|
||||
{
|
||||
for( SlotFakeCraftingMatrix craftingSlot : this.craftingSlots )
|
||||
{
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
craftingSlot.getStack().setCount( stack.getCount() - decrease );
|
||||
}
|
||||
for( OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
outputSlot.getStack().setCount( stack.getCount() - decrease );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void maximizeCount()
|
||||
{
|
||||
ItemStack[] input = new ItemStack[9];
|
||||
boolean canGrowInputs = true;
|
||||
boolean canGrowOutputs = true;
|
||||
int maxInputStackGrowth = 0;
|
||||
int maxOutputStackGrowth = 0;
|
||||
|
||||
|
||||
for( int x = 0; x < this.craftingSlots.length; x++ )
|
||||
{
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if( !input[x].isEmpty() && 64 - input[x].getCount() > maxInputStackGrowth )
|
||||
{
|
||||
maxInputStackGrowth = 64 - input[x].getCount();
|
||||
}
|
||||
if( !input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > 64 )
|
||||
{
|
||||
canGrowInputs = false;
|
||||
}
|
||||
}
|
||||
for( final OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
{
|
||||
maxOutputStackGrowth = 64 - out.getCount();
|
||||
}
|
||||
if( !out.isEmpty() && out.getCount() + maxOutputStackGrowth > 64 )
|
||||
{
|
||||
canGrowOutputs = false;
|
||||
}
|
||||
}
|
||||
if( canGrowInputs && canGrowOutputs )
|
||||
{
|
||||
int maxStackGrowth = Math.min(maxInputStackGrowth,maxOutputStackGrowth);
|
||||
for( SlotFakeCraftingMatrix craftingSlot : this.craftingSlots )
|
||||
{
|
||||
ItemStack stack = craftingSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
craftingSlot.getStack().setCount( stack.getCount() + maxStackGrowth );
|
||||
}
|
||||
for( OptionalSlotFake outputSlot : this.outputSlots )
|
||||
{
|
||||
ItemStack stack = outputSlot.getStack();
|
||||
if( !stack.isEmpty() )
|
||||
outputSlot.getStack().setCount( stack.getCount() + maxStackGrowth );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack[] getInputs()
|
||||
|
||||
@@ -185,10 +185,30 @@ public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
cpt.multiply(2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
else if( this.Name.equals( "PatternTerminal.MultiplyByThree" ) )
|
||||
{
|
||||
cpt.multiply(3);
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.DivideByTwo" ) )
|
||||
{
|
||||
cpt.divide(2);
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.DivideByThree" ) )
|
||||
{
|
||||
cpt.divide(3);
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.IncreaseByOne" ) )
|
||||
{
|
||||
cpt.increase(1);
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.DecreaseByOne" ) )
|
||||
{
|
||||
cpt.decrease(1);
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.MaximizeCount" ) )
|
||||
{
|
||||
cpt.maximizeCount();
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.Substitute" ) )
|
||||
{
|
||||
cpt.getPatternTerminal().setSubstitution( this.Value.equals( "1" ) );
|
||||
|
||||
Reference in New Issue
Block a user