New Imprinter GUI
This commit is contained in:
parent
bc035f3078
commit
37b57e31a4
6 changed files with 76 additions and 44 deletions
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
@ -18,7 +18,7 @@ public class GuiImprinter extends GuiContainer
|
|||
public GuiImprinter(InventoryPlayer par1InventoryPlayer, TileEntityImprinter tileEntity)
|
||||
{
|
||||
super(new ContainerImprinter(par1InventoryPlayer, tileEntity));
|
||||
this.ySize = 184;
|
||||
this.ySize = 201;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,6 @@ public class GuiImprinter extends GuiContainer
|
|||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(TranslationHelper.getLocal("tile.imprinter.name"), 68, 6, 4210752);
|
||||
this.fontRenderer.drawString(TranslationHelper.getLocal("assemblyline.gui.crafting") + ":", 20, 54, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -151,7 +151,7 @@ public class AssemblyLine
|
|||
GameRegistry.addRecipe(new ShapedOreRecipe(itemImprint, new Object[] { "R", "P", "I", 'P', Item.paper, 'R', Item.redstone, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
|
||||
|
||||
// Imprinter
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, new Object[] { "SIS", "SPS", "WWW", 'S', "ingotSteel", 'W', Block.wood, 'P', Block.pistonStickyBase, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, new Object[] { "SIS", "SPS", "WCW", 'S', "ingotSteel", 'C', Block.chest, 'W', Block.workbench, 'P', Block.pistonStickyBase, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
|
||||
|
||||
// Detector
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, new Object[] { "SES", "SCS", "SPS", 'S', "ingotSteel", 'C', "basicCircuit", 'E', Item.eyeOfEnder }));
|
||||
|
|
|
@ -17,21 +17,31 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
this.tileEntity = tileEntity;
|
||||
this.inventoryPlayer = inventoryPlayer;
|
||||
|
||||
// Paper Input
|
||||
this.addSlotToContainer(new SlotCustom(this.tileEntity, 0, 33, 22, new ItemStack(AssemblyLine.itemImprint)));
|
||||
// Item Stamp
|
||||
this.addSlotToContainer(new Slot(this.tileEntity, 1, 69, 22));
|
||||
// Output Filter
|
||||
this.addSlotToContainer(new SlotImprintResult(this.tileEntity, 2, 127, 22));
|
||||
// Crafting Slot
|
||||
this.addSlotToContainer(new SlotCustom(this.tileEntity, 3, 69, 51, new ItemStack(AssemblyLine.itemImprint)));
|
||||
// Crafting Output
|
||||
this.addSlotToContainer(new SlotCraftingResult(this, this.tileEntity, 4, 127, 51));
|
||||
/**
|
||||
* Crafting Matrix
|
||||
*/
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(this.tileEntity, y + x, 9 + y * 18, 16 + x * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Imprint Input for Imprinting
|
||||
this.addSlotToContainer(new SlotCustom(this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START, 68, 34, new ItemStack(AssemblyLine.itemImprint)));
|
||||
// Item to be imprinted
|
||||
this.addSlotToContainer(new Slot(this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 1, 92, 34));
|
||||
// Result of Crafting/Imprinting
|
||||
this.addSlotToContainer(new SlotCraftingResult(this, this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 2, 148, 34));
|
||||
|
||||
// Imprinter Inventory
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
this.addSlotToContainer(new WatchedSlot(this.tileEntity, i + TileEntityImprinter.START_INVENTORY, 8 + i * 18, 80, this));
|
||||
for (int ii = 0; ii < 2; ii++)
|
||||
{
|
||||
this.addSlotToContainer(new WatchedSlot(this.tileEntity, i + this.tileEntity.imprinterMatrix.length - 1, 8 + i * 18, 80 + ii * 18, this));
|
||||
}
|
||||
}
|
||||
|
||||
// Player Inventory
|
||||
|
@ -41,13 +51,13 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlotToContainer(new WatchedSlot(inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 102 + var3 * 18, this));
|
||||
this.addSlotToContainer(new WatchedSlot(inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 120 + var3 * 18, this));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlotToContainer(new WatchedSlot(inventoryPlayer, var3, 8 + var3 * 18, 160, this));
|
||||
this.addSlotToContainer(new WatchedSlot(inventoryPlayer, var3, 8 + var3 * 18, 178, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +93,7 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
{
|
||||
if (!this.mergeItemStack(slotStack, 0, 1, false)) { return null; }
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, this.tileEntity.START_INVENTORY, this.tileEntity.getSizeInventory(), false)) { return null; }
|
||||
else if (!this.mergeItemStack(slotStack, this.tileEntity.imprinterMatrix.length, this.tileEntity.getSizeInventory(), false)) { return null; }
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), this.tileEntity.getSizeInventory() + 36, false)) { return null; }
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
|
||||
public class InventoryImprinterCrafting extends InventoryCrafting
|
||||
{
|
||||
|
||||
public InventoryImprinterCrafting(Container par1Container, int par2, int par3)
|
||||
{
|
||||
super(par1Container, par2, par3);
|
||||
}
|
||||
|
||||
}
|
|
@ -27,13 +27,20 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
|
|||
|
||||
public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInventory, IArmbotUseable
|
||||
{
|
||||
public static final int START_INVENTORY = 5;
|
||||
public static final int INVENTORY_LENGTH = 9;
|
||||
public static final int IMPRINTER_MATRIX_START = 9;
|
||||
public static final int INVENTORY_START = IMPRINTER_MATRIX_START + 3;
|
||||
|
||||
/**
|
||||
* Imprinter slots. 10 extra slots for storing imprints.
|
||||
* 9 slots for crafting, 1 slot for an imprint, 1 slot for an item
|
||||
*/
|
||||
private ItemStack[] containingItems = new ItemStack[5 + INVENTORY_LENGTH];
|
||||
public InventoryImprinterCrafting craftingMatrix = new InventoryImprinterCrafting(null, 3, 3);
|
||||
|
||||
public ItemStack[] imprinterMatrix = new ItemStack[3];
|
||||
|
||||
/**
|
||||
* The Imprinter inventory containing slots.
|
||||
*/
|
||||
public ItemStack[] containingItems = new ItemStack[18];
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
|
@ -46,31 +53,35 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
{
|
||||
if (side == ForgeDirection.UP || side == ForgeDirection.DOWN)
|
||||
return 3;
|
||||
return START_INVENTORY;
|
||||
return imprinterMatrix.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventorySide(ForgeDirection side)
|
||||
{
|
||||
if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) { return 1; }
|
||||
return INVENTORY_LENGTH;
|
||||
return containingItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.containingItems.length;
|
||||
return this.imprinterMatrix.length + this.containingItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
return this.containingItems[slot];
|
||||
if (slot < 9)
|
||||
{
|
||||
return this.craftingMatrix.getStackInSlot(slot);
|
||||
}
|
||||
else if (slot < 11) { return this.imprinterMatrix[slot - IMPRINTER_MATRIX_START]; }
|
||||
return this.containingItems[slot - IMPRINTER_MATRIX_START];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and
|
||||
* returns them in a new stack.
|
||||
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int amount)
|
||||
|
@ -104,8 +115,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
}
|
||||
|
||||
/**
|
||||
* When some containers are closed they call this on each slot, then drop whatever it returns as
|
||||
* an EntityItem - like when you close a workbench GUI.
|
||||
* When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - like when you close a workbench GUI.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
|
@ -123,8 +133,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor
|
||||
* sections).
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
||||
|
@ -304,10 +313,14 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
*/
|
||||
public ArrayList<ItemStack> hasResource(Object[] recipeItems)
|
||||
{
|
||||
/**
|
||||
* Simulate an imprinter.
|
||||
*/
|
||||
TileEntityImprinter test = new TileEntityImprinter();
|
||||
NBTTagCompound cloneData = new NBTTagCompound();
|
||||
this.writeToNBT(cloneData);
|
||||
test.readFromNBT(cloneData);
|
||||
|
||||
/**
|
||||
* The actual amount of resource required. Each ItemStack will only have stacksize of 1.
|
||||
*/
|
||||
|
@ -323,7 +336,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
|
||||
if (recipeItem != null)
|
||||
{
|
||||
for (int i = START_INVENTORY; i < test.getSizeInventory(); i++)
|
||||
for (int i = imprinterMatrix.length; i < test.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack checkStack = test.getStackInSlot(i);
|
||||
|
||||
|
@ -355,7 +368,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
|
||||
if (recipeItem != null)
|
||||
{
|
||||
for (int i = START_INVENTORY; i < test.getSizeInventory(); i++)
|
||||
for (int i = imprinterMatrix.length; i < test.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack checkStack = test.getStackInSlot(i);
|
||||
|
||||
|
@ -427,6 +440,12 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
nbt.setTag("Items", var2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Armbot
|
||||
* @param tileEntity
|
||||
* @param heldEntity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onUse(TileEntityArmbot tileEntity, Entity heldEntity)
|
||||
{
|
||||
|
@ -435,17 +454,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
if (heldEntity instanceof EntityItem)
|
||||
{
|
||||
ItemStack stack = ((EntityItem) heldEntity).getEntityItem();
|
||||
if (this.getStackInSlot(3) == null && stack != null && stack.itemID == AssemblyLine.itemImprint.itemID) // no
|
||||
// crafting
|
||||
// imprint
|
||||
// and
|
||||
// stack
|
||||
// not
|
||||
// null
|
||||
// and
|
||||
// stack
|
||||
// is
|
||||
// imprint
|
||||
if (this.getStackInSlot(3) == null && stack != null && stack.itemID == AssemblyLine.itemImprint.itemID)
|
||||
{
|
||||
this.setInventorySlotContents(3, stack);
|
||||
this.onInventoryChanged();
|
||||
|
|
Loading…
Reference in a new issue