mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-25 14:34:23 +00:00
Comp Drawer extraction working now
This commit is contained in:
1 parent
4b872d889f
commit
c4be02f9c0
2 files changed
+52
-4
No files matched your search
@@ -61,13 +61,29 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
return new CompDrawerData(getCentralInventory(), slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDrawerEnabled (int slot) {
|
||||
if (slot > 0 && convRate[slot] == 0)
|
||||
return false;
|
||||
|
||||
return super.isDrawerEnabled(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int putItemsIntoSlot (int slot, ItemStack stack, int count) {
|
||||
if (stack != null && convRate != null && convRate[0] == 0) {
|
||||
populateSlots(stack);
|
||||
int added = 0;
|
||||
|
||||
for (int i = 0; i < getDrawerCount(); i++) {
|
||||
if (BaseDrawerData.areItemsEqual(protoStack[i], stack))
|
||||
return super.putItemsIntoSlot(i, stack, count);
|
||||
added = super.putItemsIntoSlot(i, stack, count);
|
||||
}
|
||||
|
||||
for (int i = 0; i < getDrawerCount(); i++) {
|
||||
IDrawer drawer = getDrawer(i);
|
||||
if (drawer instanceof CompDrawerData)
|
||||
((CompDrawerData) drawer).refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +334,7 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
populateSlots(itemPrototype);
|
||||
for (int i = 0; i < getDrawerCount(); i++) {
|
||||
if (BaseDrawerData.areItemsEqual(protoStack[i], itemPrototype))
|
||||
setStoredItemCount(i, amount);
|
||||
pooledCount = (pooledCount % convRate[slot]) + convRate[slot] * amount;
|
||||
}
|
||||
|
||||
for (int i = 0; i < getDrawerCount(); i++) {
|
||||
@@ -329,6 +345,14 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
if (drawer instanceof CompDrawerData)
|
||||
((CompDrawerData) drawer).refresh();
|
||||
}
|
||||
|
||||
if (worldObj != null && !worldObj.isRemote) {
|
||||
//TileEntityDrawersComp.this.markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
else if (itemPrototype == null) {
|
||||
setStoredItemCount(slot, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,8 +375,13 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
if (pooledCount != oldCount) {
|
||||
if (pooledCount != 0)
|
||||
markAmountDirty();
|
||||
else
|
||||
else {
|
||||
clear();
|
||||
if (worldObj != null && !worldObj.isRemote) {
|
||||
//TileEntityDrawersComp.this.markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +416,7 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
TileEntityDrawersComp.this.markDirty();
|
||||
}
|
||||
|
||||
private void refresh () {
|
||||
public void refresh () {
|
||||
for (int i = 0; i < getDrawerCount(); i++) {
|
||||
IDrawer drawer = getDrawer(i);
|
||||
if (drawer instanceof CompDrawerData)
|
||||
|
||||
@@ -77,6 +77,9 @@ public class StorageInventory implements IDrawerInventory
|
||||
if (drawer == null)
|
||||
return false;
|
||||
|
||||
if (drawer.getStoredItemCount() == 0)
|
||||
return false;
|
||||
|
||||
return drawer.canItemBeExtracted(item);
|
||||
}
|
||||
|
||||
@@ -185,6 +188,9 @@ public class StorageInventory implements IDrawerInventory
|
||||
drawer.setStoredItem(null, 0);
|
||||
else {
|
||||
drawer.setStoredItem(item, 0);
|
||||
drawer = findDrawer(item);
|
||||
if (drawer == null)
|
||||
return;
|
||||
|
||||
int insertCount = item.stackSize;
|
||||
if (insertCount > drawer.getMaxCapacity())
|
||||
@@ -195,6 +201,19 @@ public class StorageInventory implements IDrawerInventory
|
||||
}
|
||||
}
|
||||
|
||||
private IDrawer findDrawer (ItemStack item) {
|
||||
for (int i = 0; i < group.getDrawerCount(); i++) {
|
||||
if (!group.isDrawerEnabled(i))
|
||||
continue;
|
||||
|
||||
IDrawer drawer = group.getDrawer(i);
|
||||
if (drawer.canItemBeStored(item))
|
||||
return drawer;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName () {
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user