Skip to content

Commit

Permalink
bump to 1.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Mar 22, 2022
1 parent 8c45b19 commit cfd70ef
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 64 deletions.
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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')
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -180,4 +180,4 @@ uploadArchives {
}
}
}

*/
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
68 changes: 34 additions & 34 deletions src/main/java/trackapi/compat/MinecraftRail.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
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;

import java.util.HashMap;
import java.util.Map;

public class MinecraftRail implements ITrack {
private static Map<RailShape, Vector3d> vectors = new HashMap<>();
private static Map<RailShape, Vector3d> centers = new HashMap<>();
private static Map<RailShape, Vec3> vectors = new HashMap<>();
private static Map<RailShape, Vec3> 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());
Expand All @@ -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
Expand All @@ -63,28 +63,28 @@ 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
boolean trackPosMotionInverted = posRelativeToCenter.distanceTo(trackMovement) < posRelativeToCenter.scale(-1).distanceTo(trackMovement);

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
newPosition = newPosition.add(trackMovement.scale(trackMotionInverted ? -motion.length() : motion.length()));
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);
}

}
7 changes: 4 additions & 3 deletions src/main/java/trackapi/lib/ITrack.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package trackapi.lib;

import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.phys.Vec3;

public interface ITrack {

Expand All @@ -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);
}
10 changes: 5 additions & 5 deletions src/main/java/trackapi/lib/ITrackBlock.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -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);
}
18 changes: 9 additions & 9 deletions src/main/java/trackapi/lib/Util.java
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader="javafml"
loaderVersion="[31,)"
loaderVersion="[37,)"
license="MIT"
[[mods]]
modId="trackapi"
Expand All @@ -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"

0 comments on commit cfd70ef

Please sign in to comment.