Some tree farm optimizations.

This commit is contained in:
CovertJaguar committed 2014-09-23 19:41:24 -07:00
1 parent 5fe339093a
commit fbaad8bf93
7 files changed
+25 -44

No files matched your search

@@ -23,6 +23,7 @@ import forestry.core.gadgets.StructureLogic;
import forestry.core.utils.Schemata;
import forestry.core.utils.Schemata.EnumStructureBlock;
import forestry.core.utils.Vect;
import java.util.Set;
public class StructureLogicFarm extends StructureLogic {
@@ -65,7 +66,7 @@ public class StructureLogicFarm extends StructureLogic {
"FFFFFFF", "FAAAAAF", "FAAAAAF", "FBBBBBF", "FAAAAAF", "FFFFFFF",
"FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF", "FFFFFFF").setOffsets(-3, -3, -3);
public static HashSet<Block> bricks = new HashSet<Block>();
public static final Set<Block> bricks = new HashSet<Block>();
static {
bricks.add(Blocks.brick_block);
bricks.add(Blocks.stonebrick);
@@ -335,7 +335,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
ForgeDirection direction = entry.getKey();
for (FarmTarget target : entry.getValue()) {
int yOffset = 0;
int yOffset;
for (yOffset = 2; yOffset > -3; yOffset--) {
Vect position = new Vect(target.getStart().x, target.getStart().y + yOffset, target.getStart().z);
if (StructureLogicFarm.bricks.contains(worldObj.getBlock(position.x, position.y, position.z)))
@@ -343,7 +343,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
}
target.setYOffset(yOffset + 1);
int extent = 0;
int extent;
// Determine extent limit
int limit = allowedExtent;
if (target.getLimit() > 0)
@@ -39,6 +39,8 @@ import forestry.core.config.ForestryBlock;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.StackUtils;
import forestry.core.utils.Vect;
import java.util.HashSet;
import java.util.Set;
public class FarmLogicArboreal extends FarmLogicHomogenous {
@@ -141,7 +143,7 @@ public class FarmLogicArboreal extends FarmLogicHomogenous {
World world = getWorld();
ArrayList<Vect> seen = new ArrayList<Vect>();
Set<Vect> seen = new HashSet<Vect>();
Stack<ICrop> crops = new Stack<ICrop>();
// Determine what type we want to harvest.
@@ -175,7 +177,7 @@ public class FarmLogicArboreal extends FarmLogicHomogenous {
protected int yOffset = 0;
private ArrayList<Vect> processHarvestBlock(IFarmable germling, Stack<ICrop> crops, Collection<Vect> seen, Vect start, Vect position) {
private ArrayList<Vect> processHarvestBlock(IFarmable germling, Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
World world = getWorld();
@@ -194,14 +196,7 @@ public class FarmLogicArboreal extends FarmLogicHomogenous {
continue;
// See whether the given position has already been processed
boolean skip = false;
for (Vect prcs : seen)
if (candidate.equals(prcs)) {
skip = true;
break;
}
if (skip)
if (seen.contains(candidate))
continue;
ICrop crop = germling.getCropAt(world, candidate.x, candidate.y, candidate.z);
@@ -31,6 +31,8 @@ import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmable;
import forestry.core.utils.Vect;
import java.util.HashSet;
import java.util.Set;
public class FarmLogicCocoa extends FarmLogic {
@@ -147,7 +149,7 @@ public class FarmLogicCocoa extends FarmLogic {
private Collection<ICrop> getHarvestBlocks(Vect position) {
ArrayList<Vect> seen = new ArrayList<Vect>();
Set<Vect> seen = new HashSet<Vect>();
Stack<ICrop> crops = new Stack<ICrop>();
// Determine what type we want to harvest.
@@ -177,7 +179,7 @@ public class FarmLogicCocoa extends FarmLogic {
return crops;
}
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Collection<Vect> seen, Vect start, Vect position) {
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
World world = getWorld();
@@ -196,14 +198,7 @@ public class FarmLogicCocoa extends FarmLogic {
continue;
// See whether the given position has already been processed
boolean skip = false;
for (Vect prcs : seen)
if (candidate.equals(prcs)) {
skip = true;
break;
}
if (skip)
if (seen.contains(candidate))
continue;
ICrop crop = cocoa.getCropAt(world, candidate.x, candidate.y, candidate.z);
@@ -31,6 +31,8 @@ import forestry.api.farming.IFarmHousing;
import forestry.api.genetics.IFruitBearer;
import forestry.core.config.ForestryItem;
import forestry.core.utils.Vect;
import java.util.HashSet;
import java.util.Set;
public class FarmLogicOrchard extends FarmLogic {
@@ -106,7 +108,7 @@ public class FarmLogicOrchard extends FarmLogic {
private Collection<ICrop> getHarvestBlocks(Vect position) {
ArrayList<Vect> seen = new ArrayList<Vect>();
Set<Vect> seen = new HashSet<Vect>();
Stack<ICrop> crops = new Stack<ICrop>();
// Determine what type we want to harvest.
@@ -129,7 +131,7 @@ public class FarmLogicOrchard extends FarmLogic {
return crops;
}
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Collection<Vect> seen, Vect start, Vect position) {
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
World world = getWorld();
ArrayList<Vect> candidates = new ArrayList<Vect>();
@@ -147,14 +149,7 @@ public class FarmLogicOrchard extends FarmLogic {
continue;
// See whether the given position has already been processed
boolean skip = false;
for (Vect prcs : seen)
if (candidate.equals(prcs)) {
skip = true;
break;
}
if (skip)
if (seen.contains(candidate))
continue;
IFruitBearer bearer = getFruitBlock(candidate);
@@ -32,6 +32,8 @@ import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
import forestry.core.utils.Vect;
import forestry.plugins.PluginIC2;
import java.util.HashSet;
import java.util.Set;
public class FarmLogicRubber extends FarmLogic {
@@ -115,7 +117,7 @@ public class FarmLogicRubber extends FarmLogic {
private Collection<ICrop> getHarvestBlocks(Vect position) {
ArrayList<Vect> seen = new ArrayList<Vect>();
Set<Vect> seen = new HashSet<Vect>();
Stack<ICrop> crops = new Stack<ICrop>();
// Determine what type we want to harvest.
@@ -140,7 +142,7 @@ public class FarmLogicRubber extends FarmLogic {
return crops;
}
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Collection<Vect> seen, Vect position) {
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect position) {
World world = getWorld();
ArrayList<Vect> candidates = new ArrayList<Vect>();
@@ -152,14 +154,7 @@ public class FarmLogicRubber extends FarmLogic {
continue;
// See whether the given position has already been processed
boolean skip = false;
for (Vect prcs : seen)
if (candidate.equals(prcs)) {
skip = true;
break;
}
if (skip)
if (seen.contains(candidate))
continue;
Block block = getBlock(candidate);