mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-21 12:42:24 +00:00
Fix dupe bug with compacting drawers and AE2
This commit is contained in:
1 parent
88c1976052
commit
2991374e6b
7 files changed
+73
-16
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ buildscript {
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.7.10-1.9.8"
|
||||
version = "1.7.10-1.9.9"
|
||||
group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "StorageDrawers"
|
||||
|
||||
|
||||
@@ -22,9 +22,20 @@ public interface IDrawer
|
||||
*
|
||||
* @param itemPrototype An ItemStack representing the type, metadata, and tags of the item to store.
|
||||
* @param amount The amount to initialize the stored item count to.
|
||||
* @deprecated setStoredItem may redirect its set to another IDrawer, so use setStoredItemRedir instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setStoredItem (ItemStack itemPrototype, int amount);
|
||||
|
||||
/**
|
||||
* Sets the type of the stored item and initializes it to the given amount. Any existing item will be replaced.
|
||||
*
|
||||
* @param itemPrototype An ItemStack representing the type, metadata, and tags of the item to store.
|
||||
* @param amount The amount to initialize the stored item count to.
|
||||
* @return The IDrawer actually set with the prototype. Some drawer groups can redirect a set operation to another member.
|
||||
*/
|
||||
IDrawer setStoredItemRedir (ItemStack itemPrototype, int amount);
|
||||
|
||||
/**
|
||||
* Gets the number of items stored in this drawer.
|
||||
*/
|
||||
|
||||
@@ -503,12 +503,15 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredItem (int slot, ItemStack itemPrototype, int amount) {
|
||||
public IDrawer setStoredItem (int slot, ItemStack itemPrototype, int amount) {
|
||||
if (itemPrototype != null && convRate != null && convRate[0] == 0) {
|
||||
IDrawer target = null;
|
||||
populateSlots(itemPrototype);
|
||||
for (int i = 0; i < getDrawerCount(); i++) {
|
||||
if (BaseDrawerData.areItemsEqual(protoStack[i], itemPrototype))
|
||||
if (BaseDrawerData.areItemsEqual(protoStack[i], itemPrototype)) {
|
||||
target = getDrawer(i);
|
||||
pooledCount = (pooledCount % convRate[i]) + convRate[i] * amount;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < getDrawerCount(); i++) {
|
||||
@@ -524,10 +527,18 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
//TileEntityDrawersComp.this.markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
else if (itemPrototype == null) {
|
||||
setStoredItemCount(slot, 0);
|
||||
//setStoredItemCount(slot, 0);
|
||||
pooledCount = 0;
|
||||
clear();
|
||||
if (worldObj != null && !worldObj.isRemote)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
return getDrawer(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,9 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class DrawerMEInventory implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
@@ -28,18 +30,34 @@ public class DrawerMEInventory implements IMEInventory<IAEItemStack>
|
||||
long itemsLeft = input.getStackSize();
|
||||
|
||||
if (group instanceof ISmartGroup) {
|
||||
for (int slot : ((ISmartGroup) group).enumerateDrawersForInsertion(input.getItemStack(), false)) {
|
||||
IDrawer drawer = group.getDrawer(slot);
|
||||
ItemStack itemProto = drawer.getStoredItemPrototype();
|
||||
if (itemProto == null)
|
||||
drawer.setStoredItem(input.getItemStack(), 0);
|
||||
List<IDrawer> clearSet = null;
|
||||
if (type == Actionable.SIMULATE)
|
||||
clearSet = new ArrayList<IDrawer>();
|
||||
|
||||
itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type);
|
||||
try {
|
||||
for (int slot : ((ISmartGroup) group).enumerateDrawersForInsertion(input.getItemStack(), false)) {
|
||||
IDrawer drawer = group.getDrawer(slot);
|
||||
ItemStack itemProto = drawer.getStoredItemPrototype();
|
||||
if (itemProto == null) {
|
||||
drawer = drawer.setStoredItemRedir(input.getItemStack(), 0);
|
||||
if (clearSet != null)
|
||||
clearSet.add(drawer);
|
||||
}
|
||||
|
||||
if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid())
|
||||
itemsLeft = 0;
|
||||
if (itemsLeft == 0)
|
||||
return null;
|
||||
if (drawer.canItemBeStored(input.getItemStack()))
|
||||
itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type);
|
||||
|
||||
if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid())
|
||||
itemsLeft = 0;
|
||||
if (itemsLeft == 0)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (clearSet != null) {
|
||||
for (IDrawer drawer : clearSet)
|
||||
drawer.setStoredItemRedir(null, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -83,7 +101,7 @@ public class DrawerMEInventory implements IMEInventory<IAEItemStack>
|
||||
if (itemProto == null) {
|
||||
itemProto = input.getItemStack();
|
||||
if (drawer.canItemBeStored(itemProto)) {
|
||||
drawer.setStoredItem(itemProto, 0);
|
||||
drawer = drawer.setStoredItemRedir(itemProto, 0);
|
||||
itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type);
|
||||
if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid())
|
||||
itemsLeft = 0;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.storage;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IFractionalDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IShroudable;
|
||||
@@ -34,6 +35,14 @@ public class CompDrawerData extends BaseDrawerData implements IFractionalDrawer,
|
||||
// markDirty
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawer setStoredItemRedir (ItemStack itemPrototype, int amount) {
|
||||
IDrawer target = central.setStoredItem(slot, itemPrototype, amount);
|
||||
refresh();
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredItemCount () {
|
||||
return central.getStoredItemCount(slot);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.storage;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IShroudable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
||||
@@ -41,6 +42,12 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
|
||||
setStoredItem(itemPrototype, amount, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawer setStoredItemRedir (ItemStack itemPrototype, int amount) {
|
||||
setStoredItem(itemPrototype, amount, true);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void setStoredItem (ItemStack itemPrototype, int amount, boolean mark) {
|
||||
if (itemPrototype == null) {
|
||||
setStoredItemCount(0, false, true);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.storage;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -8,7 +9,7 @@ public interface ICentralInventory
|
||||
{
|
||||
public ItemStack getStoredItemPrototype (int slot);
|
||||
|
||||
public void setStoredItem (int slot, ItemStack itemPrototype, int amount);
|
||||
public IDrawer setStoredItem (int slot, ItemStack itemPrototype, int amount);
|
||||
|
||||
public int getStoredItemCount (int slot);
|
||||
|
||||
|
||||
Reference in new issue
Block a user