Make exporter less fast too
This commit is contained in:
@@ -13,6 +13,8 @@ import refinedstorage.util.InventoryUtils;
|
|||||||
public class TileExporter extends TileMachine implements ICompareSetting {
|
public class TileExporter extends TileMachine implements ICompareSetting {
|
||||||
public static final String NBT_COMPARE = "Compare";
|
public static final String NBT_COMPARE = "Compare";
|
||||||
|
|
||||||
|
public static final int SPEED = 3;
|
||||||
|
|
||||||
private InventorySimple inventory = new InventorySimple("exporter", 9, this);
|
private InventorySimple inventory = new InventorySimple("exporter", 9, this);
|
||||||
|
|
||||||
private int compare = 0;
|
private int compare = 0;
|
||||||
@@ -24,19 +26,18 @@ public class TileExporter extends TileMachine implements ICompareSetting {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMachine() {
|
public void updateMachine() {
|
||||||
TileEntity tile = worldObj.getTileEntity(pos.offset(getDirection()));
|
TileEntity connectedTile = worldObj.getTileEntity(pos.offset(getDirection()));
|
||||||
|
|
||||||
if (tile instanceof IInventory) {
|
if (connectedTile instanceof IInventory) {
|
||||||
IInventory connectedInventory = (IInventory) tile;
|
IInventory connectedInventory = (IInventory) connectedTile;
|
||||||
|
|
||||||
if (ticks % 5 == 0) {
|
if (ticks % SPEED == 0) {
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||||
ItemStack slot = inventory.getStackInSlot(i);
|
ItemStack slot = inventory.getStackInSlot(i);
|
||||||
|
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
ItemStack toTake = slot.copy();
|
ItemStack toTake = slot.copy();
|
||||||
|
toTake.stackSize = 1;
|
||||||
toTake.stackSize = 64;
|
|
||||||
|
|
||||||
ItemStack took = getController().take(toTake, compare);
|
ItemStack took = getController().take(toTake, compare);
|
||||||
|
|
||||||
|
@@ -48,10 +48,10 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addItems(List<StorageItem> items) {
|
public void addItems(List<StorageItem> items) {
|
||||||
TileEntity connectedInventory = getConnectedInventory();
|
TileEntity connectedTile = getConnectedTile();
|
||||||
|
|
||||||
if (connectedInventory instanceof IDeepStorageUnit) {
|
if (connectedTile instanceof IDeepStorageUnit) {
|
||||||
IDeepStorageUnit deep = (IDeepStorageUnit) connectedInventory;
|
IDeepStorageUnit deep = (IDeepStorageUnit) connectedTile;
|
||||||
|
|
||||||
if (deep.getStoredItemType() != null) {
|
if (deep.getStoredItemType() != null) {
|
||||||
ItemStack stack = deep.getStoredItemType().copy();
|
ItemStack stack = deep.getStoredItemType().copy();
|
||||||
@@ -60,8 +60,8 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
items.add(new StorageItem(stack.splitStack(Math.min(stack.getMaxStackSize(), stack.stackSize))));
|
items.add(new StorageItem(stack.splitStack(Math.min(stack.getMaxStackSize(), stack.stackSize))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (connectedInventory instanceof IInventory) {
|
} else if (connectedTile instanceof IInventory) {
|
||||||
IInventory inventory = (IInventory) connectedInventory;
|
IInventory inventory = (IInventory) connectedTile;
|
||||||
|
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||||
if (inventory.getStackInSlot(i) != null) {
|
if (inventory.getStackInSlot(i) != null) {
|
||||||
@@ -73,29 +73,29 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void push(ItemStack stack) {
|
public void push(ItemStack stack) {
|
||||||
TileEntity connectedInventory = getConnectedInventory();
|
TileEntity connectedTile = getConnectedTile();
|
||||||
|
|
||||||
if (connectedInventory instanceof IDeepStorageUnit) {
|
if (connectedTile instanceof IDeepStorageUnit) {
|
||||||
IDeepStorageUnit deep = (IDeepStorageUnit) connectedInventory;
|
IDeepStorageUnit deep = (IDeepStorageUnit) connectedTile;
|
||||||
|
|
||||||
if (deep.getStoredItemType() == null) {
|
if (deep.getStoredItemType() == null) {
|
||||||
deep.setStoredItemType(stack, stack.stackSize);
|
deep.setStoredItemType(stack, stack.stackSize);
|
||||||
} else {
|
} else {
|
||||||
deep.setStoredItemCount(deep.getStoredItemType().stackSize + stack.stackSize);
|
deep.setStoredItemCount(deep.getStoredItemType().stackSize + stack.stackSize);
|
||||||
}
|
}
|
||||||
} else if (connectedInventory instanceof IInventory) {
|
} else if (connectedTile instanceof IInventory) {
|
||||||
InventoryUtils.pushToInventory((IInventory) connectedInventory, stack);
|
InventoryUtils.pushToInventory((IInventory) connectedTile, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack take(ItemStack stack, int flags) {
|
public ItemStack take(ItemStack stack, int flags) {
|
||||||
TileEntity connectedInventory = getConnectedInventory();
|
TileEntity connectedTile = getConnectedTile();
|
||||||
|
|
||||||
int quantity = stack.stackSize;
|
int quantity = stack.stackSize;
|
||||||
|
|
||||||
if (connectedInventory instanceof IDeepStorageUnit) {
|
if (connectedTile instanceof IDeepStorageUnit) {
|
||||||
IDeepStorageUnit deep = (IDeepStorageUnit) connectedInventory;
|
IDeepStorageUnit deep = (IDeepStorageUnit) connectedTile;
|
||||||
|
|
||||||
if (deep.getStoredItemType() != null && InventoryUtils.compareStackNoQuantity(deep.getStoredItemType(), stack)) {
|
if (deep.getStoredItemType() != null && InventoryUtils.compareStackNoQuantity(deep.getStoredItemType(), stack)) {
|
||||||
if (deep.getStoredItemType().stackSize < quantity) {
|
if (deep.getStoredItemType().stackSize < quantity) {
|
||||||
@@ -109,8 +109,8 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
|
|
||||||
return took;
|
return took;
|
||||||
}
|
}
|
||||||
} else if (connectedInventory instanceof IInventory) {
|
} else if (connectedTile instanceof IInventory) {
|
||||||
IInventory inventory = (IInventory) connectedInventory;
|
IInventory inventory = (IInventory) connectedTile;
|
||||||
|
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||||
ItemStack slot = inventory.getStackInSlot(i);
|
ItemStack slot = inventory.getStackInSlot(i);
|
||||||
@@ -141,10 +141,10 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
@Override
|
@Override
|
||||||
public boolean canPush(ItemStack stack) {
|
public boolean canPush(ItemStack stack) {
|
||||||
if (ModeSettingUtils.doesNotViolateMode(inventory, this, compare, stack)) {
|
if (ModeSettingUtils.doesNotViolateMode(inventory, this, compare, stack)) {
|
||||||
TileEntity connectedInventory = getConnectedInventory();
|
TileEntity connectedTile = getConnectedTile();
|
||||||
|
|
||||||
if (connectedInventory instanceof IDeepStorageUnit) {
|
if (connectedTile instanceof IDeepStorageUnit) {
|
||||||
IDeepStorageUnit deep = (IDeepStorageUnit) connectedInventory;
|
IDeepStorageUnit deep = (IDeepStorageUnit) connectedTile;
|
||||||
|
|
||||||
if (deep.getStoredItemType() != null) {
|
if (deep.getStoredItemType() != null) {
|
||||||
if (InventoryUtils.compareStackNoQuantity(deep.getStoredItemType(), stack)) {
|
if (InventoryUtils.compareStackNoQuantity(deep.getStoredItemType(), stack)) {
|
||||||
@@ -155,15 +155,15 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
} else {
|
} else {
|
||||||
return stack.stackSize < deep.getMaxStoredCount();
|
return stack.stackSize < deep.getMaxStoredCount();
|
||||||
}
|
}
|
||||||
} else if (connectedInventory instanceof IInventory) {
|
} else if (connectedTile instanceof IInventory) {
|
||||||
return InventoryUtils.canPushToInventory((IInventory) connectedInventory, stack);
|
return InventoryUtils.canPushToInventory((IInventory) connectedTile, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileEntity getConnectedInventory() {
|
public TileEntity getConnectedTile() {
|
||||||
TileEntity tile = worldObj.getTileEntity(pos.offset(getDirection()));
|
TileEntity tile = worldObj.getTileEntity(pos.offset(getDirection()));
|
||||||
|
|
||||||
if (tile instanceof IInventory || tile instanceof IDeepStorageUnit) {
|
if (tile instanceof IInventory || tile instanceof IDeepStorageUnit) {
|
||||||
@@ -179,14 +179,14 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
|
|
||||||
buf.writeInt(priority);
|
buf.writeInt(priority);
|
||||||
|
|
||||||
TileEntity connectedInventory = getConnectedInventory();
|
TileEntity connectedTile = getConnectedTile();
|
||||||
|
|
||||||
if (connectedInventory instanceof IDeepStorageUnit) {
|
if (connectedTile instanceof IDeepStorageUnit) {
|
||||||
IDeepStorageUnit deep = (IDeepStorageUnit) connectedInventory;
|
IDeepStorageUnit deep = (IDeepStorageUnit) connectedTile;
|
||||||
|
|
||||||
buf.writeInt(deep.getStoredItemType() == null ? 0 : deep.getStoredItemType().stackSize);
|
buf.writeInt(deep.getStoredItemType() == null ? 0 : deep.getStoredItemType().stackSize);
|
||||||
} else if (connectedInventory instanceof IInventory) {
|
} else if (connectedTile instanceof IInventory) {
|
||||||
buf.writeInt(InventoryUtils.getInventoryItems((IInventory) connectedInventory));
|
buf.writeInt(InventoryUtils.getInventoryItems((IInventory) connectedTile));
|
||||||
} else {
|
} else {
|
||||||
buf.writeInt(0);
|
buf.writeInt(0);
|
||||||
}
|
}
|
||||||
@@ -314,11 +314,11 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCapacity() {
|
public int getCapacity() {
|
||||||
if (getConnectedInventory() == null) {
|
if (getConnectedTile() == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity connectedInventory = getConnectedInventory();
|
TileEntity connectedInventory = getConnectedTile();
|
||||||
|
|
||||||
if (connectedInventory instanceof IDeepStorageUnit) {
|
if (connectedInventory instanceof IDeepStorageUnit) {
|
||||||
return ((IDeepStorageUnit) connectedInventory).getMaxStoredCount();
|
return ((IDeepStorageUnit) connectedInventory).getMaxStoredCount();
|
||||||
|
Reference in New Issue
Block a user