Skip to content

Commit 3868f8c

Browse files
Merge remote-tracking branch 'origin/neoforge_1.21.4' into neoforge_1.21.8
2 parents c8fd64d + 869b0e8 commit 3868f8c

11 files changed

Lines changed: 246 additions & 159 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v5
1010
- run: |
1111
ref=`echo ${github_ref} | sed -e 's,refs/heads/,,' | tr '/' '-'`
1212
echo $ref
1313
echo "::set-env name=ref::$ref"
1414
env:
1515
github_ref: ${{ github.ref }}
1616
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
17+
- name: Set up JDK
18+
uses: actions/setup-java@v5
19+
with:
20+
java-version: '21'
21+
distribution: 'temurin'
1722
- name: keyscan
1823
run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa teamopenindustry.cc >> ~/.ssh/known_hosts
1924
- name: Gradle publish
2025
env:
2126
MAVENCI_PASS: ${{ secrets.MAVENCI_PASS }}
2227
run: ./gradlew publish
28+
- uses: actions/upload-artifact@v6
29+
with:
30+
name: TrackAPI-${{ env.ref }}
31+
path: build/libs/TrackAPI-*

build.gradle

Lines changed: 38 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
1-
import cam72cam.universalmodcore.Util;
2-
31
buildscript {
42
repositories {
5-
// maven { url = "https://maven.minecraftforge.net/" }
6-
maven {
7-
name "neoforgedReleases"
8-
url "https://maven.neoforged.net/releases"
9-
}
10-
maven { url = "https://teamopenindustry.cc/maven" }
3+
maven { url "https://maven.neoforged.net/releases" }
4+
maven { url "https://plugins.gradle.org/" }
115
mavenCentral()
126
gradlePluginPortal()
137
}
148
dependencies {
15-
// classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
169
classpath group: 'net.neoforged.gradle', name: 'userdev', version: '7.1.11'
17-
classpath 'cam72cam.universalmodcore:UniversalModCoreGradle:0.1.3'
1810
}
1911
}
12+
2013
apply plugin: 'net.neoforged.gradle.userdev'
21-
// Only edit below this line, the above code adds and enables the necessary things for NeoForge to be setup.
2214
apply plugin: 'eclipse'
23-
//apply plugin: 'maven'
2415
apply plugin: 'maven-publish'
2516

26-
java.toolchain.languageVersion = JavaLanguageVersion.of(21) // Since 1.20.5
17+
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
2718

28-
String baseVersion = "1.2"
19+
String baseVersion = "1.3"
2920
if (!"release".equalsIgnoreCase(System.getProperty("target"))) {
30-
baseVersion += "-" + Util.GitRevision()
21+
try {
22+
baseVersion += "-" + 'git rev-parse --verify --short=7 HEAD'.execute().text.trim()
23+
} catch (Exception ex) {
24+
baseVersion += "-unknown"
25+
}
3126
}
3227
version = "1.21.8-neoforge-" + baseVersion
3328
group = "trackapi" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
3429
archivesBaseName = "TrackAPI"
3530

