Skip to content

Commit

Permalink
fixed some pathing crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
EternalBlueFlame committed Dec 22, 2024
1 parent 2498fed commit 5ab34f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
9 changes: 4 additions & 5 deletions src/main/java/train/common/api/EntityBogie.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,12 @@ else if (l == BlockIDs.tcRail.block) {
limitSpeedOnTCRail();

lastTrack = (TileTCRail) worldObj.getTileEntity(i, j, k);
int meta = lastTrack.getBlockMetadata();

if (TCRailTypes.isStraightTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && !lastTrack.getSwitchState())) {
moveOnTCStraight(j, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
}
else if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && lastTrack.getSwitchState())) {
if (shouldIgnoreSwitch(lastTrack, i, j, k, meta)) {
if (shouldIgnoreSwitch(lastTrack, i, j, k, lastTrack.getBlockMetadata())) {
moveOnTCStraight(j, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
}
else {
Expand All @@ -471,7 +470,7 @@ else if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTr
} else if (TCRailTypes.isDiagonalCrossingTrack(lastTrack)) {
moveOnTCDiagonal(i, j, k, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), lastTrack.getRailLength());
} else if (TCRailTypes.isCurvedSlopeTrack(lastTrack)) {
moveOnTCCurvedSlope(i, j, k, lastTrack.r, lastTrack.cx, lastTrack.cz, lastTrack.xCoord, lastTrack.zCoord, meta, 1, lastTrack.slopeAngle);
moveOnTCCurvedSlope(i, j, k, lastTrack.r, lastTrack.cx, lastTrack.cz, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), 1, lastTrack.slopeAngle);
} else if (TCRailTypes.isDiagonalTrack(lastTrack)) {
moveOnTCDiagonal(i, j, k, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), lastTrack.getRailLength());
}
Expand All @@ -488,7 +487,7 @@ else if (l == BlockIDs.tcRailGag.block) {
moveOnTCStraight(j, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
}
else if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && lastTrack.getSwitchState())) {
if (shouldIgnoreSwitch(lastTrack, i, j, k, meta)) {
if (shouldIgnoreSwitch(lastTrack, i, j, k, lastTrack.getBlockMetadata())) {
moveOnTCStraight(j, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
}
else {
Expand All @@ -505,7 +504,7 @@ else if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTr
} else if (TCRailTypes.isDiagonalCrossingTrack(lastTrack)) {
moveOnTCDiagonal(i, j, k, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), lastTrack.getRailLength());
} else if (TCRailTypes.isCurvedSlopeTrack(lastTrack)) {
moveOnTCCurvedSlope(i, j, k, lastTrack.r, lastTrack.cx, lastTrack.cz, lastTrack.xCoord, lastTrack.zCoord, meta, 1, lastTrack.slopeAngle);
moveOnTCCurvedSlope(i, j, k, lastTrack.r, lastTrack.cx, lastTrack.cz, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), 1, lastTrack.slopeAngle);
} else if (TCRailTypes.isDiagonalTrack(lastTrack)) {
moveOnTCDiagonal(i, j, k, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), lastTrack.getRailLength());
}
Expand Down
34 changes: 16 additions & 18 deletions src/main/java/train/common/api/EntityRollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -1242,10 +1242,9 @@ private void updateOnTrack(int floor_posX, int floor_posY, int floor_posZ, Block
} else if (block == BlockIDs.tcRail.block) {
limitSpeedOnTCRail();
lastTrack = (TileTCRail) worldObj.getTileEntity(floor_posX, floor_posY, floor_posZ);
meta = lastTrack.getBlockMetadata();

if (TCRailTypes.isStraightTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && !lastTrack.getSwitchState())) {
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, meta);
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && lastTrack.getSwitchState())) {
if (bogieFront != null && !bogieFront.isOnRail()) {
derailSpeed = 0;
Expand All @@ -1255,12 +1254,12 @@ private void updateOnTrack(int floor_posX, int floor_posY, int floor_posZ, Block
}
if (derailSpeed == 0) {
this.unLink();
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, meta);
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else {

if (shouldIgnoreSwitch(lastTrack, floor_posX, floor_posY, floor_posZ, meta)) {
if (shouldIgnoreSwitch(lastTrack, floor_posX, floor_posY, floor_posZ, lastTrack.getBlockMetadata())) {

moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, meta);
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else {
if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && lastTrack.getSwitchState()))
moveOnTC90TurnRail(floor_posX, floor_posY, floor_posZ, lastTrack.r, lastTrack.cx, lastTrack.cz);
Expand All @@ -1270,15 +1269,15 @@ private void updateOnTrack(int floor_posX, int floor_posY, int floor_posZ, Block
// cz, tile.getType(), meta);
}
} else if (TCRailTypes.isSlopeTrack(lastTrack)) {
moveOnTCSlope(floor_posY, lastTrack.xCoord, lastTrack.zCoord, lastTrack.slopeAngle, lastTrack.slopeHeight, meta);
moveOnTCSlope(floor_posY, lastTrack.xCoord, lastTrack.zCoord, lastTrack.slopeAngle, lastTrack.slopeHeight, lastTrack.getBlockMetadata());
} else if (TCRailTypes.isCrossingTrack(lastTrack)) {
moveOnTCTwoWaysCrossing(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.yCoord, lastTrack.zCoord, meta);
moveOnTCTwoWaysCrossing(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.yCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else if (TCRailTypes.isDiagonalCrossingTrack(lastTrack)) {
moveOnTCDiamondCrossing(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.yCoord, lastTrack.zCoord, meta);
moveOnTCDiamondCrossing(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.yCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else if (TCRailTypes.isDiagonalTrack(lastTrack)) {
moveOnTCDiagonal(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), lastTrack.getRailLength());
} else if (TCRailTypes.isCurvedSlopeTrack(lastTrack)) {
moveOnTCCurvedSlope(floor_posX, floor_posY, floor_posZ, lastTrack.r, lastTrack.cx, lastTrack.cz, lastTrack.xCoord, lastTrack.zCoord, meta, 1, lastTrack.slopeAngle);
moveOnTCCurvedSlope(floor_posX, floor_posY, floor_posZ, lastTrack.r, lastTrack.cx, lastTrack.cz, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), 1, lastTrack.slopeAngle);
}

} else if (block == BlockIDs.tcRailGag.block) {
Expand All @@ -1288,9 +1287,8 @@ private void updateOnTrack(int floor_posX, int floor_posY, int floor_posZ, Block
TileTCRailGag tileGag = (TileTCRailGag) worldObj.getTileEntity(floor_posX, floor_posY, floor_posZ);
lastTrack = (TileTCRail) worldObj.getTileEntity(tileGag.originX.get(0), tileGag.originY.get(0), tileGag.originZ.get(0));
}
meta = lastTrack.getBlockMetadata();
if (TCRailTypes.isStraightTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && !lastTrack.getSwitchState())) {
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, meta);
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && lastTrack.getSwitchState())) {
if (bogieFront != null && !bogieFront.isOnRail()) {
derailSpeed = 0;
Expand All @@ -1300,12 +1298,12 @@ private void updateOnTrack(int floor_posX, int floor_posY, int floor_posZ, Block
}
if (derailSpeed == 0) {
this.unLink();
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, meta);
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else {

if (shouldIgnoreSwitch(lastTrack, floor_posX, floor_posY, floor_posZ, meta)) {
if (shouldIgnoreSwitch(lastTrack, floor_posX, floor_posY, floor_posZ, lastTrack.getBlockMetadata())) {

moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, meta);
moveOnTCStraight(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else {
if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && lastTrack.getSwitchState()))
moveOnTC90TurnRail(floor_posX, floor_posY, floor_posZ, lastTrack.r, lastTrack.cx, lastTrack.cz);
Expand All @@ -1315,15 +1313,15 @@ private void updateOnTrack(int floor_posX, int floor_posY, int floor_posZ, Block
// cz, tile.getType(), meta);
}
} else if (TCRailTypes.isSlopeTrack(lastTrack)) {
moveOnTCSlope(floor_posY, lastTrack.xCoord, lastTrack.zCoord, lastTrack.slopeAngle, lastTrack.slopeHeight, meta);
moveOnTCSlope(floor_posY, lastTrack.xCoord, lastTrack.zCoord, lastTrack.slopeAngle, lastTrack.slopeHeight, lastTrack.getBlockMetadata());
} else if (TCRailTypes.isCrossingTrack(lastTrack)) {
moveOnTCTwoWaysCrossing(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.yCoord, lastTrack.zCoord, meta);
moveOnTCTwoWaysCrossing(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.yCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else if (TCRailTypes.isDiagonalCrossingTrack(lastTrack)) {
moveOnTCDiamondCrossing(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.yCoord, lastTrack.zCoord, meta);
moveOnTCDiamondCrossing(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.yCoord, lastTrack.zCoord, lastTrack.getBlockMetadata());
} else if (TCRailTypes.isDiagonalTrack(lastTrack)) {
moveOnTCDiagonal(floor_posX, floor_posY, floor_posZ, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), lastTrack.getRailLength());
} else if (TCRailTypes.isCurvedSlopeTrack(lastTrack)) {
moveOnTCCurvedSlope(floor_posX, floor_posY, floor_posZ, lastTrack.r, lastTrack.cx, lastTrack.cz, lastTrack.xCoord, lastTrack.zCoord, meta, 1, lastTrack.slopeAngle);
moveOnTCCurvedSlope(floor_posX, floor_posY, floor_posZ, lastTrack.r, lastTrack.cx, lastTrack.cz, lastTrack.xCoord, lastTrack.zCoord, lastTrack.getBlockMetadata(), 1, lastTrack.slopeAngle);
}
} else {
lastTrack=null;
Expand Down

0 comments on commit 5ab34f6

Please sign in to comment.