From 54b5a1de49d26789ed5a44eb8f7273d3bb310809 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Thu, 9 Jun 2022 08:47:44 +0200 Subject: [PATCH] Updated to 1.19 --- build.gradle | 2 +- gradle.properties | 10 +++++----- src/main/java/nl/andrewlalis/speed_carts/Config.java | 1 + .../speed_carts/mixin/AbstractMinecartMixin.java | 12 +++++------- src/main/resources/fabric.mod.json | 6 +++--- src/main/resources/speed-carts.mixins.json | 2 +- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index 559d753..22646ab 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.10-SNAPSHOT' + id 'fabric-loom' version '0.12-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index 967299f..5d67758 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/versions.html - minecraft_version=1.18 - yarn_mappings=1.18+build.1 - loader_version=0.12.8 + minecraft_version=1.19 + yarn_mappings=1.19+build.1 + loader_version=0.14.7 # Mod Properties - mod_version = 1.3.1 + mod_version = 1.4.0 maven_group = nl.andrewlalis archives_base_name = speed-carts # Dependencies - fabric_version=0.43.1+1.18 + fabric_version=0.55.3+1.19 diff --git a/src/main/java/nl/andrewlalis/speed_carts/Config.java b/src/main/java/nl/andrewlalis/speed_carts/Config.java index 8c42641..b7b3ce9 100644 --- a/src/main/java/nl/andrewlalis/speed_carts/Config.java +++ b/src/main/java/nl/andrewlalis/speed_carts/Config.java @@ -39,6 +39,7 @@ public class Config { private void ensureConfigExists() throws IOException { if (!Files.exists(CONFIG_FILE)) { + Files.createDirectories(CONFIG_FILE.getParent()); OutputStream out = Files.newOutputStream(CONFIG_FILE); InputStream defaultConfigInputStream = SpeedCarts.class.getClassLoader().getResourceAsStream("default_config.yaml"); if (defaultConfigInputStream == null) { diff --git a/src/main/java/nl/andrewlalis/speed_carts/mixin/AbstractMinecartMixin.java b/src/main/java/nl/andrewlalis/speed_carts/mixin/AbstractMinecartMixin.java index dd6354d..2262b73 100644 --- a/src/main/java/nl/andrewlalis/speed_carts/mixin/AbstractMinecartMixin.java +++ b/src/main/java/nl/andrewlalis/speed_carts/mixin/AbstractMinecartMixin.java @@ -18,7 +18,6 @@ import net.minecraft.sound.SoundEvents; import net.minecraft.state.property.Properties; import net.minecraft.text.Text; import net.minecraft.util.DyeColor; -import net.minecraft.util.Identifier; import net.minecraft.util.math.*; import net.minecraft.world.World; import nl.andrewlalis.speed_carts.SpeedCarts; @@ -77,9 +76,9 @@ public abstract class AbstractMinecartMixin extends Entity { } @Shadow - protected abstract double getMaxOffRailSpeed(); + protected abstract double getMaxSpeed(); - @Inject(at = @At("HEAD"), method = "getMaxOffRailSpeed", cancellable = true) + @Inject(at = @At("HEAD"), method = "getMaxSpeed", cancellable = true) public void getMaxOffRailSpeedOverwrite(CallbackInfoReturnable cir) { cir.setReturnValue(this.maxSpeedBps / 20.0); } @@ -122,8 +121,7 @@ public abstract class AbstractMinecartMixin extends Entity { for (BlockPos position : this.getPositionsToCheck(pos)) { BlockEntity blockEntity = this.world.getBlockEntity(position); - if (blockEntity instanceof SignBlockEntity) { - SignBlockEntity sign = (SignBlockEntity) blockEntity; + if (blockEntity instanceof SignBlockEntity sign) { if (!sign.getPos().equals(this.lastUpdatedFrom) || this.world.getTime() > this.lastSpeedUpdate + SPEED_UPDATE_COOLDOWN) { BlockState state = this.world.getBlockState(position); Direction dir = (Direction) state.getEntries().get(Properties.HORIZONTAL_FACING); @@ -143,7 +141,7 @@ public abstract class AbstractMinecartMixin extends Entity { */ private boolean updateSpeedForSign(SignBlockEntity sign) { Text text = sign.getTextOnRow(0, false); - String s = text.asString(); + String s = text.getString(); if (!SIGN_PATTERN.matcher(s).matches()) { return false; } @@ -312,7 +310,7 @@ public abstract class AbstractMinecartMixin extends Entity { f = q + i * x; this.setPosition(d, e, f); v = this.hasPassengers() ? 0.75D : 1.0D; - w = this.getMaxOffRailSpeed(); + w = this.getMaxSpeed(); velocity = this.getVelocity(); Vec3d movement = new Vec3d(MathHelper.clamp(v * velocity.x, -w, w), 0.0D, MathHelper.clamp(v * velocity.z, -w, w)); this.move(MovementType.SELF, movement); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 56a5ede..d61a25d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,8 +27,8 @@ ], "depends": { - "fabricloader": ">=0.11.3", - "minecraft": "1.18.x", - "java": ">=16" + "fabricloader": ">=0.14.7", + "minecraft": "1.19.x", + "java": ">=17" } } diff --git a/src/main/resources/speed-carts.mixins.json b/src/main/resources/speed-carts.mixins.json index 086694c..3ded8fb 100644 --- a/src/main/resources/speed-carts.mixins.json +++ b/src/main/resources/speed-carts.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "nl.andrewlalis.speed_carts.mixin", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_17", "mixins": [ "AbstractMinecartMixin" ],