Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
- Improved reliability when moving between different track pieces.
- Fixed ability to run steamers cold/warm, and diesel cold. yes technically you can run diesel cold IRL, but that's not how the mod has ever worked.
  • Loading branch information
EternalBlueFlame committed Dec 21, 2024
1 parent 8c696a6 commit 7923d10
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/main/java/train/common/api/EntityBogie.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,7 @@ else if (ai[1][1] != 0 && MathHelper.floor_double(posX) - i == ai[1][0] &&
else if (l == BlockIDs.tcRail.block) {
limitSpeedOnTCRail();

if(lastTrack==null || !CommonUtil.getTiles(worldObj,i,j,k).contains(lastTrack)){
lastTrack = (TileTCRail) worldObj.getTileEntity(i, j, k);
}
lastTrack = (TileTCRail) worldObj.getTileEntity(i, j, k);
int meta = lastTrack.getBlockMetadata();

if (TCRailTypes.isStraightTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && !lastTrack.getSwitchState())) {
Expand Down Expand Up @@ -480,9 +478,9 @@ else if (TCRailTypes.isTurnTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTr
}
else if (l == BlockIDs.tcRailGag.block) {
limitSpeedOnTCRail();
TileTCRailGag tileGag = (TileTCRailGag) worldObj.getTileEntity(i, j, k);

if(lastTrack==null || !CommonUtil.getTiles(worldObj,i,j,k).contains(lastTrack)){
TileTCRailGag tileGag = (TileTCRailGag) worldObj.getTileEntity(i, j, k);
lastTrack = (TileTCRail) worldObj.getTileEntity(tileGag.originX.get(0), tileGag.originY.get(0), tileGag.originZ.get(0));
}
if (TCRailTypes.isTurnTrack(lastTrack)) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/train/common/api/EntityRollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -1240,9 +1240,7 @@ private void updateOnTrack(int floor_posX, int floor_posY, int floor_posZ, Block
}
} else if (block == BlockIDs.tcRail.block) {
limitSpeedOnTCRail();
if(lastTrack==null || !CommonUtil.getTiles(worldObj,floor_posX, floor_posY, floor_posZ).contains(lastTrack)){
lastTrack = (TileTCRail) worldObj.getTileEntity(floor_posX, floor_posY, floor_posZ);
}
lastTrack = (TileTCRail) worldObj.getTileEntity(floor_posX, floor_posY, floor_posZ);
int meta = lastTrack.getBlockMetadata();

if (TCRailTypes.isStraightTrack(lastTrack) || (TCRailTypes.isSwitchTrack(lastTrack) && !lastTrack.getSwitchState())) {
Expand Down Expand Up @@ -1288,9 +1286,9 @@ private void updateOnTrack(int floor_posX, int floor_posY, int floor_posZ, Block

} else if (block == BlockIDs.tcRailGag.block) {
limitSpeedOnTCRail();
TileTCRailGag tileGag = (TileTCRailGag) worldObj.getTileEntity(floor_posX, floor_posY, floor_posZ);

if(lastTrack==null || !CommonUtil.getTiles(worldObj,floor_posX, floor_posY, floor_posZ).contains(lastTrack)){
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));
}
if (TCRailTypes.isTurnTrack(lastTrack)) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/train/common/api/Locomotive.java
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,12 @@ public void onUpdate()
if (isLockedAndNotOwner()) {
return;
}
if(this instanceof SteamTrain && (!getState().equals("hot") || !getState().equals("too hot"))){
return;
}
if(this instanceof DieselTrain && (getState().equals("broken") || getState().equals("cold"))){
return;
}
int dir = MathHelper
.floor_double((passenger.rotationYaw * 4F) / 360F + 0.5D) & 3;
if (dir == 2){
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/train/common/api/SteamTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ protected void checkInvent(ItemStack locoInvent0, ItemStack locoInvent1, SteamTr
if(cartLinked1 instanceof Tender){
if(drain==null && fill(ForgeDirection.UNKNOWN,new FluidStack(FluidRegistry.WATER, 100), false)==100) {
if (getFluid() == null || getFluid().getFluid() == FluidRegistry.WATER) {
drain = ((Tender) cartLinked1).drain(ForgeDirection.UNKNOWN, new FluidStack(FluidRegistry.WATER, 100), true);
drain = cartLinked1.drain(ForgeDirection.UNKNOWN, new FluidStack(FluidRegistry.WATER, 100), true);
}
}
for (int h = 0; h < ((Tender) cartLinked1).tenderItems.length; h++) {
if (((Tender) cartLinked1).tenderItems[h] != null && FuelHandler.steamFuelLast(((Tender) cartLinked1).tenderItems[h]) != 0) {
if (getFuel() < maxFuel && ((getFuel() + FuelHandler.steamFuelLast(((Tender) cartLinked1).tenderItems[h])) <= maxFuel)) {
fuelTrain += FuelHandler.steamFuelLast(((Tender) cartLinked1).tenderItems[h]);
hasCoalInTender = true;
((Tender) cartLinked1).decrStackSize(h, 1);
cartLinked1.decrStackSize(h, 1);
break;
}
}
Expand All @@ -217,7 +217,7 @@ protected void checkInvent(ItemStack locoInvent0, ItemStack locoInvent1, SteamTr

if(drain==null && fill(ForgeDirection.UNKNOWN,new FluidStack(FluidRegistry.WATER, 100), false)==100) {
if (getFluid() == null || getFluid().getFluid() == FluidRegistry.WATER) {
drain = ((Tender) cartLinked2).drain(ForgeDirection.UNKNOWN, new FluidStack(FluidRegistry.WATER, 100), true);
drain = cartLinked2.drain(ForgeDirection.UNKNOWN, new FluidStack(FluidRegistry.WATER, 100), true);
}
}

Expand All @@ -227,7 +227,7 @@ protected void checkInvent(ItemStack locoInvent0, ItemStack locoInvent1, SteamTr
if (getFuel() < maxFuel && ((getFuel() + FuelHandler.steamFuelLast(((Tender) cartLinked2).tenderItems[h])) <= maxFuel)) {
fuelTrain += FuelHandler.steamFuelLast(((Tender) cartLinked2).tenderItems[h]);
hasCoalInTender = true;
((Tender) cartLinked2).decrStackSize(h, 1);
cartLinked2.decrStackSize(h, 1);
break;
}
}
Expand Down

0 comments on commit 7923d10

Please sign in to comment.