allow placing machines on any side of a marker box

This commit is contained in:
asiekierka 2015-03-24 17:29:27 +01:00
parent df4e416532
commit ce01c5773e
3 changed files with 45 additions and 35 deletions

View file

@ -6,6 +6,7 @@ Additions:
* Rewritten Zone Planner map system - should have much less lag and take up less disk space!
* **Note** - all existing zone planner previews will disappear. To reload them, simply break and place the zone planner!
* You can now apply RF power (or a redstone engine) to an Auto Workbench to speed it up (asie - thanks KingTriaxx!)
* You can now place a Marker-using machine next to any part of the box and not just corners (asie)
* Items:
* Paintbrush for dyeing pipes and other supported blocks (asie)
* Debugger for developer use (asie)

View file

@ -19,6 +19,7 @@ import buildcraft.BuildCraftBuilders;
import buildcraft.api.core.IAreaProvider;
import buildcraft.api.core.ISerializable;
import buildcraft.api.core.Position;
import buildcraft.api.tiles.ITileAreaProvider;
import buildcraft.core.DefaultProps;
import buildcraft.core.lib.EntityBlock;
import buildcraft.core.LaserKind;
@ -26,7 +27,7 @@ import buildcraft.core.lib.block.TileBuildCraft;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.lib.utils.Utils;
public class TileMarker extends TileBuildCraft implements IAreaProvider {
public class TileMarker extends TileBuildCraft implements ITileAreaProvider {
public static class TileWrapper implements ISerializable {
public int x, y, z;
@ -533,4 +534,41 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider {
createLasers();
}
@Override
public boolean isValidFromLocation(int x, int y, int z) {
// Rules:
// - one or two, but not three, of the coordinates must be equal to the marker's location
// - one of the coordinates must be either -1 or 1 away
// - it must be physically touching the box
// - however, it cannot be INSIDE the box
int equal = (x == xCoord ? 1 : 0) + (y == yCoord ? 1 : 0) + (z == zCoord ? 1 : 0);
int touching = 0;
if (equal == 0 || equal == 3) {
return false;
}
if (x < (xMin() - 1) || x > (xMax() + 1) || y < (yMin() - 1) || y > (yMax() + 1)
|| z < (zMin() - 1) || z > (zMax() + 1)) {
return false;
}
if (x >= xMin() && x <= xMax() && y >= yMin() && y <= yMax() && z >= zMin() && z <= zMax()) {
return false;
}
if (xMin() - x == 1 || x - xMax() == 1) {
touching++;
}
if (yMin() - y == 1 || y - yMax() == 1) {
touching++;
}
if (zMin() - z == 1 || z - zMax() == 1) {
touching++;
}
return touching == 1;
}
}

View file

@ -37,6 +37,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IAreaProvider;
import buildcraft.api.core.Position;
import buildcraft.api.power.IEngine;
import buildcraft.api.tiles.ITileAreaProvider;
import buildcraft.api.transport.IInjectable;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.CompatHooks;
@ -160,40 +161,10 @@ public final class Utils {
}
public static IAreaProvider getNearbyAreaProvider(World world, int i, int j, int k) {
TileEntity a1 = BlockUtils.getTileEntity(world, i + 1, j, k);
if (a1 instanceof IAreaProvider) {
return (IAreaProvider) a1;
}
TileEntity a2 = BlockUtils.getTileEntity(world, i - 1, j, k);
if (a2 instanceof IAreaProvider) {
return (IAreaProvider) a2;
}
TileEntity a3 = BlockUtils.getTileEntity(world, i, j, k + 1);
if (a3 instanceof IAreaProvider) {
return (IAreaProvider) a3;
}
TileEntity a4 = BlockUtils.getTileEntity(world, i, j, k - 1);
if (a4 instanceof IAreaProvider) {
return (IAreaProvider) a4;
}
TileEntity a5 = BlockUtils.getTileEntity(world, i, j + 1, k);
if (a5 instanceof IAreaProvider) {
return (IAreaProvider) a5;
}
TileEntity a6 = BlockUtils.getTileEntity(world, i, j - 1, k);
if (a6 instanceof IAreaProvider) {
return (IAreaProvider) a6;
for (TileEntity t : (List<TileEntity>) world.loadedTileEntityList) {
if (t instanceof ITileAreaProvider && ((ITileAreaProvider) t).isValidFromLocation(i, j, k)) {
return (IAreaProvider) t;
}
}
return null;