diff --git a/build.gradle.kts b/build.gradle.kts index 637d578..a8d8344 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -84,7 +84,7 @@ dependencies { implementation(libs.mixinextras.forge) } else "neoForge"("net.neoforged:neoforge:${property("vers.deps.fml")}") - modImplementation("dev.nyon:KotlinLangForge:1.0.3-k${libs.versions.kotlin.orNull}-$mcVersion+${loader.name.lowercase()}") + modImplementation("dev.nyon:KotlinLangForge:1.2.0-k${libs.versions.kotlin.orNull}-$mcVersion+${loader.name.lowercase()}") } modImplementation(libs.konfig) diff --git a/changelog.md b/changelog.md index bafac1f..ac80013 100644 --- a/changelog.md +++ b/changelog.md @@ -1,2 +1,2 @@ -- fix mod metadata resource insertion -- make yacl optional from now on \ No newline at end of file +- require yacl again +- add support for 1.21.3 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 59b4d7d..d10f54b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ kotlin = "2.0.21" mod-publish = "0.5.+" architectury-loom = "1.7-SNAPSHOT" -fabric-loader = "0.16.7" +fabric-loader = "0.16.9" fabric-language-kotlin = "1.12.3+kotlin." vineflower = "1.10.1" konfig = "2.0.2-1.20.4" diff --git a/settings.gradle.kts b/settings.gradle.kts index f21515b..588c76d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,6 +39,8 @@ extensions.configure { vers("1.20.6-fabric", "1.20.6") vers("1.21-neoforge", "1.21") vers("1.21-fabric", "1.21") + vers("1.21.3-neoforge", "1.21.3") + vers("1.21.3-fabric", "1.21.3") vcsVersion = "1.21-fabric" } create(rootProject) diff --git a/src/main/java/dev/nyon/bbm/asm/AbstractBoatMixin.java b/src/main/java/dev/nyon/bbm/asm/AbstractBoatMixin.java new file mode 100644 index 0000000..44dddc1 --- /dev/null +++ b/src/main/java/dev/nyon/bbm/asm/AbstractBoatMixin.java @@ -0,0 +1,153 @@ +package dev.nyon.bbm.asm; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import dev.nyon.bbm.BbmBoat; +import dev.nyon.bbm.config.Config; +import dev.nyon.bbm.config.ConfigKt; +import net.minecraft.core.BlockPos; +import net.minecraft.tags.BlockTags; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.player.Player; +//? if >=1.21.3 +/*import net.minecraft.world.entity.vehicle.AbstractBoat;*/ +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings("AddedMixinMembersNamePattern") +@Pseudo +@Mixin(targets = "net.minecraft.world.entity.vehicle.AbstractBoat") +public class AbstractBoatMixin implements BbmBoat { + + @Unique + private boolean jumpCollision = false; + + @Override + public void setJumpCollision(boolean b) { + jumpCollision = b; + } + + @Override + public boolean getJumpCollision() { + return jumpCollision; + } + + /*? if >=1.21.3 {*/ + /*@Shadow + private AbstractBoat.Status status; + @Unique + private AbstractBoat instance = (AbstractBoat) (Object) this; + + @SuppressWarnings("resource") + @Unique + private List getCarryingBlocks() { + List states = new ArrayList<>(); + + AABB aABB = this.instance.getBoundingBox(); + AABB aABB2 = new AABB(aABB.minX, aABB.minY - 0.001, aABB.minZ, aABB.maxX, aABB.minY, aABB.maxZ); + int i = Mth.floor(aABB2.minX) - 1; + int j = Mth.ceil(aABB2.maxX) + 1; + int k = Mth.floor(aABB2.minY) - 1; + int l = Mth.ceil(aABB2.maxY) + 1; + int m = Mth.floor(aABB2.minZ) - 1; + int n = Mth.ceil(aABB2.maxZ) + 1; + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + + for (int p = i; p < j; p++) { + for (int q = m; q < n; q++) { + int r = (p != i && p != j - 1 ? 0 : 1) + (q != m && q != n - 1 ? 0 : 1); + if (r != 2) { + for (int s = k; s < l; s++) { + if (r <= 0 || s != k && s != l - 1) { + mutableBlockPos.set(p, s, q); + BlockState blockState = instance.level().getBlockState(mutableBlockPos); + states.add(blockState); + } + } + } + } + } + + return states; + } + + @ModifyExpressionValue( + method = "floatBoat", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/vehicle/AbstractBoat;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;", + ordinal = 1 + ) + ) + private Vec3 changeMovement(Vec3 original) { + if (failsPlayerCondition()) return original; + + switch (status) { + case ON_LAND -> { + if (!ConfigKt.getActiveConfig() + .getBoostOnBlocks() && !ConfigKt.getActiveConfig() + .getBoostOnIce()) return original; + if (ConfigKt.getActiveConfig() + .getBoostOnIce()) { + List carryingBlocks = getCarryingBlocks(); + if (carryingBlocks.stream() + .noneMatch(state -> state.is(BlockTags.ICE))) return original; + } + if (!jumpCollision && !instance.horizontalCollision) return original; + } + case IN_WATER -> { + if (!ConfigKt.getActiveConfig() + .getBoostOnWater()) return original; + if (!jumpCollision && !instance.horizontalCollision) return original; + } + case UNDER_WATER, UNDER_FLOWING_WATER -> { + if (!ConfigKt.getActiveConfig() + .getBoostUnderwater()) return original; + } + case IN_AIR -> { + return original; + } + } + + return new Vec3( + original.x, + ConfigKt.getActiveConfig() + .getStepHeight(), + original.z + ); + } + + @ModifyConstant( + method = "tick", + constant = @Constant( + floatValue = 60.0F, + ordinal = 0 + ) + ) + private float changeEjectTime(float constant) { + Config config = ConfigKt.getActiveConfig(); + if (config == null) return constant; + return config.getPlayerEjectTicks(); + } + + @Unique + private boolean failsPlayerCondition() { + Config config = ConfigKt.getActiveConfig(); + if (config == null) return true; + + if (!config.getOnlyForPlayers()) return false; + return instance.getPassengers().stream() + .noneMatch(entity -> entity instanceof Player); + } + *//*?}*/ +} diff --git a/src/main/java/dev/nyon/bbm/asm/BoatMixin.java b/src/main/java/dev/nyon/bbm/asm/BoatMixin.java index f500991..5dd5393 100644 --- a/src/main/java/dev/nyon/bbm/asm/BoatMixin.java +++ b/src/main/java/dev/nyon/bbm/asm/BoatMixin.java @@ -28,12 +28,6 @@ @SuppressWarnings("AddedMixinMembersNamePattern") @Mixin(Boat.class) abstract class BoatMixin extends Entity implements BbmBoat { - @Shadow - private Boat.Status status; - - @Unique - private boolean jumpCollision = false; - public BoatMixin( EntityType entityType, Level level @@ -41,6 +35,23 @@ public BoatMixin( super(entityType, level); } + @Unique + private boolean jumpCollision = false; + + @Override + public void setJumpCollision(boolean b) { + jumpCollision = b; + } + + @Override + public boolean getJumpCollision() { + return jumpCollision; + } + + /*? if <1.21.3 {*/ + @Shadow + private Boat.Status status; + @Unique private Level bbm$getLevel() { //? if >1.19.4 @@ -152,14 +163,5 @@ private boolean failsPlayerCondition() { return getPassengers().stream() .noneMatch(entity -> entity instanceof Player); } - - @Override - public void setJumpCollision(boolean b) { - jumpCollision = b; - } - - @Override - public boolean getJumpCollision() { - return jumpCollision; - } + /*?}*/ } diff --git a/src/main/java/dev/nyon/bbm/asm/EntityMixin.java b/src/main/java/dev/nyon/bbm/asm/EntityMixin.java index 9e1a5c6..5cbcc7a 100644 --- a/src/main/java/dev/nyon/bbm/asm/EntityMixin.java +++ b/src/main/java/dev/nyon/bbm/asm/EntityMixin.java @@ -7,6 +7,8 @@ import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; +//? if >=1.21.3 +/*import net.minecraft.world.entity.vehicle.AbstractBoat;*/ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; @@ -48,7 +50,7 @@ private AABB changeBoatBox( List shapes ) { if (!expandCollision) return box; - if (!(entity instanceof Boat boat)) return box; + if (!(entity instanceof /*? if >=1.21.3 {*/ /*AbstractBoat boat *//*?} else {*/ Boat boat /*?}*/)) return box; Config config = ConfigKt.getActiveConfig(); if (config == null) return box; @@ -73,7 +75,7 @@ private Vec3 setBoatCollision(Vec3 movement) { Config config = ConfigKt.getActiveConfig(); if (config == null) return original; if (config.getExtraCollisionDetectionRange() == 0.0) return original; - if (!(instance instanceof Boat boat && instance instanceof BbmBoat bbmBoat)) return original; + if (!(instance instanceof /*? if >=1.21.3 {*/ /*AbstractBoat boat *//*?} else {*/ Boat boat /*?}*/ && instance instanceof BbmBoat bbmBoat)) return original; if (!boat.hasControllingPassenger()) return original; expandCollision = true; diff --git a/src/main/resources/bbm.mixins.json b/src/main/resources/bbm.mixins.json index 97d8b7d..eaa4867 100644 --- a/src/main/resources/bbm.mixins.json +++ b/src/main/resources/bbm.mixins.json @@ -1,16 +1,17 @@ { - "required": true, - "minVersion": "0.8", - "package": "dev.nyon.bbm.asm", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "BoatMixin", - "EntityMixin" - ], - "client": [ - "MinecraftMixin" - ], - "injectors": { - "defaultRequire": 1 + "required": true, + "minVersion": "0.8", + "package": "dev.nyon.bbm.asm", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "AbstractBoatMixin", + "BoatMixin", + "EntityMixin" + ], + "client": [ + "MinecraftMixin" + ], + "injectors": { + "defaultRequire": 1 } } diff --git a/versions/1.21.3-fabric/gradle.properties b/versions/1.21.3-fabric/gradle.properties new file mode 100644 index 0000000..3d61cb0 --- /dev/null +++ b/versions/1.21.3-fabric/gradle.properties @@ -0,0 +1,10 @@ +vers.mcVersion=1.21.3 +vers.mcVersionRange=>=1.21.2 +vers.supportedMcVersions=1.21.2,1.21.3 + +vers.deps.quiltmappings=1.21.3+build.6 +vers.deps.fapi=0.109.0+1.21.3 +vers.deps.yacl=3.6.1+1.21.2-fabric +vers.deps.modMenu=12.0.0-beta.1 + +loom.platform=fabric \ No newline at end of file diff --git a/versions/1.21.3-neoforge/gradle.properties b/versions/1.21.3-neoforge/gradle.properties new file mode 100644 index 0000000..02a64ee --- /dev/null +++ b/versions/1.21.3-neoforge/gradle.properties @@ -0,0 +1,8 @@ +vers.mcVersion=1.21.3 +vers.mcVersionRange=>=1.21.2 +vers.supportedMcVersions=1.21.2,1.21.3 + +vers.deps.quiltmappings=1.21.3+build.6 +vers.deps.fml=21.3.30-beta + +loom.platform=neoforge \ No newline at end of file