Merge pull request #1084 from Voxelstice/pylon-stuff

Wiring errors with slightly more info
This commit is contained in:
HbmMods 2023-06-30 07:54:05 +02:00 committed by GitHub
commit 0b36b76f3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 14 deletions

View File

@ -61,14 +61,21 @@ public class ItemWiring extends Item {
TileEntityPylonBase first = (TileEntityPylonBase) world.getTileEntity(x1, y1, z1); TileEntityPylonBase first = (TileEntityPylonBase) world.getTileEntity(x1, y1, z1);
TileEntityPylonBase second = ((TileEntityPylonBase) te); TileEntityPylonBase second = ((TileEntityPylonBase) te);
if(TileEntityPylonBase.canConnect(first, second)) { switch (TileEntityPylonBase.canConnect(first, second)) {
case 0:
first.addConnection(x, y, z); first.addConnection(x, y, z);
second.addConnection(x1, y1, z1); second.addConnection(x1, y1, z1);
player.addChatMessage(new ChatComponentText("Wire end")); player.addChatMessage(new ChatComponentText("Wire end"));
break;
} else { case 1:
player.addChatMessage(new ChatComponentText("Wire error")); player.addChatMessage(new ChatComponentText("Wire error - Pylons are not the same type"));
break;
case 2:
player.addChatMessage(new ChatComponentText("Wire error - Cannot connect to the same pylon"));
break;
case 3:
player.addChatMessage(new ChatComponentText("Wire error - Pylon is too far away"));
break;
} }
stack.stackTagCompound = null; stack.stackTagCompound = null;

View File

@ -19,13 +19,13 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
public List<int[]> connected = new ArrayList<int[]>(); public List<int[]> connected = new ArrayList<int[]>();
public static boolean canConnect(TileEntityPylonBase first, TileEntityPylonBase second) { public static int canConnect(TileEntityPylonBase first, TileEntityPylonBase second) {
if(first.getConnectionType() != second.getConnectionType()) if(first.getConnectionType() != second.getConnectionType())
return false; return 1;
if(first == second) if(first == second)
return false; return 2;
double len = Math.min(first.getMaxWireLength(), second.getMaxWireLength()); double len = Math.min(first.getMaxWireLength(), second.getMaxWireLength());
@ -38,7 +38,7 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
(secondPos.zCoord) - (firstPos.zCoord) (secondPos.zCoord) - (firstPos.zCoord)
); );
return len >= delta.lengthVector(); return len >= delta.lengthVector() ? 0 : 3;
} }
public void addConnection(int x, int y, int z) { public void addConnection(int x, int y, int z) {