mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 19:29:17 +00:00
Giant multiblock refactor
This commit is contained in:
1 parent
201111cb83
commit
aa47599278
259 files changed
+10117
-6495
No files matched your search
@@ -15,43 +15,42 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.core.IStructureLogic;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmComponent;
|
||||
import forestry.api.farming.IFarmInterface;
|
||||
import forestry.core.vect.MutableVect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.core.vect.VectUtil;
|
||||
import forestry.farming.gadgets.StructureLogicFarm;
|
||||
|
||||
public class FarmHelper implements IFarmInterface {
|
||||
public class FarmHelper {
|
||||
|
||||
@Override
|
||||
public IStructureLogic createFarmStructureLogic(IFarmComponent structure) {
|
||||
return new StructureLogicFarm(structure);
|
||||
public static FarmDirection getOpposite(FarmDirection farmDirection) {
|
||||
ForgeDirection forgeDirection = farmDirection.getForgeDirection();
|
||||
ForgeDirection forgeDirectionOpposite = forgeDirection.getOpposite();
|
||||
return FarmDirection.getFarmDirection(forgeDirectionOpposite);
|
||||
}
|
||||
|
||||
public static int getFarmSizeNorthSouth(World world, Vect start) {
|
||||
ForgeDirection farmSide = ForgeDirection.NORTH;
|
||||
ForgeDirection startSide = ForgeDirection.EAST;
|
||||
FarmDirection farmSide = FarmDirection.NORTH;
|
||||
FarmDirection startSide = FarmDirection.EAST;
|
||||
|
||||
Vect corner = getFarmMultiblockCorner(world, start, farmSide, startSide);
|
||||
|
||||
return getFarmSizeInDirection(world, corner, farmSide, startSide.getOpposite());
|
||||
return getFarmSizeInDirection(world, corner, farmSide, getOpposite(startSide));
|
||||
}
|
||||
|
||||
public static int getFarmSizeEastWest(World world, Vect start) {
|
||||
ForgeDirection farmSide = ForgeDirection.EAST;
|
||||
ForgeDirection startSide = ForgeDirection.NORTH;
|
||||
FarmDirection farmSide = FarmDirection.EAST;
|
||||
FarmDirection startSide = FarmDirection.NORTH;
|
||||
|
||||
Vect corner = getFarmMultiblockCorner(world, start, farmSide, startSide);
|
||||
|
||||
return getFarmSizeInDirection(world, corner, farmSide, startSide.getOpposite());
|
||||
return getFarmSizeInDirection(world, corner, farmSide, getOpposite(startSide));
|
||||
}
|
||||
|
||||
private static int getFarmSizeInDirection(World world, Vect start, ForgeDirection farmSide, ForgeDirection searchDirection) {
|
||||
private static int getFarmSizeInDirection(World world, Vect start, FarmDirection farmSide, FarmDirection searchDirection) {
|
||||
int size = 0;
|
||||
|
||||
ForgeDirection toCenter = farmSide.getOpposite();
|
||||
FarmDirection toCenter = getOpposite(farmSide);
|
||||
|
||||
Vect target = start.add(farmSide);
|
||||
|
||||
@@ -69,19 +68,19 @@ public class FarmHelper implements IFarmInterface {
|
||||
return size;
|
||||
}
|
||||
|
||||
public static Vect getFarmMultiblockCorner(World world, Vect start, ForgeDirection direction1, ForgeDirection direction2) {
|
||||
Vect edge = getFarmMultiblockEdge(world, start, direction1);
|
||||
return getFarmMultiblockEdge(world, edge, direction2);
|
||||
public static Vect getFarmMultiblockCorner(World world, Vect start, FarmDirection farmSide, FarmDirection layoutDirection) {
|
||||
Vect edge = getFarmMultiblockEdge(world, start, farmSide);
|
||||
return getFarmMultiblockEdge(world, edge, getOpposite(layoutDirection));
|
||||
}
|
||||
|
||||
private static Vect getFarmMultiblockEdge(World world, Vect start, ForgeDirection direction) {
|
||||
private static Vect getFarmMultiblockEdge(World world, Vect start, FarmDirection direction) {
|
||||
MutableVect edge = new MutableVect(start);
|
||||
|
||||
while (VectUtil.getTile(world, edge) instanceof IFarmComponent) {
|
||||
edge.add(direction);
|
||||
}
|
||||
|
||||
edge.add(direction.getOpposite());
|
||||
edge.add(getOpposite(direction));
|
||||
return new Vect(edge);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user