Skip to content

Commit c86307a

Browse files
Merge remote-tracking branch 'origin/forge_1.17.1' into forge_1.18.2
2 parents 19c9643 + aaa8a48 commit c86307a

12 files changed

Lines changed: 234 additions & 176 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: '16'
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: 27 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1-
import cam72cam.universalmodcore.Util;
2-
31
buildscript {
42
repositories {
53
maven { url = "https://maven.minecraftforge.net/" }
6-
maven { url = "https://teamopenindustry.cc/maven" }
7-
jcenter()
4+
maven { url "https://plugins.gradle.org/" }
85
mavenCentral()
96
}
107
dependencies {
11-
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
12-
classpath 'cam72cam.universalmodcore:UniversalModCoreGradle:0.1.3'
8+
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.69', changing: true
139
}
1410
}
11+
1512
apply plugin: 'net.minecraftforge.gradle'
16-
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
1713
apply plugin: 'eclipse'
18-
//apply plugin: 'maven'
1914
apply plugin: 'maven-publish'
2015

21-
java.toolchain.languageVersion = JavaLanguageVersion.of(17) // Mojang ships Java 8 to end users, so your mod should target Java 8.
16+
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
2217

23-
String baseVersion = "1.2"
18+
String baseVersion = "1.3"
2419
if (!"release".equalsIgnoreCase(System.getProperty("target"))) {
25-
baseVersion += "-" + Util.GitRevision()
20+
try {
21+
baseVersion += "-" + 'git rev-parse --verify --short=7 HEAD'.execute().text.trim()
22+
} catch (Exception ex) {
23+
baseVersion += "-unknown"
24+
}
2625
}
2726
version = "1.18.2-forge-" + baseVersion
2827
group = "trackapi" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
2928
archivesBaseName = "TrackAPI"
3029

