Reorganize folders for modules

This commit is contained in:
mDiyo committed 2014-06-04 21:44:48 -08:00
1 parent 2c14f315de
commit e2f0558b6f
370 files changed
+4274 -4788

No files matched your search

@@ -0,0 +1,232 @@
package tconstruct.tools.inventory;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.world.World;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.tools.ToolCore;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.CraftingStationLogic;
public class CraftingStationContainer extends Container
{
/** The crafting matrix inventory (3x3). */
public InventoryCrafting craftMatrix;// = new InventoryCrafting(this, 3, 3);
public IInventory craftResult;// = new InventoryCraftResult();
private CraftingStationLogic logic;
private World worldObj;
private int posX;
private int posY;
private int posZ;
public CraftingStationContainer(InventoryPlayer inventorplayer, CraftingStationLogic logic, int x, int y, int z)
{
this.worldObj = logic.getWorldObj();
this.posX = x;
this.posY = y;
this.posZ = z;
this.logic = logic;
craftMatrix = new InventoryCraftingStation(this, 3, 3, logic);
craftResult = new InventoryCraftingStationResult(logic);
this.addSlotToContainer(new SlotCrafting(inventorplayer.player, this.craftMatrix, this.craftResult, 0, 124, 35));
int row;
int column;
for (row = 0; row < 3; ++row)
{
for (column = 0; column < 3; ++column)
{
this.addSlotToContainer(new Slot(this.craftMatrix, column + row * 3, 30 + column * 18, 17 + row * 18));
}
}
// Player Inventory
for (row = 0; row < 3; ++row)
{
for (column = 0; column < 9; ++column)
{
this.addSlotToContainer(new Slot(inventorplayer, column + row * 9 + 9, 8 + column * 18, 84 + row * 18));
}
}
for (column = 0; column < 9; ++column)
{
this.addSlotToContainer(new Slot(inventorplayer, column, 8 + column * 18, 142));
}
// Side inventory
if (logic.chest != null)
{
IInventory chest = logic.chest.get();
IInventory doubleChest = logic.doubleChest == null ? null : logic.doubleChest.get();
IInventory firstChest = (logic.doubleFirst ? doubleChest : chest);
IInventory secondChest = (logic.doubleFirst ? chest : doubleChest);
int count = 0;
for (column = 0; column < 9; column++)
{
for (row = 0; row < 6; row++)
{
int value = count < 27 ? count : count - 27;
this.addSlotToContainer(new Slot(count < 27 ? firstChest : secondChest, value, -108 + row * 18, 19 + column * 18));
count++;
if (count >= 27 && doubleChest == null)
break;
}
if (count >= 27 && doubleChest == null)
break;
}
}
this.onCraftMatrixChanged(this.craftMatrix);
}
@Override
public void onCraftMatrixChanged (IInventory par1IInventory)
{
ItemStack tool = modifyTool();
if (tool != null)
this.craftResult.setInventorySlotContents(0, tool);
else
this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
}
public ItemStack modifyTool ()
{
ItemStack input = craftMatrix.getStackInSlot(4);
if (input != null)
{
Item item = input.getItem();
if (item instanceof ToolCore)
{
ItemStack[] slots = new ItemStack[8];
for (int i = 0; i < 4; i++)
{
slots[i] = craftMatrix.getStackInSlot(i);
slots[i + 4] = craftMatrix.getStackInSlot(i + 5);
}
ItemStack output = ToolBuilder.instance.modifyTool(input, slots, "");
if (output != null)
return output;
}
else if (item instanceof ArmorCore)
{
ItemStack[] slots = new ItemStack[8];
for (int i = 0; i < 4; i++)
{
slots[i] = craftMatrix.getStackInSlot(i);
slots[i + 4] = craftMatrix.getStackInSlot(i + 5);
}
ItemStack output = ToolBuilder.instance.modifyArmor(input, slots, "");
if (output != null)
return output;
}
}
return null;
}
@Override
public void onContainerClosed (EntityPlayer par1EntityPlayer)
{
super.onContainerClosed(par1EntityPlayer);
if (!this.worldObj.isRemote)
{
for (int i = 0; i < 9; ++i)
{
ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);
if (itemstack != null)
{
par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false);
}
}
}
}
@Override
public boolean canInteractWith (EntityPlayer player)
{
Block block = worldObj.getBlock(this.posX, this.posY, this.posZ);
if (block != TinkerTools.craftingStationWood && block != TinkerTools.craftingSlabWood)
return false;
return player.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D) <= 64.0D;
}
@Override
public ItemStack transferStackInSlot (EntityPlayer par1EntityPlayer, int par2)
{
ItemStack itemstack = null;
Slot slot = (Slot) this.inventorySlots.get(par2);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par2 == 0)
{
if (!this.mergeItemStack(itemstack1, 10, 46, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (par2 >= 10 && par2 < 37)
{
if (!this.mergeItemStack(itemstack1, 37, 46, false))
{
return null;
}
}
else if (par2 >= 37 && par2 < 46)
{
if (!this.mergeItemStack(itemstack1, 10, 37, false))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 10, 46, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}
slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
}
return itemstack;
}
@Override
public boolean func_94530_a (ItemStack par1ItemStack, Slot par2Slot)
{
return par2Slot.inventory != this.craftResult && super.func_94530_a(par1ItemStack, par2Slot);
}
}
@@ -0,0 +1,132 @@
package tconstruct.tools.inventory;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.FrypanLogic;
public class FrypanContainer extends Container
{
public FrypanLogic logic;
public int progress = 0;
public int fuel = 0;
public int fuelGague = 0;
public FrypanContainer(EntityPlayer player, FrypanLogic frypan)
{
InventoryPlayer inventoryplayer = player.inventory;
logic = frypan;
this.addSlotToContainer(new Slot(frypan, 1, 26, 45));
for (int y = 0; y < 2; y++)
for (int x = 0; x < 4; x++)
this.addSlotToContainer(new SlotFrypan(frypan, 2 + x + y * 4, 70 + x * 18, 27 + y * 18, player));
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
}
}
@Override
public void detectAndSendChanges ()
{
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++)
{
ICrafting icrafting = (ICrafting) crafters.get(i);
if (progress != logic.progress)
{
icrafting.sendProgressBarUpdate(this, 0, logic.progress);
}
if (fuel != logic.fuel)
{
icrafting.sendProgressBarUpdate(this, 1, logic.fuel);
}
if (fuelGague != logic.fuelGague)
{
icrafting.sendProgressBarUpdate(this, 2, logic.fuelGague);
}
}
progress = logic.progress;
fuel = logic.fuel;
fuelGague = logic.fuelGague;
}
@Override
public void updateProgressBar (int i, int j)
{
if (i == 0)
{
logic.progress = j;
}
if (i == 1)
{
logic.fuel = j;
}
if (i == 2)
{
logic.fuelGague = j;
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.heldItemBlock)
return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
}
@@ -0,0 +1,189 @@
package tconstruct.tools.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;
import tconstruct.tools.logic.FurnaceLogic;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class FurnaceContainer extends Container
{
private FurnaceLogic furnace;
private int lastCookTime;
private int lastBurnTime;
private int lastItemBurnTime;
public FurnaceContainer(InventoryPlayer par1InventoryPlayer, FurnaceLogic par2TileEntityFurnace)
{
this.furnace = par2TileEntityFurnace;
this.addSlotToContainer(new Slot(par2TileEntityFurnace, 0, 56, 17));
this.addSlotToContainer(new Slot(par2TileEntityFurnace, 1, 56, 53));
this.addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, par2TileEntityFurnace, 2, 116, 35));
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public void addCraftingToCrafters (ICrafting par1ICrafting)
{
super.addCraftingToCrafters(par1ICrafting);
par1ICrafting.sendProgressBarUpdate(this, 0, this.furnace.progress);
par1ICrafting.sendProgressBarUpdate(this, 1, this.furnace.fuel);
par1ICrafting.sendProgressBarUpdate(this, 2, this.furnace.fuelGague);
}
/**
* Looks for changes made in the container, sends them to every listener.
*/
@Override
public void detectAndSendChanges ()
{
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get(i);
if (this.lastCookTime != this.furnace.progress)
{
icrafting.sendProgressBarUpdate(this, 0, this.furnace.progress);
}
if (this.lastBurnTime != this.furnace.fuel)
{
icrafting.sendProgressBarUpdate(this, 1, this.furnace.fuel);
}
if (this.lastItemBurnTime != this.furnace.fuelGague)
{
icrafting.sendProgressBarUpdate(this, 2, this.furnace.fuelGague);
}
}
this.lastCookTime = this.furnace.progress;
this.lastBurnTime = this.furnace.fuel;
this.lastItemBurnTime = this.furnace.fuelGague;
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar (int par1, int par2)
{
if (par1 == 0)
{
this.furnace.progress = par2;
}
if (par1 == 1)
{
this.furnace.fuel = par2;
}
if (par1 == 2)
{
this.furnace.fuelGague = par2;
}
}
@Override
public boolean canInteractWith (EntityPlayer par1EntityPlayer)
{
return this.furnace.isUseableByPlayer(par1EntityPlayer);
}
/**
* Called when a player shift-clicks on a slot. You must override this or
* you will crash when someone does that.
*/
@Override
public ItemStack transferStackInSlot (EntityPlayer par1EntityPlayer, int par2)
{
ItemStack itemstack = null;
Slot slot = (Slot) this.inventorySlots.get(par2);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par2 == 2)
{
if (!this.mergeItemStack(itemstack1, 3, 39, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (par2 != 1 && par2 != 0)
{
if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null)
{
if (!this.mergeItemStack(itemstack1, 0, 1, false))
{
return null;
}
}
else if (TileEntityFurnace.isItemFuel(itemstack1))
{
if (!this.mergeItemStack(itemstack1, 1, 2, false))
{
return null;
}
}
else if (par2 >= 3 && par2 < 30)
{
if (!this.mergeItemStack(itemstack1, 30, 39, false))
{
return null;
}
}
else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}
slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
}
return itemstack;
}
}
@@ -0,0 +1,168 @@
package tconstruct.tools.inventory;
import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
public class InventoryCraftingStation extends InventoryCrafting
{
/** the width of the crafting inventory */
private int inventoryWidth;
/**
* Class containing the callbacks for the events on_GUIClosed and
* on_CraftMaxtrixChanged.
*/
private Container eventHandler;
private InventoryLogic logic;
public InventoryCraftingStation(Container par1Container, int size, int height, InventoryLogic logic)
{
super(par1Container, size, height);
this.eventHandler = par1Container;
this.inventoryWidth = size;
this.logic = logic;
}
/**
* Returns the number of slots in the inventory.
*/
@Override
public int getSizeInventory ()
{
return 9;
}
@Override
public ItemStack getStackInSlot (int slot)
{
return slot >= this.getSizeInventory() + 1 ? null : logic.getStackInSlot(slot + 1);
}
@Override
public ItemStack getStackInRowAndColumn (int row, int column)
{
if (row >= 0 && row < this.inventoryWidth)
{
int k = row + column * this.inventoryWidth;
return this.getStackInSlot(k);
}
else
{
return null;
}
}
public String getInvName ()
{
return "container.crafting";
}
public boolean isInvNameLocalized ()
{
return false;
}
@Override
public ItemStack getStackInSlotOnClosing (int par1)
{
return null;
}
/**
* 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 slotID, int par2)
{
ItemStack stack = logic.getStackInSlot(slotID + 1);
if (stack != null)
{
ItemStack itemstack;
if (stack.stackSize <= par2)
{
itemstack = stack.copy();
stack = null;
logic.setInventorySlotContents(slotID + 1, null);
this.eventHandler.onCraftMatrixChanged(this);
return itemstack;
}
else
{
itemstack = stack.splitStack(par2);
if (stack.stackSize == 0)
{
stack = null;
}
this.eventHandler.onCraftMatrixChanged(this);
return itemstack;
}
}
else
{
return null;
}
}
/**
* Sets the given item stack to the specified slot in the inventory (can be
* crafting or armor sections).
*/
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
logic.setInventorySlotContents(slot + 1, itemstack);
this.eventHandler.onCraftMatrixChanged(this);
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be
* 64, possibly will be extended. *Isn't this more of a set than a get?*
*/
@Override
public int getInventoryStackLimit ()
{
return 64;
}
/**
* Called when an the contents of an Inventory change, usually
*/
@Override
public void markDirty ()
{
}
/**
* Do not make give this method the name canInteractWith because it clashes
* with Container
*/
@Override
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
{
return true;
}
public void openChest ()
{
}
public void closeChest ()
{
}
/**
* Returns true if automation is allowed to insert the given stack (ignoring
* stack size) into the given slot.
*/
public boolean isStackValidForSlot (int par1, ItemStack par2ItemStack)
{
return true;
}
}
@@ -0,0 +1,138 @@
package tconstruct.tools.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.item.ItemStack;
import tconstruct.tools.logic.CraftingStationLogic;
public class InventoryCraftingStationResult extends InventoryCraftResult
{
CraftingStationLogic logic;
public InventoryCraftingStationResult(CraftingStationLogic logic)
{
this.logic = logic;
}
/**
* Returns the number of slots in the inventory.
*/
@Override
public int getSizeInventory ()
{
return 1;
}
/**
* Returns the stack in slot i
*/
@Override
public ItemStack getStackInSlot (int par1)
{
return logic.getStackInSlot(0);// this.stackResult[0];
}
/**
* Returns the name of the inventory.
*/
public String getInvName ()
{
return "Result";
}
/**
* If this returns false, the inventory name will be used as an unlocalized
* name, and translated into the player's language. Otherwise it will be
* used directly.
*/
public boolean isInvNameLocalized ()
{
return false;
}
/**
* 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 par1, int par2)
{
ItemStack stack = logic.getStackInSlot(0);
if (stack != null)
{
ItemStack itemstack = stack;
logic.setInventorySlotContents(0, null);
return itemstack;
}
else
{
return null;
}
}
/**
* 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 par1)
{
return null;
}
/**
* 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)
{
logic.setInventorySlotContents(0, par2ItemStack);
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be
* 64, possibly will be extended. *Isn't this more of a set than a get?*
*/
@Override
public int getInventoryStackLimit ()
{
return 64;
}
/**
* Called when an the contents of an Inventory change, usually
*/
@Override
public void markDirty ()
{
}
/**
* Do not make give this method the name canInteractWith because it clashes
* with Container
*/
@Override
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
{
return true;
}
public void openChest ()
{
}
public void closeChest ()
{
}
/**
* Returns true if automation is allowed to insert the given stack (ignoring
* stack size) into the given slot.
*/
public boolean isStackValidForSlot (int par1, ItemStack par2ItemStack)
{
return true;
}
}
@@ -0,0 +1,108 @@
package tconstruct.tools.inventory;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import tconstruct.armor.inventory.SlotOnlyTake;
import tconstruct.library.util.IPattern;
import tconstruct.smeltery.inventory.ActiveContainer;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.PartBuilderLogic;
import tconstruct.tools.logic.PatternChestLogic;
public class PartCrafterChestContainer extends ActiveContainer
{
protected PatternChestLogic patternLogic;
protected InventoryPlayer invPlayer;
protected PartBuilderLogic logic;
protected Slot[] input;
protected Slot[] inventory;
public boolean largeInventory;
public PartCrafterChestContainer(InventoryPlayer inventoryplayer, PartBuilderLogic partLogic, PatternChestLogic pLogic)
{
logic = partLogic;
patternLogic = pLogic;
largeInventory = true;
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), new Slot(partLogic, 3, 58, 45),
new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) };
for (int iter = 0; iter < inventory.length; iter++)
this.addSlotToContainer(inventory[iter]);
/* Holder inventory */
for (int column = 0; column < 5; column++)
{
for (int row = 0; row < 6; row++)
{
this.addSlotToContainer(new SlotPattern(pLogic, row + column * 6, -108 + row * 18, 30 + column * 18));
}
}
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory() + patternLogic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else
{
if (slotStack.getItem() instanceof IPattern)
{
if (!this.mergeItemStack(slotStack, 0, 2, false) && !this.mergeItemStack(slotStack, 8, 38, false))
return null;
}
else if (!this.mergeItemStack(slotStack, 2, 4, false))
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
logic.tryBuildPart(slotID);
}
slot.onSlotChanged();
}
return stack;
}
}
@@ -0,0 +1,96 @@
package tconstruct.tools.inventory;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import tconstruct.armor.inventory.SlotOnlyTake;
import tconstruct.library.util.IPattern;
import tconstruct.smeltery.inventory.ActiveContainer;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.PartBuilderLogic;
public class PartCrafterContainer extends ActiveContainer
{
protected InventoryPlayer invPlayer;
protected PartBuilderLogic logic;
protected Slot[] input;
protected Slot[] inventory;
public boolean largeInventory;
public PartCrafterContainer(InventoryPlayer inventoryplayer, PartBuilderLogic partLogic)
{
invPlayer = inventoryplayer;
logic = partLogic;
largeInventory = false;
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), new Slot(partLogic, 3, 58, 45),
new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) };
for (int iter = 0; iter < inventory.length; iter++)
this.addSlotToContainer(inventory[iter]);
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else
{
if (slotStack.getItem() instanceof IPattern)
{
if (!this.mergeItemStack(slotStack, 0, 2, false))
return null;
}
else if (!this.mergeItemStack(slotStack, 2, 4, false))
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
logic.tryBuildPart(slotID);
}
slot.onSlotChanged();
}
return stack;
}
}
@@ -0,0 +1,99 @@
package tconstruct.tools.inventory;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import tconstruct.library.util.IPattern;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.PatternChestLogic;
public class PatternChestContainer extends Container
{
public PatternChestLogic logic;
public int progress = 0;
public int fuel = 0;
public int fuelGague = 0;
public PatternChestContainer(InventoryPlayer inventoryplayer, PatternChestLogic chest)
{
logic = chest;
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 10; row++)
{
this.addSlotToContainer(new SlotPattern(chest, row + column * 10, 8 + row * 18, 18 + column * 18));
}
}
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 17 + row * 18, 86 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 17 + column * 18, 144));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
@Override
protected boolean mergeItemStack (ItemStack stack, int inventorySize, int slotSize, boolean par4)
{
if (!(stack.getItem() instanceof IPattern))
return false;
return super.mergeItemStack(stack, inventorySize, slotSize, par4);
}
}
@@ -0,0 +1,111 @@
package tconstruct.tools.inventory;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import tconstruct.armor.inventory.SlotOnlyTake;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.StencilTableLogic;
public class PatternShaperContainer extends Container
{
public StencilTableLogic logic;
public PatternShaperContainer(InventoryPlayer inventoryplayer, StencilTableLogic shaper)
{
logic = shaper;
this.addSlotToContainer(new Slot(shaper, 0, 48, 35));
this.addSlotToContainer(new SlotOnlyTake(shaper, 1, 106, 35));
/*for (int i = 0; i < 3; i++)
{
for (int l = 0; l < 3; l++)
{
this.addSlotToContainer(new Slot(craftMatrix, l + i * 3, 30 + l * 18, 17 + i * 18));
}
}*/
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
}
}
/*public void onCraftMatrixChanged(IInventory iinventory)
{
craftResult.setInventorySloTRepos(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
}*/
/*@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
if (logic.worldObj.isRemote)
{
return;
}
ItemStack itemstack = logic.getStackInSlot(0);
if (itemstack != null)
{
entityplayer.dropPlayerItem(itemstack);
}
}*/
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
return null;
/*ItemStack stack = null;
Slot slot = (Slot)this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory()-1, false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return stack;*/
}
}
@@ -0,0 +1,37 @@
package tconstruct.tools.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.achievements.TAchievements;
public class SlotFrypan extends Slot
{
public EntityPlayer player;
public SlotFrypan(IInventory par1IInventory, int par2, int par3, int par4, EntityPlayer player)
{
super(par1IInventory, par2, par3, par4);
this.player = player;
}
@Override
public void putStack (ItemStack par1ItemStack)
{
super.putStack(par1ItemStack);
if (par1ItemStack != null && par1ItemStack.getItem() != null && par1ItemStack.getItem() instanceof ItemFood && par1ItemStack.hasTagCompound())
{
NBTTagCompound stackTagCompound = par1ItemStack.getTagCompound();
if (stackTagCompound == null || !stackTagCompound.getBoolean("frypanKill"))
{
return;
}
player.addStat(TAchievements.achievements.get("tconstruct:dualConvenience"), 1);
}
}
}
@@ -0,0 +1,20 @@
package tconstruct.tools.inventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotPartBuilder extends Slot
{
public SlotPartBuilder(IInventory inv, int index, int posX, int posY)
{
super(inv, index, posX, posY);
}
@Override
protected void onCrafting (ItemStack par1ItemStack, int par2)
{
}
}
@@ -0,0 +1,23 @@
package tconstruct.tools.inventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import tconstruct.library.util.IPattern;
public class SlotPattern extends Slot
{
public SlotPattern(IInventory builder, int par3, int par4, int par5)
{
super(builder, par3, par4, par5);
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
@Override
public boolean isItemValid (ItemStack stack)
{
return stack.getItem() instanceof IPattern;
}
}
@@ -0,0 +1,80 @@
package tconstruct.tools.inventory;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import tconstruct.library.event.ToolCraftedEvent;
import tconstruct.library.tools.ToolCore;
public class SlotTool extends Slot
{
/** The player that is using the GUI where this slot resides. */
public EntityPlayer player;
Random random = new Random();
public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
{
super(builder, par3, par4, par5);
this.player = entityplayer;
}
/**
* Check if the stack is a valid item for this slot. Always true beside for
* the armor slots.
*/
@Override
public boolean isItemValid (ItemStack stack)
{
return false;
// return stack.getItem() instanceof ToolCore;
}
@Override
public void onPickupFromSlot (EntityPlayer par1EntityPlayer, ItemStack stack)
{
this.onCrafting(stack);
// stack.setUnlocalizedName("\u00A7f" + toolName);
super.onPickupFromSlot(par1EntityPlayer, stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
* not ore and wood. Typically increases an internal count then calls
* onCrafting(item).
*/
@Override
protected void onCrafting (ItemStack stack, int par2)
{
// this.field_75228_b += par2;
this.onCrafting(stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
* not ore and wood.
*/
@Override
protected void onCrafting (ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
{
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null);
for (int i = 2; i <= 3; i++)
inventory.decrStackSize(i, 1);
int amount = inventory.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
inventory.decrStackSize(1, amount);
if (!player.worldObj.isRemote && full)
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
// player.worldObj.playAuxSFX(1021, (int)player.posX,
// (int)player.posY, (int)player.posZ, 0);
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.inventory, player, stack));
}
}
}
@@ -0,0 +1,40 @@
package tconstruct.tools.inventory;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import tconstruct.library.event.ToolCraftedEvent;
import tconstruct.library.tools.ToolCore;
public class SlotToolForge extends SlotTool
{
/** The player that is using the GUI where this slot resides. */
Random random = new Random();
public SlotToolForge(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
{
super(entityplayer, builder, par3, par4, par5);
}
@Override
protected void onCrafting (ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
{
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null);
for (int i = 2; i <= 4; i++)
inventory.decrStackSize(i, 1);
int amount = inventory.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
inventory.decrStackSize(1, amount);
if (!player.worldObj.isRemote && full)
player.worldObj.playAuxSFX(1021, (int) player.posX, (int) player.posY, (int) player.posZ, 0);
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.inventory, player, stack));
}
}
}
@@ -0,0 +1,102 @@
package tconstruct.tools.inventory;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolCore;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.ToolForgeLogic;
import tconstruct.tools.logic.ToolStationLogic;
public class ToolForgeContainer extends ToolStationContainer
{
public ToolForgeContainer(InventoryPlayer inventoryplayer, ToolForgeLogic logic)
{
super(inventoryplayer, logic);
}
@Override
public void initializeContainer (InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{
invPlayer = inventoryplayer;
this.logic = builderlogic;
toolSlot = new SlotToolForge(inventoryplayer.player, logic, 0, 225, 38);
this.addSlotToContainer(toolSlot);
slots = new Slot[] { new Slot(logic, 1, 167, 29), new Slot(logic, 2, 169, 29), new Slot(logic, 3, 167, 47), new Slot(logic, 4, 149, 47) };
for (int iter = 0; iter < 4; iter++)
this.addSlotToContainer(slots[iter]);
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 118 + column * 18, 142));
}
}
// posX and posY must be the same length
@Override
public void resetSlots (int[] posX, int[] posY)
{
inventorySlots.clear();
inventoryItemStacks.clear();
this.addSlotToContainer(toolSlot);
for (int iter = 0; iter < 4; iter++)
{
slots[iter].xDisplayPosition = posX[iter] + 111;
slots[iter].yDisplayPosition = posY[iter] + 1;
addSlotToContainer(slots[iter]);
}
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(invPlayer, column, 118 + column * 18, 142));
}
}
@Override
protected void craftTool (ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
{
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
for (int i = 2; i <= 4; i++)
logic.decrStackSize(i, 1);
int amount = logic.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
logic.decrStackSize(1, amount);
if (!logic.getWorldObj().isRemote)
logic.getWorldObj().playAuxSFX(1021, (int) logic.xCoord, (int) logic.yCoord, (int) logic.zCoord, 0);
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolForge && block != TinkerTools.craftingSlabWood)
return false;
return logic.isUseableByPlayer(entityplayer);
}
}
@@ -0,0 +1,233 @@
package tconstruct.tools.inventory;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolCore;
import tconstruct.smeltery.inventory.ActiveContainer;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.ToolStationLogic;
public class ToolStationContainer extends ActiveContainer
{
public InventoryPlayer invPlayer;
public ToolStationLogic logic;
public Slot[] slots;
public SlotTool toolSlot;
public Random random = new Random();
public ToolStationContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{
initializeContainer(inventoryplayer, builderlogic);
}
public void initializeContainer (InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{
invPlayer = inventoryplayer;
logic = builderlogic;
toolSlot = new SlotTool(inventoryplayer.player, builderlogic, 0, 225, 38);
this.addSlotToContainer(toolSlot);
slots = new Slot[] { new Slot(builderlogic, 1, 167, 29), new Slot(builderlogic, 2, 149, 38), new Slot(builderlogic, 3, 167, 47) };
for (int iter = 0; iter < 3; iter++)
this.addSlotToContainer(slots[iter]);
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(inventoryplayer, column, 118 + column * 18, 142));
}
}
// posX and posY must be the same length
public void resetSlots (int[] posX, int[] posY)
{
/* Station inventory */
inventorySlots.clear();
inventoryItemStacks.clear();
this.addSlotToContainer(toolSlot);
for (int iter = 0; iter < 3; iter++)
{
slots[iter].xDisplayPosition = posX[iter] + 111;
slots[iter].yDisplayPosition = posY[iter] + 1;
addSlotToContainer(slots[iter]);
}
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
this.addSlotToContainer(new Slot(invPlayer, column, 118 + column * 18, 142));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (slotID == 0)
{
if (!this.mergeCraftedStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true, player))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 1, logic.getSizeInventory(), false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
protected void craftTool (ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
{
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
for (int i = 2; i <= 3; i++)
logic.decrStackSize(i, 1);
int amount = logic.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
logic.decrStackSize(1, amount);
logic.getWorldObj().playSoundEffect(logic.xCoord, logic.yCoord, logic.zCoord, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
}
}
protected boolean mergeCraftedStack (ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player)
{
boolean failedToMerge = false;
int slotIndex = slotsStart;
if (playerInventory)
{
slotIndex = slotsTotal - 1;
}
Slot otherInventorySlot;
ItemStack copyStack = null;
/*
* if (stack.isStackable()) { while (stack.stackSize > 0 &&
* (!playerInventory && slotIndex < slotsTotal || playerInventory &&
* slotIndex >= slotsStart)) { otherInventorySlot =
* (Slot)this.inventorySlots.get(slotIndex); copyStack =
* otherInventorySlot.getStack();
*
* if (copyStack != null && copyStack.itemID == stack.itemID &&
* (!stack.getHasSubtypes() || stack.getItemDamage() ==
* copyStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack,
* copyStack)) { int totalSize = copyStack.stackSize + stack.stackSize;
*
* if (totalSize <= stack.getMaxStackSize()) { stack.stackSize = 0;
* copyStack.stackSize = totalSize; otherInventorySlot.onSlotChanged();
* failedToMerge = true; } else if (copyStack.stackSize <
* stack.getMaxStackSize()) { stack.stackSize -= stack.getMaxStackSize()
* - copyStack.stackSize; copyStack.stackSize = stack.getMaxStackSize();
* otherInventorySlot.onSlotChanged(); failedToMerge = true; } }
*
* if (playerInventory) { --slotIndex; } else { ++slotIndex; } } }
*/
if (stack.stackSize > 0)
{
if (playerInventory)
{
slotIndex = slotsTotal - 1;
}
else
{
slotIndex = slotsStart;
}
while (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart)
{
otherInventorySlot = (Slot) this.inventorySlots.get(slotIndex);
copyStack = otherInventorySlot.getStack();
if (copyStack == null)
{
craftTool(stack);
otherInventorySlot.putStack(stack.copy());
otherInventorySlot.onSlotChanged();
stack.stackSize = 0;
failedToMerge = true;
break;
}
if (playerInventory)
{
--slotIndex;
}
else
{
++slotIndex;
}
}
}
/*
* boolean emptySlots = ( ((Slot) inventorySlots.get(2)).getStack() ==
* null && ((Slot) inventorySlots.get(3)).getStack() == null );
* TConstruct.logger.info("Empty slots"); if (!failedToMerge &&
* emptySlots) player.worldObj.playAuxSFX(1021, (int)player.posX,
* (int)player.posY, (int)player.posZ, 0);
*/
return failedToMerge;
}
}