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;
}
}
+7
View File
@@ -10,6 +10,8 @@ public class OptionalSlotFake extends SlotFake
final int groupNum;
IOptionalSlotHost host;
public boolean renderDisabled = true;
public int srcX;
public int srcY;
@@ -43,4 +45,9 @@ public class OptionalSlotFake extends SlotFake
return host.isSlotEnabled( groupNum );
}
public boolean renderDisabled()
{
return renderDisabled;
}
}
+5 -4
View File
@@ -4,22 +4,23 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class SlotPatternTerm extends AppEngSlot
public class SlotPatternTerm extends OptionalSlotFake
{
public SlotPatternTerm(IInventory inv, int idx, int x, int y) {
super( inv, idx, x, y );
public SlotPatternTerm(IInventory inv, IOptionalSlotHost h, int idx, int x, int y, int grpnum) {
super( inv, h, idx, x, y, 0, 0, grpnum );
}
@Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{
return false;
return super.canTakeStack( par1EntityPlayer );
}
@Override
public void onPickupFromSlot(EntityPlayer p, ItemStack is)
{
super.onPickupFromSlot( p, is );
}
}
+7 -2
View File
@@ -130,9 +130,14 @@ public class SlotRestrictedInput extends AppEngSlot
case VALID_ENCODED_PATTERN_W_OUPUT:
case ENCODED_PATTERN_W_OUTPUT:
case ENCODED_PATTERN: {
ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) i.getItem()).getPatternForItem( i ) : null;
return pattern != null;
if ( i.getItem() instanceof ICraftingPatternItem )
return true;
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem)
// i.getItem()).getPatternForItem( i ) : null;
return false;// pattern != null;
}
case BLANK_PATTERN:
return AEApi.instance().materials().materialBlankPattern.sameAs( i );
case PATTERN:
if ( i.getItem() instanceof ICraftingPatternItem )