30+
java {
31+
withSourcesJar()
32+
}
33+
3134
minecraft {
3235
// The mappings can be changed at any time, and must be in the following format.
3336
// snapshot_YYYYMMDD Snapshot are built nightly.
@@ -36,7 +39,7 @@ minecraft {
3639
// Simply re-run your setup task after changing the mappings to update your workspace.
3740
mappings channel: 'official', version: '1.18.2'
3841
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
39-
42+
4043
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
4144

4245
// Default run configurations.
@@ -52,7 +55,7 @@ minecraft {
5255
property 'forge.logging.console.level', 'debug'
5356

5457
mods {
55-
examplemod {
58+
trackapi {
5659
source sourceSets.main
5760
}
5861
}
@@ -68,7 +71,7 @@ minecraft {
6871
property 'forge.logging.console.level', 'debug'
6972

7073
mods {
71-
examplemod {
74+
trackapi {
7275
source sourceSets.main
7376
}
7477
}
@@ -77,16 +80,13 @@ minecraft {
7780
data {
7881
workingDirectory project.file('run')
7982

80-
// Recommended logging data for a userdev environment
8183
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
82-
83-
// Recommended logging level for the console
8484
property 'forge.logging.console.level', 'debug'
8585

86-
args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')
86+
args '--mod', 'trackapi', '--all', '--output', file('src/generated/resources/')
8787

8888
mods {
89-
examplemod {
89+
trackapi {
9090
source sourceSets.main
9191
}
9292
}
@@ -97,44 +97,8 @@ minecraft {
9797
sourceSets.main.resources { srcDir 'src/generated/resources' }
9898

9999
dependencies {
100-
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
101-
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
102-
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
103100
minecraft 'net.minecraftforge:forge:1.18.2-40.0.22'
104-
105-
// You may put jars on which you depend on in ./libs or you may define them like so..
106-
// compile "some.group:artifact:version:classifier"
107-
// compile "some.group:artifact:version"
108-
109-
// Real examples
110-
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
111-
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
112-
113-
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
114-
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
115-
116-
// These dependencies get remapped to your current MCP mappings
117-
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
118-
119-
// For more info...
120-
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
121-
// http://www.gradle.org/docs/current/userguide/dependency_management.html
122-
123-
}
124-
125-
// Example for how to get properties into the manifest for reading by the runtime..
126-
jar {
127-
manifest {
128-
attributes([
129-
"Specification-Title": "trackapi",
130-
"Specification-Vendor": "trackapi",
131-
"Specification-Version": "1", // We are version 1 of ourselves
132-
"Implementation-Title": project.name,
133-
"Implementation-Version": "${version}",
134-
"Implementation-Vendor" :"trackapi",
135-
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
136-
])
137-
}
101+
minecraftLibrary "org.apache.maven.wagon:wagon-ssh:3.5.3"
138102
}
139103

140104
jar.finalizedBy('reobfJar')
@@ -143,6 +107,8 @@ publishing {
143107
publications {
144108
mavenJava(MavenPublication) {
145109
artifact jar
110+
artifact sourcesJar
111+
artifactId archivesBaseName
146112
}
147113
}
148114
repositories {
@@ -156,49 +122,12 @@ publishing {
156122
}
157123
}
158124

159-
160-
161-
162-
/*
163-
// Example configuration to allow publishing using the maven-publish task
164-
// we define a custom artifact that is sourced from the reobfJar output task
165-
// and then declare that to be published
166-
// Note you'll need to add a repository here
167-
def reobfFile = file("$buildDir/reobfJar/output.jar")
168-
def reobfArtifact = artifacts.add('default', reobfFile) {
169-
type 'jar'
170-
builtBy 'reobfJar'
171-
}
172-
publishing {
173-
publications {
174-
mavenJava(MavenPublication) {
175-
artifact reobfArtifact
176-
}
177-
}
178-
repositories {
179-
maven {
180-
url "file:///${project.projectDir}/mcmodsrepo"
181-
}
125+
task ('showBuildInfo') {
126+
doLast {
127+
System.out.println("Build Uploaded to Maven at: ")
128+
System.out.println("https://teamopenindustry.cc/maven/trackapi/TrackAPI/${version}/TrackAPI-${version}.jar")
182129
}
183130
}
184131

185-
task deployJar(type: Jar)
186-
187-
configurations {
188-
deployerJars
189-
}
132+
publish.finalizedBy showBuildInfo
190133

191-
dependencies {
192-
deployerJars "org.apache.maven.wagon:wagon-ssh:2.9"
193-
}
194-
195-
uploadArchives {
196-
tasks.uploadArchives.dependsOn build
197-
repositories.mavenDeployer {
198-
configuration = configurations.deployerJars
199-
repository(url: "scp://teamopenindustry.cc/var/www/html/maven/") {
200-
authentication(userName: "mavenci", privateKey: "publish_key")
201-
}
202-
}
203-
}
204-
*/

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip

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: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
package trackapi.compat;
22

3-
import net.minecraft.world.phys.Vec3;
4-
import net.minecraft.core.BlockPos;
53
import net.minecraft.world.entity.vehicle.Minecart;
64
import net.minecraft.world.level.Level;
75
import net.minecraft.world.level.block.BaseRailBlock;
6+
import net.minecraft.world.phys.Vec3;
7+
import net.minecraft.core.BlockPos;
88
import net.minecraft.world.level.block.state.BlockState;
99
import net.minecraft.world.level.block.state.properties.RailShape;
1010
import trackapi.lib.Gauges;
11-
import trackapi.lib.ITrack;
11+
import trackapi.lib.ITrackV2;
12+
import trackapi.lib.PathingData;
1213

1314
import java.util.HashMap;
1415
import java.util.Map;
1516

16-
public class MinecraftRail implements ITrack {
17+
/**
18+
* Wrapper for vanilla rail
19+
*/
20+
public class MinecraftRail implements ITrackV2 {
1721
private static Map<RailShape, Vec3> vectors = new HashMap<>();
1822
private static Map<RailShape, Vec3> centers = new HashMap<>();
1923
static {
@@ -47,8 +51,8 @@ public class MinecraftRail implements ITrack {
4751
}
4852

4953

50-
private RailShape direction;
51-
private BlockPos pos;
54+
private final RailShape direction;
55+
private final BlockPos pos;
5256

5357
public MinecraftRail(Level world, BlockPos pos) {
5458
this.pos = pos;
@@ -58,33 +62,37 @@ public MinecraftRail(Level world, BlockPos pos) {
5862
}
5963

6064
@Override
61-
public double getTrackGauge() {
62-
return Gauges.MINECRAFT;
65+
public double[] getTrackGauges() {
66+
return new double[]{Gauges.MINECRAFT};
6367
}
6468

6569
@Override
66-
public Vec3 getNextPosition(Vec3 currentPosition, Vec3 motion) {
67-
Vec3 trackMovement = vectors.get(direction);
70+
public<D extends PathingData> void getNextPosition(D inputData, Vec3 motion, double gauge) {
71+
Vec3 currentPosition = inputData.getPos();
72+
73+
Vec3 trackMovement = vectors.get(direction);
6874
Vec3 trackCenter = centers.get(direction);
6975

70-
Vec3 posRelativeToCenter = currentPosition.vectorTo(Vec3.atLowerCornerOf(pos).add(trackCenter));
76+
Vec3 pos = Vec3.atLowerCornerOf(this.pos).add(trackCenter);
77+
Vec3 posRelativeToCenter = currentPosition.subtract(pos);
7178
double distanceToCenter = posRelativeToCenter.length();
7279

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

7683
boolean trackMotionInverted = motion.distanceTo(trackMovement) > motion.scale(-1).distanceTo(trackMovement);
7784

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

8695
public static boolean isRail(Level world, BlockPos pos) {
8796
return BaseRailBlock.isRail(world, pos);
8897
}
89-
9098
}
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
}

0 commit comments

Comments
 (0)