From b3fd6d1c72315369c968719ecd77e5f509a649d1 Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Sat, 2 Apr 2016 16:02:41 +0200 Subject: [PATCH] Renames of a few vars --- src/main/java/refinedstorage/gui/GuiGrid.java | 18 +++++----- .../network/MessageStoragePull.java | 14 ++++---- .../refinedstorage/storage/NBTStorage.java | 24 ++++++------- .../refinedstorage/tile/TileController.java | 36 +++++++++---------- .../refinedstorage/tile/TileDetector.java | 10 +++--- 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/main/java/refinedstorage/gui/GuiGrid.java b/src/main/java/refinedstorage/gui/GuiGrid.java index 4c70d6512..4499f502f 100755 --- a/src/main/java/refinedstorage/gui/GuiGrid.java +++ b/src/main/java/refinedstorage/gui/GuiGrid.java @@ -74,15 +74,15 @@ public class GuiGrid extends GuiBase { items.clear(); if (grid.isConnected()) { - items.addAll(grid.getController().getItems()); + items.addAll(grid.getController().getItemGroups()); if (!searchField.getText().trim().isEmpty()) { Iterator t = items.iterator(); while (t.hasNext()) { - ItemGroup item = t.next(); + ItemGroup group = t.next(); - if (!item.toItemStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) { + if (!group.toItemStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) { t.remove(); } } @@ -90,11 +90,11 @@ public class GuiGrid extends GuiBase { Collections.sort(items, new Comparator() { @Override - public int compare(ItemGroup o1, ItemGroup o2) { + public int compare(ItemGroup left, ItemGroup right) { if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) { - return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName()); + return right.toItemStack().getDisplayName().compareTo(left.toItemStack().getDisplayName()); } else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) { - return o1.toItemStack().getDisplayName().compareTo(o2.toItemStack().getDisplayName()); + return left.toItemStack().getDisplayName().compareTo(right.toItemStack().getDisplayName()); } return 0; @@ -104,11 +104,11 @@ public class GuiGrid extends GuiBase { if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) { Collections.sort(items, new Comparator() { @Override - public int compare(ItemGroup o1, ItemGroup o2) { + public int compare(ItemGroup left, ItemGroup right) { if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) { - return Integer.valueOf(o2.getQuantity()).compareTo(o1.getQuantity()); + return Integer.valueOf(right.getQuantity()).compareTo(left.getQuantity()); } else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) { - return Integer.valueOf(o1.getQuantity()).compareTo(o2.getQuantity()); + return Integer.valueOf(left.getQuantity()).compareTo(right.getQuantity()); } return 0; diff --git a/src/main/java/refinedstorage/network/MessageStoragePull.java b/src/main/java/refinedstorage/network/MessageStoragePull.java index 373eb4a7c..b8726e0f5 100755 --- a/src/main/java/refinedstorage/network/MessageStoragePull.java +++ b/src/main/java/refinedstorage/network/MessageStoragePull.java @@ -69,13 +69,13 @@ public class MessageStoragePull extends MessageHandlerPlayerToServer 1) { - quantity = item.getQuantity() / 2; + if (message.isPullingHalf() && group.getQuantity() > 1) { + quantity = group.getQuantity() / 2; if (quantity > 32) { quantity = 32; @@ -86,11 +86,11 @@ public class MessageStoragePull extends MessageHandlerPlayerToServer item.getType().getItemStackLimit(item.toItemStack())) { - quantity = item.getType().getItemStackLimit(item.toItemStack()); + if (quantity > group.getType().getItemStackLimit(group.toItemStack())) { + quantity = group.getType().getItemStackLimit(group.toItemStack()); } - ItemStack took = controller.take(item.copy(quantity).toItemStack()); + ItemStack took = controller.take(group.copy(quantity).toItemStack()); if (took != null) { if (message.isPullingWithShift()) { diff --git a/src/main/java/refinedstorage/storage/NBTStorage.java b/src/main/java/refinedstorage/storage/NBTStorage.java index 06070dad5..8af951b59 100755 --- a/src/main/java/refinedstorage/storage/NBTStorage.java +++ b/src/main/java/refinedstorage/storage/NBTStorage.java @@ -31,7 +31,7 @@ public class NBTStorage implements IStorage { NBTTagList list = (NBTTagList) nbtTag.getTag(NBT_ITEMS); for (int i = 0; i < list.tagCount(); ++i) { - items.add(createItemFromNBT(list.getCompoundTagAt(i))); + items.add(createItemGroupFromNBT(list.getCompoundTagAt(i))); } } @@ -44,10 +44,10 @@ public class NBTStorage implements IStorage { for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound tag = list.getCompoundTagAt(i); - ItemGroup item = createItemFromNBT(tag); + ItemGroup group = createItemGroupFromNBT(tag); - if (item.compareNoQuantity(stack)) { - tag.setInteger(NBT_ITEM_QUANTITY, item.getQuantity() + stack.stackSize); + if (group.compareNoQuantity(stack)) { + tag.setInteger(NBT_ITEM_QUANTITY, group.getQuantity() + stack.stackSize); return; } @@ -75,22 +75,22 @@ public class NBTStorage implements IStorage { for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound tag = list.getCompoundTagAt(i); - ItemGroup item = createItemFromNBT(tag); + ItemGroup group = createItemGroupFromNBT(tag); - if (item.compare(stack, flags)) { - if (quantity > item.getQuantity()) { - quantity = item.getQuantity(); + if (group.compare(stack, flags)) { + if (quantity > group.getQuantity()) { + quantity = group.getQuantity(); } - tag.setInteger(NBT_ITEM_QUANTITY, item.getQuantity() - quantity); + tag.setInteger(NBT_ITEM_QUANTITY, group.getQuantity() - quantity); - if (item.getQuantity() - quantity == 0) { + if (group.getQuantity() - quantity == 0) { list.removeTag(i); } nbtTag.setInteger(NBT_STORED, getStored(nbtTag) - quantity); - ItemStack newItem = item.toItemStack(); + ItemStack newItem = group.toItemStack(); newItem.stackSize = quantity; @@ -115,7 +115,7 @@ public class NBTStorage implements IStorage { return priority; } - private ItemGroup createItemFromNBT(NBTTagCompound tag) { + private ItemGroup createItemGroupFromNBT(NBTTagCompound tag) { return new ItemGroup(Item.getItemById(tag.getInteger(NBT_ITEM_TYPE)), tag.getInteger(NBT_ITEM_QUANTITY), tag.getInteger(NBT_ITEM_DAMAGE), tag.hasKey(NBT_ITEM_NBT) ? ((NBTTagCompound) tag.getTag(NBT_ITEM_NBT)) : null); } diff --git a/src/main/java/refinedstorage/tile/TileController.java b/src/main/java/refinedstorage/tile/TileController.java index cbb28c5a3..9aa9dcae4 100755 --- a/src/main/java/refinedstorage/tile/TileController.java +++ b/src/main/java/refinedstorage/tile/TileController.java @@ -29,7 +29,7 @@ import refinedstorage.util.InventoryUtils; import java.util.*; public class TileController extends TileBase implements IEnergyReceiver, INetworkTile, IRedstoneModeConfig { - private List items = new ArrayList(); + private List itemGroups = new ArrayList(); private List storages = new ArrayList(); private List wirelessGridConsumers = new ArrayList(); private List wirelessGridConsumersMarkedForRemoval = new ArrayList(); @@ -162,15 +162,15 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor return machines; } - public List getItems() { - return items; + public List getItemGroups() { + return itemGroups; } private void syncItems() { - items.clear(); + itemGroups.clear(); for (IStorage storage : storages) { - storage.addItems(items); + storage.addItems(itemGroups); } combineItems(); @@ -179,22 +179,22 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor private void combineItems() { List markedIndexes = new ArrayList(); - for (int i = 0; i < items.size(); ++i) { + for (int i = 0; i < itemGroups.size(); ++i) { if (markedIndexes.contains(i)) { continue; } - ItemGroup item = items.get(i); + ItemGroup group = itemGroups.get(i); - for (int j = i + 1; j < items.size(); ++j) { + for (int j = i + 1; j < itemGroups.size(); ++j) { if (markedIndexes.contains(j)) { continue; } - ItemGroup other = items.get(j); + ItemGroup otherGroup = itemGroups.get(j); - if (item.compareNoQuantity(other)) { - item.setQuantity(item.getQuantity() + other.getQuantity()); + if (group.compareNoQuantity(otherGroup)) { + group.setQuantity(group.getQuantity() + otherGroup.getQuantity()); markedIndexes.add(j); } @@ -204,10 +204,10 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor List markedItems = new ArrayList(); for (int i : markedIndexes) { - markedItems.add(items.get(i)); + markedItems.add(itemGroups.get(i)); } - items.removeAll(markedItems); + itemGroups.removeAll(markedItems); } public boolean push(ItemStack stack) { @@ -406,12 +406,12 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor redstoneMode = RedstoneMode.getById(buf.readInt()); - items.clear(); + itemGroups.clear(); int size = buf.readInt(); for (int i = 0; i < size; ++i) { - items.add(new ItemGroup(buf)); + itemGroups.add(new ItemGroup(buf)); } machines.clear(); @@ -436,10 +436,10 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor buf.writeInt(redstoneMode.id); - buf.writeInt(items.size()); + buf.writeInt(itemGroups.size()); - for (ItemGroup item : items) { - item.toBytes(buf, items.indexOf(item)); + for (ItemGroup group : itemGroups) { + group.toBytes(buf, itemGroups.indexOf(group)); } buf.writeInt(machines.size()); diff --git a/src/main/java/refinedstorage/tile/TileDetector.java b/src/main/java/refinedstorage/tile/TileDetector.java index 809c6b4e5..a8a71b41a 100755 --- a/src/main/java/refinedstorage/tile/TileDetector.java +++ b/src/main/java/refinedstorage/tile/TileDetector.java @@ -50,19 +50,19 @@ public class TileDetector extends TileMachine implements ICompareConfig { if (slot != null) { boolean foundAny = false; - for (ItemGroup item : getController().getItems()) { - if (item.compare(slot, compare)) { + for (ItemGroup group : getController().getItemGroups()) { + if (group.compare(slot, compare)) { foundAny = true; switch (mode) { case MODE_UNDER: - powered = item.getQuantity() < amount; + powered = group.getQuantity() < amount; break; case MODE_EQUAL: - powered = item.getQuantity() == amount; + powered = group.getQuantity() == amount; break; case MODE_ABOVE: - powered = item.getQuantity() > amount; + powered = group.getQuantity() > amount; break; }