From c3f48c333f68008a62fec6a7ed060e03ce7fb494 Mon Sep 17 00:00:00 2001 From: Joshua Gwinn Date: Wed, 19 Feb 2014 22:12:57 -0700 Subject: [PATCH 1/3] Optimization to Digital Miner search thread This is a slight change to the digital miner search thread to remove the object creation that occurs for each block checked. It is a sort of minor thing, but it will help to keep the memory requirements for the thread down and execution maybe slightly faster. --- common/mekanism/common/miner/ThreadMinerSearch.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/mekanism/common/miner/ThreadMinerSearch.java b/common/mekanism/common/miner/ThreadMinerSearch.java index a62e88dee..42939e0eb 100644 --- a/common/mekanism/common/miner/ThreadMinerSearch.java +++ b/common/mekanism/common/miner/ThreadMinerSearch.java @@ -43,6 +43,7 @@ public class ThreadMinerSearch extends Thread Coord4D coord = tileEntity.getStartingCoord(); int diameter = tileEntity.getDiameter(); int size = tileEntity.getTotalSize(); + ItemInfo info = new ItemInfo(0,0); for(int i = 0; i < size; i++) { @@ -70,12 +71,11 @@ public class ThreadMinerSearch extends Thread continue; } - int blockID = tileEntity.worldObj.getBlockId(x, y, z); - int meta = tileEntity.worldObj.getBlockMetadata(x, y, z); + info.id = tileEntity.worldObj.getBlockId(x, y, z); + info.meta = tileEntity.worldObj.getBlockMetadata(x, y, z); - if(blockID != 0 && blockID != Block.bedrock.blockID) + if(info.id != 0 && info.id != Block.bedrock.blockID) { - ItemInfo info = new ItemInfo(blockID, meta); boolean canFilter = false; if(acceptedItems.containsKey(info)) @@ -83,7 +83,7 @@ public class ThreadMinerSearch extends Thread canFilter = acceptedItems.get(info); } else { - ItemStack stack = new ItemStack(blockID, 1, meta); + ItemStack stack = new ItemStack(info.id, 1, info.meta); if(tileEntity.replaceStack != null && tileEntity.replaceStack.isItemEqual(stack)) { From 37321040f480c6a2b9e3e60c3be00bf65543994c Mon Sep 17 00:00:00 2001 From: Joshua Gwinn Date: Wed, 19 Feb 2014 23:52:25 -0700 Subject: [PATCH 2/3] Fix additional source of Digital Miner tile entity freezing The function nextSetBit was incorrectly assumed to search for indexes starting after the index given, but it in fact is inclusive with the index given, this can lead to the while loop turning infinite if a block it is expecting to be there isn't there. --- common/mekanism/common/tile/TileEntityDigitalMiner.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/mekanism/common/tile/TileEntityDigitalMiner.java b/common/mekanism/common/tile/TileEntityDigitalMiner.java index 75b1633f8..725364f9e 100644 --- a/common/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/common/mekanism/common/tile/TileEntityDigitalMiner.java @@ -167,7 +167,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(!coord.exists(worldObj)) { - next = index; + next = index + 1; continue; } @@ -177,7 +177,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(id == 0) { toRemove.add(index); - next = index; + next = index + 1; continue; } @@ -195,7 +195,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(inverse ? hasFilter : !hasFilter) { toRemove.add(index); - next = index; + next = index + 1; continue; } From c8f0801486995910bf6451af31053c85fed36a40 Mon Sep 17 00:00:00 2001 From: Joshua Gwinn Date: Thu, 20 Feb 2014 00:25:17 -0700 Subject: [PATCH 3/3] Remove blocks that are outside of loaded chunks from bitset list Remove another potential source of unneeded calculations, if a digital miner is chunkloaded and chunks it is considering are outside of loaded chunks, they will be iterated through for each block mined. --- common/mekanism/common/tile/TileEntityDigitalMiner.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common/mekanism/common/tile/TileEntityDigitalMiner.java b/common/mekanism/common/tile/TileEntityDigitalMiner.java index 725364f9e..52609367b 100644 --- a/common/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/common/mekanism/common/tile/TileEntityDigitalMiner.java @@ -167,6 +167,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(!coord.exists(worldObj)) { + toRemove.add(index); next = index + 1; continue; }