From 6f49b5d89995f2afe9386e08582df92993371d78 Mon Sep 17 00:00:00 2001 From: F53 Date: Wed, 8 May 2024 16:35:33 -0600 Subject: [PATCH] Update to 1.20.6 Closes #48 --- .github/workflows/build.yml | 2 +- build.gradle | 2 +- gradle.properties | 16 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../mixin/Client/TransparentArmor.java | 4 +- .../HorseBuff/mixin/Server/BreakSpeed.java | 26 ------- .../mixin/Server/MountedModifiers.java | 69 +++++++++++++++++++ .../HorseBuff/mixin/Server/StepHeight.java | 19 ----- src/main/resources/fabric.mod.json | 4 +- src/main/resources/horsebuff.mixins.json | 3 +- 10 files changed, 86 insertions(+), 61 deletions(-) delete mode 100644 src/main/java/net/F53/HorseBuff/mixin/Server/BreakSpeed.java create mode 100644 src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.java delete mode 100644 src/main/java/net/F53/HorseBuff/mixin/Server/StepHeight.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 036baf1..b5e6673 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'adopt' - java-version: 17 + java-version: 21 - name: make gradle wrapper executable run: chmod +x ./gradlew - name: build diff --git a/build.gradle b/build.gradle index a9a5c9a..7e2dce6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.4-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index 01c2b4a..482b749 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,17 +4,17 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop/ -minecraft_version=1.20.2 -yarn_mappings=1.20.2+build.4 -loader_version=0.15.0 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.1 +loader_version=0.15.11 # Mod Properties -mod_version = 2.1.3 +mod_version = 2.1.4 maven_group = com.HorseBuff archives_base_name = HorseBuff # Dependencies -fabric_version=0.91.1+1.20.2 -cloth_config_version=12.0.111 -mod_menu_version=8.0.0 -mixinextras_version=0.2.0 \ No newline at end of file +fabric_version=0.98.0+1.20.6 +cloth_config_version=14.0.126 +mod_menu_version=10.0.0-beta.1 +mixinextras_version=0.3.5 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a595206..48c0a02 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentArmor.java b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentArmor.java index ef2740f..2604d0e 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentArmor.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentArmor.java @@ -10,6 +10,7 @@ import net.minecraft.entity.passive.HorseEntity; import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -18,12 +19,13 @@ @Mixin(value = HorseArmorFeatureRenderer.class, priority = 960) public class TransparentArmor { + @Unique private float opacity; @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/passive/HorseEntity;FFFFFF)V", at = @At("HEAD")) void fetchOpacity(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, HorseEntity horseEntity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch, CallbackInfo ci) { - if (horseEntity.hasArmorInSlot() && ModConfig.getInstance().pitchFade.enabled && horseEntity.hasPassenger(MinecraftClient.getInstance().player)) { + if (horseEntity.isWearingBodyArmor() && ModConfig.getInstance().pitchFade.enabled && horseEntity.hasPassenger(MinecraftClient.getInstance().player)) { ClientPlayerEntity player = MinecraftClient.getInstance().player; assert player != null; opacity = getOpacity(player); diff --git a/src/main/java/net/F53/HorseBuff/mixin/Server/BreakSpeed.java b/src/main/java/net/F53/HorseBuff/mixin/Server/BreakSpeed.java deleted file mode 100644 index c1e81d6..0000000 --- a/src/main/java/net/F53/HorseBuff/mixin/Server/BreakSpeed.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.F53.HorseBuff.mixin.Server; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import net.F53.HorseBuff.config.ModConfig; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.passive.AbstractHorseEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -// Disable breakspeed debuff for not being grounded (while on horseback) -@Mixin(value = PlayerEntity.class, priority = 960) -public abstract class BreakSpeed extends LivingEntity { - protected BreakSpeed(EntityType entityType, World world) { - super(entityType, world); - } - - @ModifyReturnValue(method = "getBlockBreakingSpeed", at = @At("RETURN")) - private float horseBreakSpeed(float original) { - if (!this.isOnGround() && this.getRootVehicle() instanceof AbstractHorseEntity && ModConfig.getInstance().breakSpeed) - return original * 5f; - return original; - } -} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.java b/src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.java new file mode 100644 index 0000000..8d27199 --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.java @@ -0,0 +1,69 @@ +package net.F53.HorseBuff.mixin.Server; + +import net.F53.HorseBuff.config.ModConfig; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.attribute.EntityAttributeInstance; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.attribute.EntityAttributes; +import net.minecraft.entity.passive.AbstractHorseEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +// adds DataPack attribute modifiers to player & horse while mounted to +// - increase horse's StepHeight by 10% (when enabled) +// - remove BreakSpeed debuff from not being grounded (when enabled) +@Mixin(value = PlayerEntity.class, priority = 960) +public abstract class MountedModifiers extends LivingEntity { + protected MountedModifiers(EntityType entityType, World world) { + super(entityType, world); + } + + @Unique + EntityAttributeModifier mountedStepHeight = new EntityAttributeModifier("HorseBuff-MountedStepHeight", 0.1, EntityAttributeModifier.Operation.ADD_VALUE); + @Unique + EntityAttributeModifier mountedBreakSpeed = new EntityAttributeModifier("HorseBuff-MountedBreakSpeed", 5, EntityAttributeModifier.Operation.ADD_MULTIPLIED_BASE); + + @Unique + public boolean startRiding(Entity entity, boolean force) { + boolean result = super.startRiding(entity, force); + if (!(super.getWorld() instanceof ServerWorld && entity instanceof AbstractHorseEntity horse)) + return result; + + if (ModConfig.getInstance().stepHeight) { + EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT); + if (stepHeight != null) stepHeight.addTemporaryModifier(mountedStepHeight); + } + + if (ModConfig.getInstance().breakSpeed) { + EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED); + if (breakSpeed != null) breakSpeed.addTemporaryModifier(mountedBreakSpeed); + } + return result; + } + + @Unique + public boolean startRiding(Entity entity) { + return this.startRiding(entity, false); + } + + @Unique + public void stopRiding() { + if (!(super.getWorld() instanceof ServerWorld && getVehicle() instanceof AbstractHorseEntity horse)) { + super.stopRiding(); + return; + } + + EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT); + if (stepHeight != null) stepHeight.removeModifier(mountedStepHeight); + + EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED); + if (breakSpeed != null) breakSpeed.removeModifier(mountedBreakSpeed); + + super.stopRiding(); + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Server/StepHeight.java b/src/main/java/net/F53/HorseBuff/mixin/Server/StepHeight.java deleted file mode 100644 index f050697..0000000 --- a/src/main/java/net/F53/HorseBuff/mixin/Server/StepHeight.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.F53.HorseBuff.mixin.Server; - -import net.F53.HorseBuff.config.ModConfig; -import net.minecraft.entity.passive.AbstractHorseEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; - -// Increases step-height for horses by 10%, allowing you to ride up a path to a full block\ -// video displaying issue this fixes: https://user-images.githubusercontent.com/37855219/167529335-bea46c66-4ee2-4e3f-9391-f8cf2960d58a.mp4 -@Mixin(value = AbstractHorseEntity.class, priority = 960) -public class StepHeight { - @ModifyConstant(method = "(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V", constant = @Constant(floatValue = 1.0f)) - private float horseHigherStepHeight(float value) { - if (ModConfig.getInstance().stepHeight) - return 1.1f; - return value; - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ffdaf9d..64d39b1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,8 +29,8 @@ ], "depends": { - "fabricloader": ">=0.14.23", - "minecraft": ">=1.20.2", + "fabricloader": ">=0.15.11", + "minecraft": ">=1.20.6", "java": ">=17" } } diff --git a/src/main/resources/horsebuff.mixins.json b/src/main/resources/horsebuff.mixins.json index 05dc5a5..dfcc224 100644 --- a/src/main/resources/horsebuff.mixins.json +++ b/src/main/resources/horsebuff.mixins.json @@ -7,12 +7,11 @@ "PortalHorse.AllowPortalUse", "PortalHorse.OnCollideEnd", "PortalHorse.TickNether", - "Server.BreakSpeed", "Server.ClearFutureTickEvents", "Server.MovementCheck", "Server.NoBuck", "Server.NoWander", - "Server.StepHeight" + "Server.MountedModifiers" ], "client": [ "Client.HeadPitchOffset",