mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 15:22:57 +00:00
1 parent
576afde7b7
commit
2e20b14e06
32 files changed
+329
-153
No files matched your search
@@ -8,12 +8,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -28,6 +29,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.core.utils.vect.VectUtil;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
@@ -123,7 +125,7 @@ public class FarmLogicRubber extends FarmLogic {
|
||||
private Collection<ICrop> getHarvestBlocks(Vect position) {
|
||||
|
||||
Set<Vect> seen = new HashSet<>();
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
|
||||
World world = getWorld();
|
||||
|
||||
@@ -152,31 +154,33 @@ public class FarmLogicRubber extends FarmLogic {
|
||||
return crops;
|
||||
}
|
||||
|
||||
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect position) {
|
||||
private ArrayList<Vect> processHarvestBlock(Deque<ICrop> crops, Set<Vect> seen, Vect position) {
|
||||
World world = getWorld();
|
||||
|
||||
ArrayList<Vect> candidates = new ArrayList<>();
|
||||
|
||||
// Get additional candidates to return
|
||||
final MutableVect mutable = position.asMutable();
|
||||
for (int j = 0; j < 2; j++) {
|
||||
Vect candidate = new Vect(position.x, position.y + j, position.z);
|
||||
if (candidate.equals(position)) {
|
||||
mutable.y = position.y + j;
|
||||
if (mutable.equals(position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// See whether the given position has already been processed
|
||||
if (seen.contains(candidate)) {
|
||||
if (seen.contains(mutable)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = VectUtil.getBlock(world, candidate);
|
||||
Block block = VectUtil.getBlock(world, mutable);
|
||||
if (ItemStackUtil.equals(block, PluginIC2.rubberwood)) {
|
||||
int meta = VectUtil.getBlockMeta(world, candidate);
|
||||
final Vect immutable = new Vect(mutable);
|
||||
int meta = VectUtil.getBlockMeta(world, immutable);
|
||||
if (meta >= 2 && meta <= 5) {
|
||||
crops.push(new CropRubber(world, block, meta, candidate));
|
||||
crops.push(new CropRubber(world, block, meta, immutable));
|
||||
}
|
||||
candidates.add(candidate);
|
||||
seen.add(candidate);
|
||||
candidates.add(immutable);
|
||||
seen.add(immutable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user