Fix unnecessary copies

This commit is contained in:
Raoul Van den Berge
2016-06-03 22:59:25 +02:00
parent 41f3ff7c74
commit 446568a9d1
4 changed files with 5 additions and 8 deletions

View File

@@ -71,7 +71,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
} }
if (block != null && block.canPlaceBlockAt(worldObj, front)) { if (block != null && block.canPlaceBlockAt(worldObj, front)) {
ItemStack took = controller.take(filter.getStackInSlot(0).copy(), compare); ItemStack took = controller.take(filter.getStackInSlot(0), compare);
if (took != null) { if (took != null) {
scheduler.resetSchedule(); scheduler.resetSchedule();

View File

@@ -63,9 +63,8 @@ public class TileDestructor extends TileMachine implements ICompareConfig, IMode
worldObj.setBlockToAir(front); worldObj.setBlockToAir(front);
for (ItemStack drop : drops) { for (ItemStack drop : drops) {
// We check if the controller isn't null here because // We check if the controller isn't null here because when a destructor faces a machine block and removes it
// when a destructor faces a storage network block and removes it // it will essentially remove this block itself from the network without knowing
// it will essentially remove this block from the network without knowing.
if (controller == null || !controller.push(drop)) { if (controller == null || !controller.push(drop)) {
InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), drop); InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), drop);
} }

View File

@@ -43,9 +43,7 @@ public class StorageHandler {
// NO OP, the quantity already set (64) is needed for shift // NO OP, the quantity already set (64) is needed for shift
} }
if (size > stack.getItem().getItemStackLimit(stack)) { size = Math.min(size, stack.getItem().getItemStackLimit(stack));
size = stack.getItem().getItemStackLimit(stack);
}
ItemStack took = controller.take(ItemHandlerHelper.copyStackWithSize(stack, size)); ItemStack took = controller.take(ItemHandlerHelper.copyStackWithSize(stack, size));

View File

@@ -149,7 +149,7 @@ public class TileGrid extends TileMachine implements IGrid {
if (slot != null) { if (slot != null) {
if (slot.stackSize == 1 && isConnected()) { if (slot.stackSize == 1 && isConnected()) {
matrix.setInventorySlotContents(i, controller.take(slot.copy())); matrix.setInventorySlotContents(i, controller.take(slot));
} else { } else {
matrix.decrStackSize(i, 1); matrix.decrStackSize(i, 1);
} }