mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 03:39:09 +00:00
Fix #251 overlapping farming areas
This commit is contained in:
1 parent
7fc90fb76e
commit
0848cfb891
8 files changed
+92
-67
No files matched your search
@@ -15,10 +15,12 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.gadgets.StructureLogic;
|
||||
import forestry.core.vect.MutableVect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.core.vect.VectUtil;
|
||||
import forestry.farming.gadgets.StructureLogicFarm;
|
||||
import forestry.farming.logic.FarmLogic;
|
||||
|
||||
public class FarmTarget {
|
||||
|
||||
@@ -55,33 +57,22 @@ public class FarmTarget {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setExtentAndYOffset(World world) {
|
||||
Vect groundPosition = getGroundPosition(world);
|
||||
if (groundPosition == null) {
|
||||
public void setExtentAndYOffset(World world, Vect platformPosition) {
|
||||
if (platformPosition == null) {
|
||||
extent = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
MutableVect position = new MutableVect(groundPosition);
|
||||
MutableVect position = new MutableVect(platformPosition);
|
||||
for (extent = 0; extent < getLimit(); extent++) {
|
||||
Block ground = VectUtil.getBlock(world, position);
|
||||
if (!StructureLogicFarm.bricks.contains(ground)) {
|
||||
Block platform = VectUtil.getBlock(world, position);
|
||||
Vect soilPosition = new Vect(position.x, position.y + 1, position.z);
|
||||
if (!StructureLogicFarm.bricks.contains(platform) || !FarmLogic.canBreakSoil(world, soilPosition)) {
|
||||
break;
|
||||
}
|
||||
position.add(getDirection());
|
||||
}
|
||||
|
||||
yOffset = groundPosition.getY() + 1 - getStart().getY();
|
||||
}
|
||||
|
||||
private Vect getGroundPosition(World world) {
|
||||
for (int yOffset = 2; yOffset > -3; yOffset--) {
|
||||
Vect position = getStart().add(0, yOffset, 0);
|
||||
Block ground = VectUtil.getBlock(world, position);
|
||||
if (StructureLogicFarm.bricks.contains(ground)) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
yOffset = platformPosition.getY() + 1 - getStart().getY();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user