Large chunk on the pattern terminal.

This commit is contained in:
AlgorithmX2
2014-04-09 23:51:08 -05:00
parent 01c76a6870
commit d84be03027
11 changed files with 206 additions and 45 deletions
@@ -1,9 +1,12 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ITerminalHost;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.SlotRestrictedInput;
@@ -13,37 +16,97 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory
public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost
{
AppEngInternalInventory craftSlotInv = new AppEngInternalInventory( this, 1 );
SlotFake craftingSlots[] = new SlotFake[9];
SlotFake outputSlots[] = new SlotFake[3];
SlotPatternTerm craftSlot;
SlotRestrictedInput patternSlot;
OptionalSlotFake outputSlots[] = new OptionalSlotFake[3];
PartPatternTerminal ct;
SlotPatternTerm craftSlot;
SlotRestrictedInput patternSlotIN;
SlotRestrictedInput patternSlotOUT;
public PartPatternTerminal ct;
public boolean craftingMode = true;
public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost montiorable) {
super( ip, montiorable, false );
ct = (PartPatternTerminal) montiorable;
IInventory patternInv = ct.getInventoryByName( "pattern" );
IInventory output = ct.getInventoryByName( "output" );
IInventory crafting = ct.getInventoryByName( "crafting" );
for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++)
addSlotToContainer( craftingSlots[x + y * 3] = new SlotFake( crafting, x + y * 3, 54 + x * 18, -76 + y * 18 ) );
addSlotToContainer( craftingSlots[x + y * 3] = new SlotFake( crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) );
addSlotToContainer( craftSlot = new SlotPatternTerm( craftSlotInv, this, 0, 110, -76 + 18, 2 ) );
craftSlot.renderDisabled = false;
craftSlot.IIcon = -1;
for (int y = 0; y < 3; y++)
addSlotToContainer( outputSlots[y] = new SlotFake( crafting, 9 + y, 146, -76 + y * 18 ) );
{
addSlotToContainer( outputSlots[y] = new OptionalSlotFake( output, this, y, 110, -76 + y * 18, 0, 0, 1 ) );
outputSlots[y].renderDisabled = false;
outputSlots[y].IIcon = -1;
}
addSlotToContainer( patternSlotIN = new SlotRestrictedInput( PlaceableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9 ) );
addSlotToContainer( patternSlotOUT = new SlotRestrictedInput( PlaceableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34 ) );
addSlotToContainer( patternSlot = new SlotRestrictedInput( PlaceableItemType.PATTERN, patternInv, 0, 17, -72 - 9 ) );
addSlotToContainer( craftSlot = new SlotPatternTerm( craftSlotInv, 0, 17, -72 + 34 ) );
patternSlotOUT.setStackLimit( 1 );
patternSlot.setStackLimit( 1 );
bindPlayerInventory( ip, 0, 0 );
updateOrderOfOutputSlots();
}
private void updateOrderOfOutputSlots()
{
if ( !craftingMode )
{
craftSlot.xDisplayPosition = 0;
for (int y = 0; y < 3; y++)
outputSlots[y].xDisplayPosition = outputSlots[y].defX;
}
else
{
craftSlot.xDisplayPosition = craftSlot.defX;
for (int y = 0; y < 3; y++)
outputSlots[y].xDisplayPosition = 0;
}
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
if ( craftingMode != ct.craftingMode )
{
craftingMode = ct.craftingMode;
updateOrderOfOutputSlots();
for (Object c : this.crafters)
{
if ( c instanceof ICrafting )
((ICrafting) c).sendProgressBarUpdate( this, 97, craftingMode ? 1 : 0 );
}
}
}
@Override
public void updateProgressBar(int idx, int value)
{
super.updateProgressBar( idx, value );
if ( idx == 97 )
{
craftingMode = value == 1;
updateOrderOfOutputSlots();
}
}
@Override
@@ -57,4 +120,19 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
}
public void encode()
{
}
@Override
public boolean isSlotEnabled(int idx)
{
if ( idx == 1 )
return craftingMode == false;
if ( idx == 2 )
return craftingMode == true;
return false;
}
}