31+
configurations {
32+
minecraftLibrary
33+
implementation.extendsFrom minecraftLibrary
34+
}
35+
36+
java {
37+
withSourcesJar()
38+
}
39+
3640
runs {
3741
// applies to all the run configs below
3842
configureEach {
@@ -48,6 +52,10 @@ runs {
4852
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
4953
systemProperty 'forge.logging.console.level', 'debug'
5054

55+
dependencies {
56+
runtime project.configurations.minecraftLibrary
57+
}
58+
5159
modSource project.sourceSets.main
5260
}
5361

@@ -77,44 +85,24 @@ runs {
7785
}
7886
}
7987

80-
8188
sourceSets.main.resources { srcDir 'src/generated/resources' }
8289

8390
dependencies {
84-
8591
implementation 'net.neoforged:neoforge:21.8.52'
86-
87-
// You may put jars on which you depend on in ./libs or you may define them like so..
88-
// compile "some.group:artifact:version:classifier"
89-
// compile "some.group:artifact:version"
90-
91-
// Real examples
92-
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
93-
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
94-
95-
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
96-
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
97-
98-
// These dependencies get remapped to your current MCP mappings
99-
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
100-
101-
// For more info...
102-
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
103-
// http://www.gradle.org/docs/current/userguide/dependency_management.html
104-
92+
minecraftLibrary "org.apache.maven.wagon:wagon-ssh:3.5.3"
10593
}
10694

10795
// Example for how to get properties into the manifest for reading by the runtime..
10896
jar {
10997
manifest {
11098
attributes([
111-
"Specification-Title" : "trackapi",
112-
"Specification-Vendor" : "trackapi",
113-
"Specification-Version" : "1", // We are version 1 of ourselves
114-
"Implementation-Title" : project.name,
115-
"Implementation-Version" : "${version}",
116-
"Implementation-Vendor" : "trackapi",
117-
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
99+
"Specification-Title": "trackapi",
100+
"Specification-Vendor": "trackapi",
101+
"Specification-Version": "1", // We are version 1 of ourselves
102+
"Implementation-Title": project.name,
103+
"Implementation-Version": "${version}",
104+
"Implementation-Vendor" :"trackapi",
105+
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
118106
])
119107
}
120108
}
@@ -123,6 +111,8 @@ publishing {
123111
publications {
124112
mavenJava(MavenPublication) {
125113
artifact jar
114+
artifact sourcesJar
115+
artifactId archivesBaseName
126116
}
127117
}
128118
repositories {
@@ -136,47 +126,12 @@ publishing {
136126
}
137127
}
138128

139-
140-
/*
141-
// Example configuration to allow publishing using the maven-publish task
142-
// we define a custom artifact that is sourced from the reobfJar output task
143-
// and then declare that to be published
144-
// Note you'll need to add a repository here
145-
def reobfFile = file("$buildDir/reobfJar/output.jar")
146-
def reobfArtifact = artifacts.add('default', reobfFile) {
147-
type 'jar'
148-
builtBy 'reobfJar'
149-
}
150-
publishing {
151-
publications {
152-
mavenJava(MavenPublication) {
153-
artifact reobfArtifact
154-
}
155-
}
156-
repositories {
157-
maven {
158-
url "file:///${project.projectDir}/mcmodsrepo"
159-
}
129+
task ('showBuildInfo') {
130+
doLast {
131+
System.out.println("Build Uploaded to Maven at: ")
132+
System.out.println("https://teamopenindustry.cc/maven/trackapi/TrackAPI/${version}/TrackAPI-${version}.jar")
160133
}
161134
}
162135

163-
task deployJar(type: Jar)
136+
publish.finalizedBy showBuildInfo
164137

165-
configurations {
166-
deployerJars
167-
}
168-
169-
dependencies {
170-
deployerJars "org.apache.maven.wagon:wagon-ssh:2.9"
171-
}
172-
173-
uploadArchives {
174-
tasks.uploadArchives.dependsOn build
175-
repositories.mavenDeployer {
176-
configuration = configurations.deployerJars
177-
repository(url: "scp://teamopenindustry.cc/var/www/html/maven/") {
178-
authentication(userName: "mavenci", privateKey: "publish_key")
179-
}
180-
}
181-
}
182-
*/

src/main/java/trackapi/TrackAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
public class TrackAPI
77
{
88
public static final String MODID = "trackapi";
9-
public static final String VERSION = "1.2";
9+
public static final String VERSION = "1.3";
1010
}

src/main/java/trackapi/compat/MinecraftRail.java

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22

33
import net.minecraft.world.phys.Vec3;
44
import net.minecraft.core.BlockPos;
5+
import net.minecraft.world.entity.vehicle.Minecart;
56
import net.minecraft.world.level.Level;
67
import net.minecraft.world.level.block.BaseRailBlock;
8+
import net.minecraft.world.phys.Vec3;
9+
import net.minecraft.core.BlockPos;
710
import net.minecraft.world.level.block.state.BlockState;
811
import net.minecraft.world.level.block.state.properties.RailShape;
912
import trackapi.lib.Gauges;
10-
import trackapi.lib.ITrack;
13+
import trackapi.lib.ITrackV2;
14+
import trackapi.lib.PathingData;
1115

1216
import java.util.HashMap;
1317
import java.util.Map;
1418

15-
public class MinecraftRail implements ITrack {
19+
/**
20+
* Wrapper for vanilla rail
21+
*/
22+
public class MinecraftRail implements ITrackV2 {
1623
private static Map<RailShape, Vec3> vectors = new HashMap<>();
1724
private static Map<RailShape, Vec3> centers = new HashMap<>();
1825
static {
@@ -46,8 +53,8 @@ public class MinecraftRail implements ITrack {
4653
}
4754

4855

49-
private RailShape direction;
50-
private BlockPos pos;
56+
private final RailShape direction;
57+
private final BlockPos pos;
5158

5259
public MinecraftRail(Level world, BlockPos pos) {
5360
this.pos = pos;
@@ -57,33 +64,37 @@ public MinecraftRail(Level world, BlockPos pos) {
5764
}
5865

5966
@Override
60-
public double getTrackGauge() {
61-
return Gauges.MINECRAFT;
67+
public double[] getTrackGauges() {
68+
return new double[]{Gauges.MINECRAFT};
6269
}
6370

6471
@Override
65-
public Vec3 getNextPosition(Vec3 currentPosition, Vec3 motion) {
66-
Vec3 trackMovement = vectors.get(direction);
72+
public<D extends PathingData> void getNextPosition(D inputData, Vec3 motion, double gauge) {
73+
Vec3 currentPosition = inputData.getPos();
74+
75+
Vec3 trackMovement = vectors.get(direction);
6776
Vec3 trackCenter = centers.get(direction);
6877

69-
Vec3 posRelativeToCenter = currentPosition.vectorTo(Vec3.atLowerCornerOf(pos).add(trackCenter));
78+
Vec3 pos = Vec3.atLowerCornerOf(this.pos).add(trackCenter);
79+
Vec3 posRelativeToCenter = currentPosition.subtract(pos);
7080
double distanceToCenter = posRelativeToCenter.length();
7181

7282
// Determine if trackMovement should be positive or negative as relative to block center
7383
boolean trackPosMotionInverted = posRelativeToCenter.distanceTo(trackMovement) < posRelativeToCenter.scale(-1).distanceTo(trackMovement);
7484

7585
boolean trackMotionInverted = motion.distanceTo(trackMovement) > motion.scale(-1).distanceTo(trackMovement);
7686

77-
Vec3 newPosition = Vec3.atLowerCornerOf(pos).add(trackCenter);
78-
//Correct new pos to track alignment
79-
newPosition = newPosition.add(trackMovement.scale(trackPosMotionInverted ? -distanceToCenter : distanceToCenter));
80-
// Move new pos along track alignment
81-
newPosition = newPosition.add(trackMovement.scale(trackMotionInverted ? -motion.length() : motion.length()));
82-
return newPosition;
87+
Vec3 newPosition = pos;
88+
double factor =
89+
//Correct new pos to track alignment
90+
(trackPosMotionInverted ? -distanceToCenter : distanceToCenter)
91+
//And Move new pos along track alignment
92+
+ (trackMotionInverted ? -motion.length() : motion.length());
93+
newPosition = newPosition.add(trackMovement.scale(factor));
94+
inputData.setPos(newPosition).setRoll(0d);
8395
}
8496

8597
public static boolean isRail(Level world, BlockPos pos) {
8698
return BaseRailBlock.isRail(world, pos);
8799
}
88-
89100
}
Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
11
package trackapi.lib;
22

3+
/**
4+
* Some gauge constants in meters
5+
*/
36
public class Gauges {
47
/**
5-
* US Standard Gauge in meters
8+
* Minecraft Gauge
9+
*/
10+
public static final double MINECRAFT = 0.632;
11+
12+
/**
13+
* 2 Foot 6 Inches Narrow Gauge
14+
*/
15+
public static final double TWO_FOOT_SIX_INCHES = 0.762;
16+
17+
/**
18+
* 3 Foot Narrow Gauge
19+
*/
20+
public static final double THREE_FOOT = 0.9144;
21+
22+
/**
23+
* Meter Gauge
24+
*/
25+
public static final double METER = 1.000;
26+
27+
/**
28+
* Cape gauge
29+
*/
30+
public static final double CAPE = 1.067;
31+
32+
/**
33+
* US Standard Gauge
634
*/
735
public static final double STANDARD = 1.435;
836

937
/**
10-
* Minecraft Gauge in meters
38+
* Russian Standard Gauge
1139
*/
12-
public static final double MINECRAFT = 0.632;
40+
public static final double RU_STANDARD = 1.524;
41+
42+
/**
43+
* Brunel Gauge
44+
*/
45+
public static final double BRUNEL = 2.140;
1346
}

src/main/java/trackapi/lib/ITrack.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@ public interface ITrack {
77
/**
88
* The distance between the rails measured in meters
99
*
10-
* @see Gauges#STANDARD
11-
* @see Gauges#MINECRAFT
10+
* @see Gauges
1211
*/
13-
public double getTrackGauge();
12+
double getTrackGauge();
1413

1514
/**
16-
* Used by rolling stock to look up their next position.
15+
* Used by rolling stocks to look up their next position.
1716
*
18-
* @param rotationYaw - Current entity rotation in degrees
19-
* @param bogieYaw - Current bogey rotation in degrees (set to rotationYaw if unused)
20-
* @param distance - Distanced traveled in meters
21-
* @param currentPosition - Current entity or bogey position
22-
* @param motion
23-
* @return The new position of the entity or bogey
17+
* @param currentPosition Current position of entity or bogey
18+
* @param motion Current velocity of entity or bogey
19+
* @return Next found position on the track
2420
*/
25-
public Vec3 getNextPosition(Vec3 currentPosition, Vec3 motion);
21+
Vec3 getNextPosition(Vec3 currentPosition, Vec3 motion);
2622
}

0 commit comments

Comments
 (0)