mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-21 12:42:24 +00:00
Make 'for' usage more consistent for minor performance and GC improvement.
This commit is contained in:
1 parent
892ae6c6c9
commit
142cfc0a29
7 files changed
+36
-34
No files matched your search
@@ -67,8 +67,8 @@ public class DrawerData
|
||||
continue;
|
||||
|
||||
List<ItemStack> list = OreDictionary.getOres(OreDictionary.getOreName(id));
|
||||
for (ItemStack oreItem : list)
|
||||
oreDictMatches.add(oreItem);
|
||||
for (int i = 0, n = list.size(); i < n; i++)
|
||||
oreDictMatches.add(list.get(i));
|
||||
}
|
||||
|
||||
if (oreDictMatches.size() == 0)
|
||||
@@ -190,15 +190,15 @@ public class DrawerData
|
||||
boolean oreMatch = false;
|
||||
|
||||
BRK_ORE_MATCH:
|
||||
for (int i = 0; i < ids1.length; i++) {
|
||||
if (StorageDrawers.oreDictRegistry.isEntryBlacklisted(OreDictionary.getOreName(ids1[i])))
|
||||
for (int oreIndexLeft : ids1) {
|
||||
if (StorageDrawers.oreDictRegistry.isEntryBlacklisted(OreDictionary.getOreName(oreIndexLeft)))
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < ids2.length; j++) {
|
||||
if (StorageDrawers.oreDictRegistry.isEntryBlacklisted(OreDictionary.getOreName(ids2[j])))
|
||||
for (int oreIndexRight : ids2) {
|
||||
if (StorageDrawers.oreDictRegistry.isEntryBlacklisted(OreDictionary.getOreName(oreIndexRight)))
|
||||
continue;
|
||||
|
||||
if (ids1[i] == ids2[j]) {
|
||||
if (oreIndexLeft == oreIndexRight) {
|
||||
oreMatch = true;
|
||||
break BRK_ORE_MATCH;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
|
||||
|
||||
public TileEntityCompDrawers () {
|
||||
data = new DrawerData[3];
|
||||
for (int i = 0; i < data.length; i++)
|
||||
for (int i = 0, n = data.length; i < n; i++)
|
||||
data[i] = new DrawerData(this, i);
|
||||
|
||||
snapshotItems = new ItemStack[3];
|
||||
@@ -147,7 +147,7 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
|
||||
count += putItemsIntoSlot(slot, currentStack, currentStack.stackSize);
|
||||
|
||||
if (worldObj.getWorldTime() - lastClickTime < 10 && player.getPersistentID().equals(lastClickUUID)) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
for (int i = 0, n = player.inventory.getSizeInventory(); i < n; i++) {
|
||||
ItemStack subStack = player.inventory.getStackInSlot(i);
|
||||
if (subStack != null) {
|
||||
int subCount = putItemsIntoSlot(slot, subStack, subStack.stackSize);
|
||||
@@ -179,7 +179,7 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
|
||||
NBTTagList slots = tag.getTagList("Slots", Constants.NBT.TAG_COMPOUND);
|
||||
data = new DrawerData[slots.tagCount()];
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
for (int i = 0, n = data.length; i < n; i++) {
|
||||
NBTTagCompound slot = slots.getCompoundTagAt(i);
|
||||
data[i] = new DrawerData(this, i);
|
||||
data[i].readFromNBT(slot);
|
||||
@@ -187,7 +187,7 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
|
||||
|
||||
pooledCount = tag.getInteger("Count");
|
||||
|
||||
for (int i = 0; i < convRate.length; i++)
|
||||
for (int i = 0, n = convRate.length; i < n; i++)
|
||||
convRate[i] = 0;
|
||||
|
||||
if (tag.hasKey("Conv0"))
|
||||
@@ -206,9 +206,9 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
|
||||
super.writeToNBT(tag);
|
||||
|
||||
NBTTagList slots = new NBTTagList();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
for (DrawerData drawer : data) {
|
||||
NBTTagCompound slot = new NBTTagCompound();
|
||||
data[i].writeToNBT(slot);
|
||||
drawer.writeToNBT(slot);
|
||||
slots.appendTag(slot);
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
|
||||
}
|
||||
|
||||
private void setupLookup (InventoryLookup inv, ItemStack stack) {
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
for (int i = 0, n = inv.getSizeInventory(); i < n; i++)
|
||||
inv.setInventorySlotContents(i, stack);
|
||||
|
||||
lookupSizeResult = inv.getSizeInventory();
|
||||
@@ -571,8 +571,8 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side) {
|
||||
for (int i = 0; i < autoSides.length; i++) {
|
||||
if (side == autoSides[i])
|
||||
for (int aside : autoSides) {
|
||||
if (side == aside)
|
||||
return drawerSlots3;
|
||||
}
|
||||
|
||||
@@ -584,8 +584,8 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
|
||||
if (slot >= getSizeInventory())
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < autoSides.length; i++) {
|
||||
if (side == autoSides[i]) {
|
||||
for (int aside : autoSides) {
|
||||
if (side == aside) {
|
||||
return isItemValidForSlot(slot, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
|
||||
drawerCount = count;
|
||||
|
||||
data = new DrawerData[drawerCount];
|
||||
for (int i = 0; i < data.length; i++)
|
||||
for (int i = 0, n = data.length; i < n; i++)
|
||||
data[i] = new DrawerData(this, i);
|
||||
|
||||
snapshotItems = new ItemStack[count];
|
||||
@@ -91,7 +91,7 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
|
||||
count += putItemsIntoSlot(slot, currentStack, currentStack.stackSize);
|
||||
|
||||
if (worldObj.getWorldTime() - lastClickTime < 10 && player.getPersistentID().equals(lastClickUUID)) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
for (int i = 0, n = player.inventory.getSizeInventory(); i < n; i++) {
|
||||
ItemStack subStack = player.inventory.getStackInSlot(i);
|
||||
if (subStack != null) {
|
||||
int subCount = putItemsIntoSlot(slot, subStack, subStack.stackSize);
|
||||
@@ -155,7 +155,7 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
|
||||
drawerCount = slots.tagCount();
|
||||
data = new DrawerData[slots.tagCount()];
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
for (int i = 0, n = data.length; i < n; i++) {
|
||||
NBTTagCompound slot = slots.getCompoundTagAt(i);
|
||||
data[i] = new DrawerData(this, i);
|
||||
data[i].readFromNBT(slot);
|
||||
@@ -170,9 +170,9 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
|
||||
super.writeToNBT(tag);
|
||||
|
||||
NBTTagList slots = new NBTTagList();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
for (DrawerData drawer : data) {
|
||||
NBTTagCompound slot = new NBTTagCompound();
|
||||
data[i].writeToNBT(slot);
|
||||
drawer.writeToNBT(slot);
|
||||
slots.appendTag(slot);
|
||||
}
|
||||
|
||||
@@ -331,8 +331,8 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side) {
|
||||
for (int i = 0; i < autoSides.length; i++) {
|
||||
if (side == autoSides[i])
|
||||
for (int aside : autoSides) {
|
||||
if (side == aside)
|
||||
return (drawerCount == 2) ? drawerSlots2 : drawerSlots4;
|
||||
}
|
||||
|
||||
@@ -344,8 +344,8 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
|
||||
if (slot >= getSizeInventory())
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < autoSides.length; i++) {
|
||||
if (side == autoSides[i]) {
|
||||
for (int aside : autoSides) {
|
||||
if (side == aside) {
|
||||
return isItemValidForSlot(slot, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ public class CompTierRegistry
|
||||
if (stack == null || stack.getItem() == null)
|
||||
return null;
|
||||
|
||||
for (Record r : records) {
|
||||
for (int i = 0, n = records.size(); i < n; i++) {
|
||||
Record r = records.get(i);
|
||||
if (stack.isItemEqual(r.lower) && ItemStack.areItemStackTagsEqual(stack, r.lower))
|
||||
return r;
|
||||
}
|
||||
@@ -52,7 +53,8 @@ public class CompTierRegistry
|
||||
if (stack == null || stack.getItem() == null)
|
||||
return null;
|
||||
|
||||
for (Record r : records) {
|
||||
for (int i = 0, n = records.size(); i < n; i++) {
|
||||
Record r = records.get(i);
|
||||
if (stack.isItemEqual(r.upper) && ItemStack.areItemStackTagsEqual(stack, r.upper))
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class OreDictRegistry
|
||||
if (blacklist.contains(entry))
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < blacklistPrefix.size(); i++) {
|
||||
for (int i = 0, n = blacklistPrefix.size(); i < n; i++) {
|
||||
if (entry.startsWith(blacklistPrefix.get(i)))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ItemUpgrade extends Item
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems (Item item, CreativeTabs creativeTabs, List list) {
|
||||
for (int i = 0; i < iconNames.length; i++) {
|
||||
for (int i = 0, n = iconNames.length; i < n; i++) {
|
||||
if (iconNames[i] != null)
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class ItemUpgrade extends Item
|
||||
public void registerIcons (IIconRegister register) {
|
||||
icons = new IIcon[iconNames.length];
|
||||
|
||||
for (int i = 0; i < iconNames.length; i++) {
|
||||
for (int i = 0, n = iconNames.length; i < n; i++) {
|
||||
if (iconNames[i] != null)
|
||||
icons[i] = register.registerIcon(StorageDrawers.MOD_ID + ":upgrade_" + iconNames[i]);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ItemUpgradeStatus extends Item
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems (Item item, CreativeTabs creativeTabs, List list) {
|
||||
for (int i = 0; i < iconNames.length; i++) {
|
||||
for (int i = 0, n = iconNames.length; i < n; i++) {
|
||||
if (iconNames[i] != null)
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class ItemUpgradeStatus extends Item
|
||||
public void registerIcons (IIconRegister register) {
|
||||
icons = new IIcon[iconNames.length];
|
||||
|
||||
for (int i = 0; i < iconNames.length; i++) {
|
||||
for (int i = 0, n = iconNames.length; i < n; i++) {
|
||||
if (iconNames[i] != null)
|
||||
icons[i] = register.registerIcon(StorageDrawers.MOD_ID + ":upgrade_status_" + iconNames[i]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user