From cfd70efda24c8e2e0a58415a238a0f9895d53718 Mon Sep 17 00:00:00 2001 From: Christian Mesh Date: Tue, 22 Mar 2022 17:22:01 -0400 Subject: [PATCH] bump to 1.17.1 --- build.gradle | 18 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../java/trackapi/compat/MinecraftRail.java | 68 +++++++++---------- src/main/java/trackapi/lib/ITrack.java | 7 +- src/main/java/trackapi/lib/ITrackBlock.java | 10 +-- src/main/java/trackapi/lib/Util.java | 18 ++--- src/main/resources/META-INF/mods.toml | 6 +- 7 files changed, 65 insertions(+), 64 deletions(-) diff --git a/build.gradle b/build.gradle index 75a23ef..04a390e 100644 --- a/build.gradle +++ b/build.gradle @@ -8,23 +8,23 @@ buildscript { mavenCentral() } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true classpath 'cam72cam.universalmodcore:UniversalModCoreGradle:0.1.3' } } apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' -apply plugin: 'maven' +//apply plugin: 'maven' apply plugin: 'maven-publish' -java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8. +java.toolchain.languageVersion = JavaLanguageVersion.of(16) // Mojang ships Java 8 to end users, so your mod should target Java 8. String baseVersion = "1.2" if (!"release".equalsIgnoreCase(System.getProperty("target"))) { baseVersion += "-" + Util.GitRevision() } -version = "1.16.5-forge-" + baseVersion +version = "1.17.1-forge-" + baseVersion group = "trackapi" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "TrackAPI" @@ -34,7 +34,7 @@ minecraft { // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'official', version: '1.16.5' + mappings channel: 'official', version: '1.17.1' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') @@ -100,7 +100,7 @@ dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.16.5-36.1.0' + minecraft 'net.minecraftforge:forge:1.17.1-37.1.1' // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" @@ -137,8 +137,8 @@ jar { } } -jar.finalizedBy('reobfJar') - +//jar.finalizedBy('reobfJar') +/* // Example configuration to allow publishing using the maven-publish task // we define a custom artifact that is sourced from the reobfJar output task // and then declare that to be published @@ -180,4 +180,4 @@ uploadArchives { } } } - +*/ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8bf36ee..8ad73a7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip diff --git a/src/main/java/trackapi/compat/MinecraftRail.java b/src/main/java/trackapi/compat/MinecraftRail.java index cc06148..9f161ff 100644 --- a/src/main/java/trackapi/compat/MinecraftRail.java +++ b/src/main/java/trackapi/compat/MinecraftRail.java @@ -1,12 +1,12 @@ package trackapi.compat; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.BlockState; -import net.minecraft.entity.item.minecart.MinecartEntity; -import net.minecraft.state.properties.RailShape; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.vehicle.Minecart; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.RailShape; import trackapi.lib.Gauges; import trackapi.lib.ITrack; @@ -14,14 +14,14 @@ import java.util.Map; public class MinecraftRail implements ITrack { - private static Map vectors = new HashMap<>(); - private static Map centers = new HashMap<>(); + private static Map vectors = new HashMap<>(); + private static Map centers = new HashMap<>(); static { - Vector3d north = new Vector3d(0, 0, 1); - Vector3d south = new Vector3d(0, 0, -1); - Vector3d east = new Vector3d(1, 0, 0); - Vector3d west = new Vector3d(-1, 0, 0); - Vector3d ascending = new Vector3d(0, 1, 0); + Vec3 north = new Vec3(0, 0, 1); + Vec3 south = new Vec3(0, 0, -1); + Vec3 east = new Vec3(1, 0, 0); + Vec3 west = new Vec3(-1, 0, 0); + Vec3 ascending = new Vec3(0, 1, 0); vectors.put(RailShape.ASCENDING_EAST, east.add(ascending).normalize()); vectors.put(RailShape.ASCENDING_NORTH, north.add(ascending).normalize()); @@ -34,27 +34,27 @@ public class MinecraftRail implements ITrack { vectors.put(RailShape.SOUTH_EAST, south.add(east).normalize()); vectors.put(RailShape.SOUTH_WEST, south.add(west).normalize()); - centers.put(RailShape.ASCENDING_EAST, new Vector3d(0.5, 0.5, 0.5)); - centers.put(RailShape.ASCENDING_NORTH, new Vector3d(0.5, 0.5, 0.5)); - centers.put(RailShape.ASCENDING_SOUTH, new Vector3d(0.5, 0.5, 0.5)); - centers.put(RailShape.ASCENDING_WEST, new Vector3d(0.5, 0.5, 0.5)); - centers.put(RailShape.EAST_WEST, new Vector3d(0.5, 0.1, 0.5)); - centers.put(RailShape.NORTH_EAST, new Vector3d(0.75, 0.1, 0.25)); - centers.put(RailShape.NORTH_SOUTH, new Vector3d(0.5, 0.1, 0.5)); - centers.put(RailShape.NORTH_WEST, new Vector3d(0.25, 0.1, 0.25)); - centers.put(RailShape.SOUTH_EAST, new Vector3d(0.75, 0.1, 0.75)); - centers.put(RailShape.SOUTH_WEST, new Vector3d(0.25, 0.1, 0.75)); + centers.put(RailShape.ASCENDING_EAST, new Vec3(0.5, 0.5, 0.5)); + centers.put(RailShape.ASCENDING_NORTH, new Vec3(0.5, 0.5, 0.5)); + centers.put(RailShape.ASCENDING_SOUTH, new Vec3(0.5, 0.5, 0.5)); + centers.put(RailShape.ASCENDING_WEST, new Vec3(0.5, 0.5, 0.5)); + centers.put(RailShape.EAST_WEST, new Vec3(0.5, 0.1, 0.5)); + centers.put(RailShape.NORTH_EAST, new Vec3(0.75, 0.1, 0.25)); + centers.put(RailShape.NORTH_SOUTH, new Vec3(0.5, 0.1, 0.5)); + centers.put(RailShape.NORTH_WEST, new Vec3(0.25, 0.1, 0.25)); + centers.put(RailShape.SOUTH_EAST, new Vec3(0.75, 0.1, 0.75)); + centers.put(RailShape.SOUTH_WEST, new Vec3(0.25, 0.1, 0.75)); } private RailShape direction; private BlockPos pos; - public MinecraftRail(World world, BlockPos pos) { + public MinecraftRail(Level world, BlockPos pos) { this.pos = pos; BlockState state = world.getBlockState(pos); - AbstractRailBlock blockrailbase = (AbstractRailBlock)state.getBlock(); - this.direction = blockrailbase.getRailDirection(state, world, pos, new MinecartEntity(world, pos.getX(), pos.getY(), pos.getZ())); + BaseRailBlock blockrailbase = (BaseRailBlock)state.getBlock(); + this.direction = blockrailbase.getRailDirection(state, world, pos, new Minecart(world, pos.getX(), pos.getY(), pos.getZ())); } @Override @@ -63,11 +63,11 @@ public double getTrackGauge() { } @Override - public Vector3d getNextPosition(Vector3d currentPosition, Vector3d motion) { - Vector3d trackMovement = vectors.get(direction); - Vector3d trackCenter = centers.get(direction); + public Vec3 getNextPosition(Vec3 currentPosition, Vec3 motion) { + Vec3 trackMovement = vectors.get(direction); + Vec3 trackCenter = centers.get(direction); - Vector3d posRelativeToCenter = currentPosition.vectorTo(Vector3d.atLowerCornerOf(pos).add(trackCenter)); + Vec3 posRelativeToCenter = currentPosition.vectorTo(Vec3.atLowerCornerOf(pos).add(trackCenter)); double distanceToCenter = posRelativeToCenter.length(); // Determine if trackMovement should be positive or negative as relative to block center @@ -75,7 +75,7 @@ public Vector3d getNextPosition(Vector3d currentPosition, Vector3d motion) { boolean trackMotionInverted = motion.distanceTo(trackMovement) > motion.scale(-1).distanceTo(trackMovement); - Vector3d newPosition = Vector3d.atLowerCornerOf(pos).add(trackCenter); + Vec3 newPosition = Vec3.atLowerCornerOf(pos).add(trackCenter); //Correct new pos to track alignment newPosition = newPosition.add(trackMovement.scale(trackPosMotionInverted ? -distanceToCenter : distanceToCenter)); // Move new pos along track alignment @@ -83,8 +83,8 @@ public Vector3d getNextPosition(Vector3d currentPosition, Vector3d motion) { return newPosition; } - public static boolean isRail(World world, BlockPos pos) { - return AbstractRailBlock.isRail(world, pos); + public static boolean isRail(Level world, BlockPos pos) { + return BaseRailBlock.isRail(world, pos); } } diff --git a/src/main/java/trackapi/lib/ITrack.java b/src/main/java/trackapi/lib/ITrack.java index b398c91..f94c00a 100644 --- a/src/main/java/trackapi/lib/ITrack.java +++ b/src/main/java/trackapi/lib/ITrack.java @@ -1,6 +1,6 @@ package trackapi.lib; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public interface ITrack { @@ -15,11 +15,12 @@ public interface ITrack { /** * Used by rolling stock to look up their next position. * - * @param currentPosition - Current entity or bogey position * @param rotationYaw - Current entity rotation in degrees * @param bogieYaw - Current bogey rotation in degrees (set to rotationYaw if unused) * @param distance - Distanced traveled in meters + * @param currentPosition - Current entity or bogey position + * @param motion * @return The new position of the entity or bogey */ - public Vector3d getNextPosition(Vector3d currentPosition, Vector3d motion); + public Vec3 getNextPosition(Vec3 currentPosition, Vec3 motion); } diff --git a/src/main/java/trackapi/lib/ITrackBlock.java b/src/main/java/trackapi/lib/ITrackBlock.java index 50b9df6..3be790b 100644 --- a/src/main/java/trackapi/lib/ITrackBlock.java +++ b/src/main/java/trackapi/lib/ITrackBlock.java @@ -1,8 +1,8 @@ package trackapi.lib; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; /** * Compatibility layer for block only tracks @@ -16,7 +16,7 @@ public interface ITrackBlock { * @see Gauges#STANDARD * @see Gauges#MINECRAFT */ - public double getTrackGauge(World world, BlockPos pos); + public double getTrackGauge(Level world, BlockPos pos); /** * Used by rolling stock to look up their next position. @@ -27,5 +27,5 @@ public interface ITrackBlock { * @param distance - Distanced traveled in meters * @return The new position of the entity or bogey */ - public Vector3d getNextPosition(World world, BlockPos pos, Vector3d currentPosition, Vector3d motion); + public Vec3 getNextPosition(Level world, BlockPos pos, Vec3 currentPosition, Vec3 motion); } diff --git a/src/main/java/trackapi/lib/Util.java b/src/main/java/trackapi/lib/Util.java index ad76a02..9461e46 100644 --- a/src/main/java/trackapi/lib/Util.java +++ b/src/main/java/trackapi/lib/Util.java @@ -1,14 +1,14 @@ package trackapi.lib; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; import trackapi.compat.MinecraftRail; public class Util { - private static ITrack getInternalTileEntity(final World world, Vector3d pos, boolean acceptMinecraftRails) { + private static ITrack getInternalTileEntity(final Level world, Vec3 pos, boolean acceptMinecraftRails) { final BlockPos bp = new BlockPos(Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.z)); BlockState bs = world.getBlockState(bp); @@ -22,13 +22,13 @@ public double getTrackGauge() { return track.getTrackGauge(world, bp); } @Override - public Vector3d getNextPosition(Vector3d currentPosition, Vector3d motion) { + public Vec3 getNextPosition(Vec3 currentPosition, Vec3 motion) { return track.getNextPosition(world, bp, currentPosition, motion); } }; } - TileEntity te = world.getBlockEntity(bp); + BlockEntity te = world.getBlockEntity(bp); if (te instanceof ITrack) { return (ITrack) te; } @@ -40,7 +40,7 @@ public Vector3d getNextPosition(Vector3d currentPosition, Vector3d motion) { return null; } - public static ITrack getTileEntity(World world, Vector3d pos, boolean acceptMinecraftRails) { + public static ITrack getTileEntity(Level world, Vec3 pos, boolean acceptMinecraftRails) { ITrack track = getInternalTileEntity(world, pos, acceptMinecraftRails); if (track != null) { return track; diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 229d1ce..fd0f1cc 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[31,)" +loaderVersion="[37,)" license="MIT" [[mods]] modId="trackapi" @@ -10,12 +10,12 @@ description='''A common track interface for minecraft forge''' [[dependencies.trackapi]] modId="forge" mandatory=true - versionRange="[31,)" + versionRange="[37,)" ordering="NONE" side="BOTH" [[dependencies.trackapi]] modId="minecraft" mandatory=true - versionRange="[1.16.4]" + versionRange="[1.17.1]" ordering="NONE" side="BOTH"