Skip to content

Commit

Permalink
Fixing customChest bug and changing version to 1.0.4_beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Otho committed Dec 5, 2014
1 parent 7096fbb commit 61c362a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "1.0_beta_4-1.7.10"
version = "1.0.4_beta_1.7.10"
group= "com.Otho.customItems" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "customItems"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,36 +63,58 @@ protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
}

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int i)
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
{
//TODO: FIX THIS THING
ItemStack itemstack = null;
Slot slot = (Slot) inventorySlots.get(i);
Slot slotObj = (Slot) inventorySlots.get(slot);
int invSize = tileEntity.getSizeInventory();
int maxStackSize = tileEntity.getInventoryStackLimit();

if (slot != null && slot.getHasStack())
if (slotObj != null && slotObj.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
ItemStack itemstack1 = slotObj.getStack();
itemstack = itemstack1.copy();
if (i < invSize)

//From chest to player
if (slot < invSize)
{
if (!mergeItemStack(itemstack1, invSize, inventorySlots.size(), true))
{
if (itemstack1.stackSize == 0)
{
slotObj.putStack(null);
}
else
{
slotObj.onSlotChanged();
}

return null;
}
}
}
//From player to chest
else if (!mergeItemStack(itemstack1, 0, invSize, false))
{
if (itemstack1.stackSize == 0)
{
slotObj.putStack(null);
}
else
{
slotObj.onSlotChanged();
}

return null;
}

if (itemstack1.stackSize == 0)
{
slot.putStack(null);
//mergeItemStack(itemstack1, size, inventorySlots.size(), true);
slotObj.putStack(null);
}
else
{
slot.onSlotChanged();
slotObj.onSlotChanged();
}
}
return itemstack;
Expand Down Expand Up @@ -141,26 +163,27 @@ else if (itemstack1.stackSize < incomingStack.getMaxStackSize())
}
}else
{
int l = itemstack1.stackSize + incomingStack.stackSize;

if (l <= incomingStack.getMaxStackSize() && l <= tileEntity.getInventoryStackLimit())
{
incomingStack.stackSize = 0;
itemstack1.stackSize = l;
int sum = itemstack1.stackSize + incomingStack.stackSize;
int maxInInvSlot = tileEntity.getInventoryStackLimit();
int maxStackSize = itemstack1.getMaxStackSize();
int incoming = incomingStack.stackSize;
int actual = itemstack1.stackSize;

int cabe = Math.min((maxInInvSlot - actual), (maxStackSize - actual));

if(incoming <= cabe){
//soma
incomingStack.stackSize = 0;
itemstack1.stackSize += incoming;
slot.onSlotChanged();
flag1 = true;
}
else if (itemstack1.stackSize < tileEntity.getInventoryStackLimit())
{
incomingStack.stackSize -= tileEntity.getInventoryStackLimit() - itemstack1.stackSize;
itemstack1.stackSize = tileEntity.getInventoryStackLimit();
}else{
incomingStack.stackSize -= cabe;
itemstack1.stackSize += cabe;
slot.onSlotChanged();
flag1 = false;
}else
{
flag1 = false;
break;
}

}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
"modid": "customitems",
"name": "Custom Items",
"description": "A simple way to add your stuff to minecraft.",
"version": "1.0.4beta",
"description": "A simple way to add your custom stuff to minecraft.",
"version": "1.0.4 beta",
"mcversion": "1.7.10",
"url": "https://github.com/0tho/CustomItems",
"updateUrl": "",
Expand Down

0 comments on commit 61c362a

Please sign in to comment.