From 3e26501bc817407e380f7e8448001fab5f57d069 Mon Sep 17 00:00:00 2001 From: TheDoctor1138 Date: Tue, 13 Aug 2024 15:31:09 +0200 Subject: [PATCH] Crash on placing diagonal straights Placement check was broken, would attempt to set a flag to a tile that doesnt exist. --- src/main/java/train/common/items/ItemTCRail.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/train/common/items/ItemTCRail.java b/src/main/java/train/common/items/ItemTCRail.java index 0c88e6fb2..96ff50e5d 100644 --- a/src/main/java/train/common/items/ItemTCRail.java +++ b/src/main/java/train/common/items/ItemTCRail.java @@ -3100,17 +3100,19 @@ private boolean diagonalStraight(EntityPlayer player, World world, int x, int y, } for (int i = 0; i <= trackLength; i += 3){ - if (!canPlaceTrack(player, world, x + (i * dx), y + 1, z + (i * dz)) - || !canPlaceTrack(player, world, x + (i * dx) + dx, y + 1, z + (i * dz) + dz) - || !canPlaceTrack(player, world, x + (i * dx) + (2*dx), y + 1, z + (i * dz) + (2*dz))) - + if (!canPlaceTrack(player, world, x + (i * dx), y + 1, z + (i * dz)) + || !canPlaceTrack(player, world, x + (i * dx) + dx, y + 1, z + (i * dz) + dz) + || !canPlaceTrack(player, world, x + (i * dx) + (2*dx), y + 1, z + (i * dz) + (2*dz))) return false; for(int j = 0; j < 3 ; j++){ - if(!canPlaceTrack(player, world, x + (i * dx) + dx, y + 1, z + (i * dz)) - || !canPlaceTrack(player, world, x + (i * dx) , y + 1, z + (i * dz) + dz)) - return false; + + if(!canPlaceTrack(player, world, x + (i * dx) + (j * dx ) + dx , y + 1, z + (i * dz) + (j * dz)) + || !canPlaceTrack(player, world, x + (i * dx) + (j * dx), y + 1 , z + (i * dz) + (j * dz) + dz)) + return false; } + + } for (int i = 0; i <= trackLength; i += 3){