This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.lx862.mtrtm.data; | ||
|
||
public enum TrainState { | ||
SKIP_COLLISION(0), | ||
HALT_DWELL(1), | ||
HALT_SPEED(2); | ||
|
||
private final int pos; | ||
|
||
TrainState(int pos) { | ||
this.pos = pos; | ||
} | ||
|
||
public int getPos() { | ||
return pos; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.lx862.mtrtm.mixin; | ||
|
||
import com.lx862.mtrtm.TransitManager; | ||
import com.lx862.mtrtm.data.TrainState; | ||
import mtr.data.Depot; | ||
import mtr.data.Train; | ||
import net.minecraft.world.level.Level; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(value = Train.class, remap = false) | ||
public class TrainMixin { | ||
@Shadow protected float speed; | ||
|
||
@Shadow protected float elapsedDwellTicks; | ||
|
||
/* Disable train collision */ | ||
@Inject(method = "simulateTrain", at = @At("TAIL"), cancellable = true) | ||
public void isRailBlocked(Level world, float ticksElapsed, Depot depot, CallbackInfo ci) { | ||
long trainId = ((Train)((Object)this)).id; | ||
if(TransitManager.getTrainState(trainId, TrainState.HALT_SPEED)) { | ||
this.speed = 0; | ||
} | ||
if(TransitManager.getTrainState(trainId, TrainState.HALT_DWELL)) { | ||
this.elapsedDwellTicks -= ticksElapsed; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters