mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Farm refactor, Fix #187 Multifarms do not give equal space
This commit is contained in:
1 parent
b36d10308b
commit
f832025f6d
3 files changed
+298
-269
No files matched your search
@@ -10,31 +10,31 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.vect.MutableVect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.core.vect.VectUtil;
|
||||
import forestry.farming.gadgets.StructureLogicFarm;
|
||||
|
||||
public class FarmTarget {
|
||||
|
||||
private final Vect start;
|
||||
private final ForgeDirection direction;
|
||||
private final int limit;
|
||||
|
||||
private int yOffset;
|
||||
private int extent;
|
||||
private int limit;
|
||||
|
||||
public FarmTarget(Vect start) {
|
||||
public FarmTarget(Vect start, ForgeDirection direction, int limit) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public void setYOffset(int yOffset) {
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.direction = direction;
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public void setExtent(int extent) {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
public Vect getStart() {
|
||||
return start;
|
||||
}
|
||||
@@ -50,4 +50,38 @@ public class FarmTarget {
|
||||
public int getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
public ForgeDirection getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setExtentAndYOffset(World world) {
|
||||
Vect groundPosition = getGroundPosition(world);
|
||||
if (groundPosition == null) {
|
||||
extent = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
MutableVect position = new MutableVect(groundPosition);
|
||||
for (extent = 0; extent < getLimit(); extent++) {
|
||||
Block ground = VectUtil.getBlock(world, position);
|
||||
if (!StructureLogicFarm.bricks.contains(ground)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user