From 46a44b911c8a37aa67dd518c4fe691adbd36698b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Bj=C3=B8rnstad?= Date: Thu, 26 Dec 2024 21:50:51 +0100 Subject: [PATCH 1/2] Port to 1.21.3 * Bumped version to 2.2.0 * Extended the EntityRenderState for rideable entities with id and flag for playerPassenger * Extended the EntityModel for rideable and equippable models with flag for playerPassenger * Prefixed Unique methods and fields with horsebuff modid * Replaced accesswidener with Shadow fields and used Identifier.of instead of constructor * Removed portalPatch config * Removed portalPatch, fairBreeds from lang-files * Updated mixin extras to 0.4.1 * Updated from java 17 to java 21 in gradle build * Updated gradle wrapper to 8.11 * Updated build github action * Updated README with more precise descriptions --- .github/workflows/build.yml | 10 +- README.md | 8 +- build.gradle | 12 +- gradle.properties | 16 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../net/F53/HorseBuff/config/ModConfig.java | 167 +++++++++--------- .../mixin/Client/HeadPitchOffset.java | 22 +-- .../HorseArmorFeatureRendererMixin.java | 25 +++ .../HorseBuff/mixin/Client/HorseRenderer.java | 55 ------ .../mixin/Client/InventoryAccessor.java | 12 +- .../mixin/Client/JebHorseTintable.java | 52 +++--- .../Client/LivingEntityRendererMixin.java | 77 ++++++++ .../LlamaDecorFeatureRendererMixin.java | 26 +++ .../RideableEntityRenderStateMixin.java | 41 +++++ .../RideableEquippableEntityModelMixin.java | 25 +++ .../net/F53/HorseBuff/mixin/Client/Swim.java | 13 +- .../mixin/Client/TransparentArmor.java | 35 ---- .../mixin/Client/TransparentEquipment.java | 43 +++++ ...ngs.java => TransparentHorseMarkings.java} | 20 ++- .../mixin/Client/TransparentLlamaDecor.java | 36 ---- .../F53/HorseBuff/mixin/Server/AllowRaft.java | 14 +- .../mixin/Server/MountedModifiers.java | 21 +-- .../HorseBuff/mixin/Server/MovementCheck.java | 3 +- .../F53/HorseBuff/mixin/Server/NoBuck.java | 57 +++--- .../F53/HorseBuff/mixin/Server/NoWander.java | 5 +- ...ExtendedRideableEquippableEntityModel.java | 6 + .../ExtendedRideableEntityRenderState.java | 8 + .../net/F53/HorseBuff/utils/RenderUtils.java | 59 ++++--- .../assets/horsebuff/lang/en_us.json | 6 - .../assets/horsebuff/lang/es_mx.json | 6 - .../assets/horsebuff/lang/ru_ru.json | 6 - src/main/resources/fabric.mod.json | 5 +- src/main/resources/horsebuff.accesswidener | 5 - src/main/resources/horsebuff.mixins.json | 13 +- 34 files changed, 521 insertions(+), 390 deletions(-) create mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/HorseArmorFeatureRendererMixin.java delete mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/HorseRenderer.java create mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/LivingEntityRendererMixin.java create mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/LlamaDecorFeatureRendererMixin.java create mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/RideableEntityRenderStateMixin.java create mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/RideableEquippableEntityModelMixin.java delete mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/TransparentArmor.java create mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/TransparentEquipment.java rename src/main/java/net/F53/HorseBuff/mixin/Client/{TransparentMarkings.java => TransparentHorseMarkings.java} (68%) delete mode 100644 src/main/java/net/F53/HorseBuff/mixin/Client/TransparentLlamaDecor.java create mode 100644 src/main/java/net/F53/HorseBuff/render/entity/model/ExtendedRideableEquippableEntityModel.java create mode 100644 src/main/java/net/F53/HorseBuff/render/entity/state/ExtendedRideableEntityRenderState.java delete mode 100644 src/main/resources/horsebuff.accesswidener diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5e6673..eba985c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,15 +5,15 @@ jobs: build: strategy: matrix: - os: [ubuntu-20.04] + os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - name: checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: validate gradle wrapper uses: gradle/wrapper-validation-action@v1 - - name: setup jdk ${{ matrix.java }} - uses: actions/setup-java@v3 + - name: setup jdk + uses: actions/setup-java@v4 with: distribution: 'adopt' java-version: 21 @@ -22,7 +22,7 @@ jobs: - name: build run: ./gradlew build - name: capture build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Artifacts path: build/libs/ diff --git a/README.md b/README.md index 9ee7fbc..faa777f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Improve horses by removing stupid stuff and adding useful stuff.
Horses Sit in Rafts - Rafts only because its impossible to break boats when they are in a boat. + Rafts only because its impossible to break boats when they are in a boat. Works with horses, donkeys, mules, zombie horses, skeleton horses, camels and llamas. ![player sitting in a bamboo raft in a river with a horse](https://cdn.modrinth.com/data/cached_images/d2faef4b56e873ee8a20816b5276e52aa1b20bbc.png)
@@ -71,6 +71,8 @@ Improve horses by removing stupid stuff and adding useful stuff.
Fade Horse as you look down + The same applies to donkeys, mules, zombie horses, skeleton horses, camels and llamas. + ![going down a hill into a cave, looking down through horse for better navigation](https://i.imgur.com/kwtmFVd.gif)
@@ -78,6 +80,7 @@ Improve horses by removing stupid stuff and adding useful stuff. Horse Head Pitch offset Option to lower horse's head down up to 45 degrees to improve visibility. + Works with horses, donkeys, mules, zombie horses and skeleton horses. ![comparison of 0 vs 45 degree offset](https://user-images.githubusercontent.com/37855219/163890939-87f3b255-176a-49df-ad4d-ec5b41a3b54a.png) @@ -85,7 +88,10 @@ Improve horses by removing stupid stuff and adding useful stuff.
Horses named `jeb_` become rainbow + The same can be applied to donkeys, mules, camels, llamas, zombie horses and skeleton horses. + ![Jeb_ rainbow horse, like the sheep easter egg](https://i.imgur.com/QTk8w33.gif) +
diff --git a/build.gradle b/build.gradle index 1ca9818..530a4dc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,15 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.9-SNAPSHOT' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 archivesBaseName = project.archives_base_name + "-" + project.minecraft_version version = project.mod_version group = project.maven_group -loom { - accessWidenerPath = file("src/main/resources/horsebuff.accesswidener") -} - configurations { modIncludeImplementation @@ -66,7 +62,7 @@ tasks.withType(JavaCompile).configureEach { // If Javadoc is generated, this must be specified in that task too. it.options.encoding = "UTF-8" - it.options.release = 17 + it.options.release = 21 } java { // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task diff --git a/gradle.properties b/gradle.properties index bdf1f8d..8b5388c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop/ -minecraft_version=1.21 -yarn_mappings=1.21+build.2 -loader_version=0.15.11 +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 +loader_version=0.16.9 # Mod Properties -mod_version=2.1.8 +mod_version=2.2.0 maven_group=com.HorseBuff archives_base_name=HorseBuff # Dependencies -fabric_version=0.100.3+1.21 -cloth_config_version=15.0.127 -mod_menu_version=11.0.1 -mixinextras_version=0.3.5 \ No newline at end of file +fabric_version=0.112.1+1.21.3 +cloth_config_version=16.0.143 +mod_menu_version=12.0.0 +mixinextras_version=0.4.1 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48c0a02..e48eca5 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.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/net/F53/HorseBuff/config/ModConfig.java b/src/main/java/net/F53/HorseBuff/config/ModConfig.java index 4016336..2af96b6 100644 --- a/src/main/java/net/F53/HorseBuff/config/ModConfig.java +++ b/src/main/java/net/F53/HorseBuff/config/ModConfig.java @@ -1,85 +1,82 @@ -package net.F53.HorseBuff.config; - -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer; -import me.shedaniel.autoconfig.ConfigData; -import me.shedaniel.autoconfig.annotation.*; - - -@SuppressWarnings("CanBeFinal") -@Config(name = "HorseBuff") -public class ModConfig implements ConfigData{ - @ConfigEntry.Category("Server") - @ConfigEntry.Gui.Tooltip - public boolean noWander = true; - - @ConfigEntry.Category("Server") - @ConfigEntry.Gui.Tooltip - public boolean portalPatch = true; - - @ConfigEntry.Category("Server") - @ConfigEntry.Gui.Tooltip - public boolean rubberBand = true; - - @ConfigEntry.Category("Server") - @ConfigEntry.Gui.Tooltip - public boolean breakSpeed = true; - - @ConfigEntry.Category("Server") - @ConfigEntry.Gui.Tooltip - public boolean stepHeight = true; - - @ConfigEntry.Category("Client") - @ConfigEntry.Gui.Tooltip - public boolean noBuck = true; - - @ConfigEntry.Category("Client") - @ConfigEntry.Gui.Tooltip - public boolean swimHorse = true; - - @ConfigEntry.Category("Client") - @ConfigEntry.Gui.Tooltip - public boolean swimCamel = false; - - @ConfigEntry.Category("Client") - @ConfigEntry.Gui.Tooltip - public boolean swimDead = false; - - @ConfigEntry.Category("Client") - @ConfigEntry.Gui.Tooltip - @ConfigEntry.Gui.CollapsibleObject - public FadeConfig pitchFade = new FadeConfig(); - - public static class FadeConfig { - public boolean enabled = true; - - @ConfigEntry.Gui.Tooltip - @ConfigEntry.BoundedDiscrete(min = 0, max = 90) - public int startAngle = 30; - - @ConfigEntry.Gui.Tooltip - @ConfigEntry.BoundedDiscrete(min = 0, max = 90) - public int endAngle = 50; - - @ConfigEntry.Gui.Tooltip - @ConfigEntry.BoundedDiscrete(min = 50, max = 100) - public int maxTransparency = 90; - } - - @ConfigEntry.Category("Client") - @ConfigEntry.Gui.Tooltip - @ConfigEntry.BoundedDiscrete(min = 0, max = 45) - public int horseHeadAngleOffset = 0; - - @ConfigEntry.Category("Client") - @ConfigEntry.Gui.Tooltip - public boolean jeb_Horses = true; - - public static void init() { - AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new); - } - - public static ModConfig getInstance() { - return AutoConfig.getConfigHolder(ModConfig.class).getConfig(); - } -} +package net.F53.HorseBuff.config; + +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.ConfigData; +import me.shedaniel.autoconfig.annotation.Config; +import me.shedaniel.autoconfig.annotation.ConfigEntry; +import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer; + + +@SuppressWarnings("CanBeFinal") +@Config(name = "HorseBuff") +public class ModConfig implements ConfigData{ + @ConfigEntry.Category("Server") + @ConfigEntry.Gui.Tooltip + public boolean noWander = true; + + @ConfigEntry.Category("Server") + @ConfigEntry.Gui.Tooltip + public boolean rubberBand = true; + + @ConfigEntry.Category("Server") + @ConfigEntry.Gui.Tooltip + public boolean breakSpeed = true; + + @ConfigEntry.Category("Server") + @ConfigEntry.Gui.Tooltip + public boolean stepHeight = true; + + @ConfigEntry.Category("Client") + @ConfigEntry.Gui.Tooltip + public boolean noBuck = true; + + @ConfigEntry.Category("Client") + @ConfigEntry.Gui.Tooltip + public boolean swimHorse = true; + + @ConfigEntry.Category("Client") + @ConfigEntry.Gui.Tooltip + public boolean swimCamel = false; + + @ConfigEntry.Category("Client") + @ConfigEntry.Gui.Tooltip + public boolean swimDead = false; + + @ConfigEntry.Category("Client") + @ConfigEntry.Gui.Tooltip + @ConfigEntry.Gui.CollapsibleObject + public FadeConfig pitchFade = new FadeConfig(); + + public static class FadeConfig { + public boolean enabled = true; + + @ConfigEntry.Gui.Tooltip + @ConfigEntry.BoundedDiscrete(min = 0, max = 90) + public int startAngle = 30; + + @ConfigEntry.Gui.Tooltip + @ConfigEntry.BoundedDiscrete(min = 0, max = 90) + public int endAngle = 50; + + @ConfigEntry.Gui.Tooltip + @ConfigEntry.BoundedDiscrete(min = 50, max = 100) + public int maxTransparency = 90; + } + + @ConfigEntry.Category("Client") + @ConfigEntry.Gui.Tooltip + @ConfigEntry.BoundedDiscrete(min = 0, max = 45) + public int horseHeadAngleOffset = 0; + + @ConfigEntry.Category("Client") + @ConfigEntry.Gui.Tooltip + public boolean jeb_Horses = true; + + public static void init() { + AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new); + } + + public static ModConfig getInstance() { + return AutoConfig.getConfigHolder(ModConfig.class).getConfig(); + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/HeadPitchOffset.java b/src/main/java/net/F53/HorseBuff/mixin/Client/HeadPitchOffset.java index 71951b3..ee75725 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/HeadPitchOffset.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/HeadPitchOffset.java @@ -1,12 +1,11 @@ package net.F53.HorseBuff.mixin.Client; import net.F53.HorseBuff.config.ModConfig; +import net.F53.HorseBuff.render.entity.state.ExtendedRideableEntityRenderState; import net.minecraft.client.MinecraftClient; import net.minecraft.client.model.ModelPart; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.client.render.entity.model.HorseEntityModel; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.passive.AbstractHorseEntity; +import net.minecraft.client.render.entity.model.AbstractHorseEntityModel; +import net.minecraft.client.render.entity.state.LivingHorseEntityRenderState; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -14,15 +13,18 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +@Mixin(value = AbstractHorseEntityModel.class, priority = 960) +public abstract class HeadPitchOffset { -@Mixin(value = HorseEntityModel.class, priority = 960) -public class HeadPitchOffset> { @Shadow @Final protected ModelPart head; // Thanks dorianpb#9929 for the tip on where to mixin - @Inject(method = "setAngles(Lnet/minecraft/entity/passive/AbstractHorseEntity;FFFFF)V", at = @At("TAIL")) - void headPitch(AbstractHorseEntity horseBaseEntity, float f, float g, float h, float i, float j, CallbackInfo ci){ - if (horseBaseEntity.hasPassenger(MinecraftClient.getInstance().player) && MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) - this.head.pitch = Math.min(this.head.pitch + ModConfig.getInstance().horseHeadAngleOffset/100f, 1.5f); + @Inject(method = "setAngles(Lnet/minecraft/client/render/entity/state/LivingHorseEntityRenderState;)V", at = @At("TAIL")) + void headPitch(LivingHorseEntityRenderState livingHorseEntityRenderState, CallbackInfo ci) { + if (livingHorseEntityRenderState instanceof ExtendedRideableEntityRenderState extendedRideableEntityRenderState) { + if (extendedRideableEntityRenderState.horsebuff$isPlayerPassenger() && MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) { + this.head.pitch = Math.min(this.head.pitch + ModConfig.getInstance().horseHeadAngleOffset / 100f, 1.5f); + } + } } } diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/HorseArmorFeatureRendererMixin.java b/src/main/java/net/F53/HorseBuff/mixin/Client/HorseArmorFeatureRendererMixin.java new file mode 100644 index 0000000..a39e31b --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/HorseArmorFeatureRendererMixin.java @@ -0,0 +1,25 @@ +package net.F53.HorseBuff.mixin.Client; + +import com.llamalad7.mixinextras.sugar.Local; +import net.F53.HorseBuff.render.entity.model.ExtendedRideableEquippableEntityModel; +import net.F53.HorseBuff.render.entity.state.ExtendedRideableEntityRenderState; +import net.minecraft.client.render.entity.feature.HorseArmorFeatureRenderer; +import net.minecraft.client.render.entity.model.HorseEntityModel; +import net.minecraft.client.render.entity.state.HorseEntityRenderState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(HorseArmorFeatureRenderer.class) +public abstract class HorseArmorFeatureRendererMixin { + + @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/HorseEntityRenderState;FF)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/HorseEntityModel;setAngles(Lnet/minecraft/client/render/entity/state/LivingHorseEntityRenderState;)V", shift = At.Shift.AFTER)) + void updatePlayerPassenger(CallbackInfo callbackInfo, @Local(argsOnly = true) HorseEntityRenderState horseEntityRenderState, @Local HorseEntityModel horseEntityModel) { + if(horseEntityRenderState instanceof ExtendedRideableEntityRenderState extendedRideableEntityRenderState) { + boolean isPlayerPassenger = extendedRideableEntityRenderState.horsebuff$isPlayerPassenger(); + ((ExtendedRideableEquippableEntityModel) horseEntityModel).horsebuff$setPlayerPassenger(isPlayerPassenger); + } + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/HorseRenderer.java b/src/main/java/net/F53/HorseBuff/mixin/Client/HorseRenderer.java deleted file mode 100644 index 10a1275..0000000 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/HorseRenderer.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.F53.HorseBuff.mixin.Client; - -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.Share; -import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; -import net.F53.HorseBuff.utils.RenderUtils; -import net.minecraft.client.render.entity.LivingEntityRenderer; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.passive.AbstractHorseEntity; -import net.minecraft.entity.passive.SheepEntity; -import net.minecraft.util.DyeColor; -import net.minecraft.util.math.ColorHelper.Argb; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(value = LivingEntityRenderer.class, priority = 960) -public abstract class HorseRenderer { - @Inject(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) - void getAlpha(CallbackInfo ci, @Local(argsOnly = true) LivingEntity entity, @Share("alpha") LocalIntRef alpha) { - if (entity instanceof AbstractHorseEntity) - alpha.set(RenderUtils.getAlpha(entity)); - } - - @ModifyArg(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V"), - index = 4) - int setOpacityAndChromaForRender(int color, @Local(argsOnly = true, ordinal = 1) float tickDelta, @Local(argsOnly = true) LivingEntity entity, @Share("alpha") LocalIntRef alpha) { - if (!(entity instanceof AbstractHorseEntity)) return color; - if (RenderUtils.isJeb(entity)) { - // see net/minecraft/client/render/entity/feature/SheepWoolFeatureRenderer - int dyeIndex = entity.age / 25 + entity.getId(); - int numDyes = DyeColor.values().length; - int currentDye = SheepEntity.getRgbColor(DyeColor.byId(dyeIndex % numDyes)); - int nextDye = SheepEntity.getRgbColor(DyeColor.byId((dyeIndex + 1) % numDyes)); - float dyeTransitionProgress = ((float) (entity.age % 25) + tickDelta) / 25.0f; - color = Argb.lerp(dyeTransitionProgress, currentDye, nextDye); - // increase brightness by a bit because the horse texture is a bit dark - color = Argb.getArgb(Math.min(Argb.getRed(color) * 2, 255), Math.min(Argb.getGreen(color) * 2, 255), Math.min(Argb.getBlue(color) * 2, 255)); - } - return Argb.withAlpha(alpha.get(), color); - } - - @ModifyArg(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;getRenderLayer(Lnet/minecraft/entity/LivingEntity;ZZZ)Lnet/minecraft/client/render/RenderLayer;"), - index = 2) - boolean makeRenderLayerTranslucent(boolean translucent, @Local(argsOnly = true) LivingEntity entity, @Share("alpha") LocalIntRef alphaRef) { - if (translucent) return true; - if (entity instanceof AbstractHorseEntity) - return alphaRef.get() != 255; - return false; - } -} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/InventoryAccessor.java b/src/main/java/net/F53/HorseBuff/mixin/Client/InventoryAccessor.java index 02e5340..adb0489 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/InventoryAccessor.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/InventoryAccessor.java @@ -1,5 +1,6 @@ package net.F53.HorseBuff.mixin.Client; +import net.F53.HorseBuff.ClientInit; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.InventoryScreen; @@ -11,24 +12,21 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import net.F53.HorseBuff.ClientInit; @Mixin(value = MinecraftClient.class, priority = 960) public abstract class InventoryAccessor { - @Shadow @Final private TutorialManager tutorialManager; + @Shadow @Final private TutorialManager tutorialManager; @Shadow public abstract void setScreen(@Nullable Screen screen); - @Shadow @Nullable public ClientPlayerEntity player; - @Redirect(method= "handleInputEvents()V", at = @At(value = "INVOKE", target = "net/minecraft/client/network/ClientPlayerEntity.openRidingInventory ()V")) - void playerInventoryAccess(ClientPlayerEntity instance){ + @Redirect(method = "handleInputEvents()V", at = @At(value = "INVOKE", target = "net/minecraft/client/network/ClientPlayerEntity.openRidingInventory ()V")) + void playerInventoryAccess(ClientPlayerEntity instance) { assert this.player != null; if (ClientInit.horsePlayerInventory.isPressed()) { tutorialManager.onInventoryOpened(); setScreen(new InventoryScreen(this.player)); - } - else { + } else { instance.openRidingInventory(); } } diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/JebHorseTintable.java b/src/main/java/net/F53/HorseBuff/mixin/Client/JebHorseTintable.java index 73e375c..08baeaa 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/JebHorseTintable.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/JebHorseTintable.java @@ -1,22 +1,30 @@ -package net.F53.HorseBuff.mixin.Client; - -import net.minecraft.client.render.entity.HorseEntityRenderer; -import net.minecraft.entity.passive.HorseColor; -import net.minecraft.entity.passive.HorseEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import static net.F53.HorseBuff.utils.RenderUtils.isJeb; - -@Mixin(value = HorseEntityRenderer.class, priority = 960) -public class JebHorseTintable { - @Redirect(method = "getTexture(Lnet/minecraft/entity/passive/HorseEntity;)Lnet/minecraft/util/Identifier;", - at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/HorseEntity;getVariant()Lnet/minecraft/entity/passive/HorseColor;")) - HorseColor jebHorseTintable(HorseEntity instance){ - if (isJeb(instance)){ - return HorseColor.WHITE; - } - return instance.getVariant(); - } -} +package net.F53.HorseBuff.mixin.Client; + +import net.minecraft.client.render.entity.HorseEntityRenderer; +import net.minecraft.client.render.entity.state.HorseEntityRenderState; +import net.minecraft.entity.passive.HorseColor; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Map; + +import static net.F53.HorseBuff.utils.RenderUtils.isJeb; + +@Mixin(value = HorseEntityRenderer.class, priority = 960) +public abstract class JebHorseTintable { + + @Final @Shadow private static Map TEXTURES; + + @Redirect(method = "getTexture(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;)Lnet/minecraft/util/Identifier;", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/HorseEntityRenderer;getTexture(Lnet/minecraft/client/render/entity/state/HorseEntityRenderState;)Lnet/minecraft/util/Identifier;")) + Identifier jebHorseTintable(HorseEntityRenderer instance, HorseEntityRenderState horseEntityRenderState) { + if (isJeb(horseEntityRenderState)) { + return TEXTURES.get(HorseColor.WHITE); + } + return TEXTURES.get(horseEntityRenderState.color); + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/LivingEntityRendererMixin.java b/src/main/java/net/F53/HorseBuff/mixin/Client/LivingEntityRendererMixin.java new file mode 100644 index 0000000..53dad81 --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/LivingEntityRendererMixin.java @@ -0,0 +1,77 @@ +package net.F53.HorseBuff.mixin.Client; + +import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; +import net.F53.HorseBuff.render.entity.state.ExtendedRideableEntityRenderState; +import net.F53.HorseBuff.utils.RenderUtils; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.render.entity.state.LivingEntityRenderState; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.passive.SheepEntity; +import net.minecraft.util.DyeColor; +import net.minecraft.util.math.ColorHelper; +import net.minecraft.util.math.MathHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import static net.F53.HorseBuff.utils.RenderUtils.isJeb; +import static net.F53.HorseBuff.utils.RenderUtils.isRideableEntityRenderState; + +@Mixin(value = LivingEntityRenderer.class, priority = 960) +public abstract class LivingEntityRendererMixin { + + @Inject(method = "updateRenderState(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;F)V", + at = @At("TAIL")) + void setPlayerPassenger(CallbackInfo ci, @Local(argsOnly = true) LivingEntityRenderState livingEntityRenderState, @Local(argsOnly = true) LivingEntity livingEntity) { + if (isRideableEntityRenderState(livingEntityRenderState)) { + boolean playerPassenger = livingEntity.hasPassenger(MinecraftClient.getInstance().player); + ((ExtendedRideableEntityRenderState) livingEntityRenderState).horsebuff$setId(livingEntity.getId()); + ((ExtendedRideableEntityRenderState) livingEntityRenderState).horsebuff$setPlayerPassenger(playerPassenger); + } + } + + @Inject(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", + at = @At("HEAD")) + void setAlpha(CallbackInfo ci, @Local(argsOnly = true) LivingEntityRenderState livingEntityRenderState, @Share("alpha") LocalIntRef alpha) { + if (livingEntityRenderState instanceof ExtendedRideableEntityRenderState extendedRideableEntityRenderState) { + alpha.set(RenderUtils.getAlpha(extendedRideableEntityRenderState.horsebuff$isPlayerPassenger())); + } + } + + @ModifyArg(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V"), + index = 4) + int setOpacityAndChromaForRender(int color, @Local(argsOnly = true) LivingEntityRenderState livingEntityRenderState, @Share("alpha") LocalIntRef alpha) { + if (isRideableEntityRenderState(livingEntityRenderState)) { + if (isJeb(livingEntityRenderState) && livingEntityRenderState instanceof ExtendedRideableEntityRenderState extendedRideableEntityRenderState) { + // see net/minecraft/client/render/entity/feature/SheepWoolFeatureRenderer + int dyeIndex = MathHelper.floor(livingEntityRenderState.age) / 25 + extendedRideableEntityRenderState.horsebuff$getId(); + int numDyes = DyeColor.values().length; + int currentDye = SheepEntity.getRgbColor(DyeColor.byId(dyeIndex % numDyes)); + int nextDye = SheepEntity.getRgbColor(DyeColor.byId((dyeIndex + 1) % numDyes)); + float dyeTransitionProgress = ((float) (MathHelper.floor(livingEntityRenderState.age) % 25) + MathHelper.fractionalPart(livingEntityRenderState.age)) / 25.0F; + color = ColorHelper.lerp(dyeTransitionProgress, currentDye, nextDye); + // increase brightness by a bit because the horse texture is a bit dark + color = ColorHelper.getArgb(Math.min(ColorHelper.getRed(color) * 2, 255), Math.min(ColorHelper.getGreen(color) * 2, 255), Math.min(ColorHelper.getBlue(color) * 2, 255)); + } + return ColorHelper.withAlpha(alpha.get(), color); + } else { + return color; + } + } + + @ModifyArg(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;getRenderLayer(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;ZZZ)Lnet/minecraft/client/render/RenderLayer;"), + index = 2) + boolean makeRenderLayerTranslucent(boolean translucent, @Local(argsOnly = true) LivingEntityRenderState livingEntityRenderState, @Share("alpha") LocalIntRef alphaRef) { + if (translucent) return true; + if (isRideableEntityRenderState(livingEntityRenderState)) + return alphaRef.get() != 255; + return false; + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/LlamaDecorFeatureRendererMixin.java b/src/main/java/net/F53/HorseBuff/mixin/Client/LlamaDecorFeatureRendererMixin.java new file mode 100644 index 0000000..5fc4d5d --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/LlamaDecorFeatureRendererMixin.java @@ -0,0 +1,26 @@ +package net.F53.HorseBuff.mixin.Client; + +import com.llamalad7.mixinextras.sugar.Local; +import net.F53.HorseBuff.render.entity.model.ExtendedRideableEquippableEntityModel; +import net.F53.HorseBuff.render.entity.state.ExtendedRideableEntityRenderState; +import net.minecraft.client.render.entity.feature.LlamaDecorFeatureRenderer; +import net.minecraft.client.render.entity.model.LlamaEntityModel; +import net.minecraft.client.render.entity.state.LlamaEntityRenderState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = LlamaDecorFeatureRenderer.class, priority = 960) +public class LlamaDecorFeatureRendererMixin { + + @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/entity/state/LlamaEntityRenderState;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Identifier;I)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/LlamaEntityModel;setAngles(Lnet/minecraft/client/render/entity/state/LlamaEntityRenderState;)V", + shift = At.Shift.AFTER)) + void updatePlayerPassenger(CallbackInfo callbackInfo, @Local(argsOnly = true) LlamaEntityRenderState llamaEntityRenderState, @Local LlamaEntityModel llamaEntityModel) { + if (llamaEntityRenderState instanceof ExtendedRideableEntityRenderState extendedRideableEntityRenderState) { + boolean isPlayerPassenger = extendedRideableEntityRenderState.horsebuff$isPlayerPassenger(); + ((ExtendedRideableEquippableEntityModel) llamaEntityModel).horsebuff$setPlayerPassenger(isPlayerPassenger); + } + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/RideableEntityRenderStateMixin.java b/src/main/java/net/F53/HorseBuff/mixin/Client/RideableEntityRenderStateMixin.java new file mode 100644 index 0000000..33ff29c --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/RideableEntityRenderStateMixin.java @@ -0,0 +1,41 @@ +package net.F53.HorseBuff.mixin.Client; + +import net.F53.HorseBuff.render.entity.state.ExtendedRideableEntityRenderState; +import net.minecraft.client.render.entity.state.CamelEntityRenderState; +import net.minecraft.client.render.entity.state.LivingHorseEntityRenderState; +import net.minecraft.client.render.entity.state.LlamaEntityRenderState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +// Additional fields for: +// horses, donkeys, mules, undead horses, skeleton horses (LivingHorseEntityRenderState) +// llamas and camels +@Mixin(value = {LivingHorseEntityRenderState.class, LlamaEntityRenderState.class, CamelEntityRenderState.class}, priority = 960) +public abstract class RideableEntityRenderStateMixin implements ExtendedRideableEntityRenderState { + + @Unique + private int horsebuff$id; + + @Unique + private boolean horsebuff$playerPassenger; + + @Override + public void horsebuff$setId(int id) { + this.horsebuff$id = id; + } + + @Override + public int horsebuff$getId() { + return this.horsebuff$id; + } + + @Override + public void horsebuff$setPlayerPassenger(boolean playerPassenger) { + this.horsebuff$playerPassenger = playerPassenger; + } + + @Override + public boolean horsebuff$isPlayerPassenger() { + return horsebuff$playerPassenger; + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/RideableEquippableEntityModelMixin.java b/src/main/java/net/F53/HorseBuff/mixin/Client/RideableEquippableEntityModelMixin.java new file mode 100644 index 0000000..8af509b --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/RideableEquippableEntityModelMixin.java @@ -0,0 +1,25 @@ +package net.F53.HorseBuff.mixin.Client; + +import net.F53.HorseBuff.render.entity.model.ExtendedRideableEquippableEntityModel; +import net.minecraft.client.render.entity.model.HorseEntityModel; +import net.minecraft.client.render.entity.model.LlamaEntityModel; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +// Horses can equip armor and llamas can equip carpets +@Mixin(value = {HorseEntityModel.class, LlamaEntityModel.class}, priority = 960) +public abstract class RideableEquippableEntityModelMixin implements ExtendedRideableEquippableEntityModel { + + @Unique + private boolean horsebuff$playerPassenger; + + @Override + public void horsebuff$setPlayerPassenger(boolean playerPassenger) { + this.horsebuff$playerPassenger = playerPassenger; + } + + @Override + public boolean horsebuff$isPlayerPassenger() { + return this.horsebuff$playerPassenger; + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/Swim.java b/src/main/java/net/F53/HorseBuff/mixin/Client/Swim.java index 37319bd..a00b235 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/Swim.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/Swim.java @@ -4,7 +4,11 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.SkeletonHorseEntity; import net.minecraft.entity.mob.ZombieHorseEntity; -import net.minecraft.entity.passive.*; +import net.minecraft.entity.passive.AbstractHorseEntity; +import net.minecraft.entity.passive.CamelEntity; +import net.minecraft.entity.passive.DonkeyEntity; +import net.minecraft.entity.passive.HorseEntity; +import net.minecraft.entity.passive.MuleEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.Vec3d; @@ -15,12 +19,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(value = LivingEntity.class) -public class Swim { +public abstract class Swim { + @Inject(method = "travelControlled", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;travel(Lnet/minecraft/util/math/Vec3d;)V", shift = At.Shift.BEFORE)) private void fakeSwim(PlayerEntity controllingPlayer, Vec3d movementInput, CallbackInfo ci) { if (!((Object)this instanceof AbstractHorseEntity)) {return;} AbstractHorseEntity horseInstance = (AbstractHorseEntity) (Object) this; - if (!hb$shouldSwim(horseInstance)) {return;} + if (!horsebuff$shouldSwim(horseInstance)) {return;} if (horseInstance.getFluidHeight(FluidTags.WATER) > horseInstance.getSwimHeight()) { horseInstance.addVelocity(0, 0.08, 0); @@ -28,7 +33,7 @@ private void fakeSwim(PlayerEntity controllingPlayer, Vec3d movementInput, Callb } @Unique - private boolean hb$shouldSwim(AbstractHorseEntity horseInstance) { + private boolean horsebuff$shouldSwim(AbstractHorseEntity horseInstance) { if (horseInstance instanceof HorseEntity || horseInstance instanceof DonkeyEntity || horseInstance instanceof MuleEntity) { diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentArmor.java b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentArmor.java deleted file mode 100644 index ea0fbf8..0000000 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentArmor.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.F53.HorseBuff.mixin.Client; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.Share; -import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.entity.feature.HorseArmorFeatureRenderer; -import net.minecraft.entity.passive.HorseEntity; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.ColorHelper.Argb; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -import static net.F53.HorseBuff.utils.RenderUtils.getAlpha; - -@Mixin(value = HorseArmorFeatureRenderer.class, priority = 960) -public class TransparentArmor { - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/passive/HorseEntity;FFFFFF)V", - at = @At(value = "INVOKE", target = "net/minecraft/client/render/RenderLayer.getEntityCutoutNoCull (Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;")) - RenderLayer makeRenderLayerTranslucent(Identifier texture, Operation original, @Local(argsOnly = true) HorseEntity horseEntity, @Share("alpha") LocalIntRef alpha) { - alpha.set(getAlpha(horseEntity)); - if (alpha.get() == 255) return original.call(texture); - return RenderLayer.getItemEntityTranslucentCull(texture); - } - - @ModifyArg(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/passive/HorseEntity;FFFFFF)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/HorseEntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V"), - index = 4) - int setOpacityForRender(int color, @Share("alpha") LocalIntRef alpha) { - return Argb.withAlpha(Math.min(Math.max(0, Argb.getAlpha(color)), alpha.get()), color); - } -} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentEquipment.java b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentEquipment.java new file mode 100644 index 0000000..da14ac4 --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentEquipment.java @@ -0,0 +1,43 @@ +package net.F53.HorseBuff.mixin.Client; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; +import net.F53.HorseBuff.render.entity.model.ExtendedRideableEquippableEntityModel; +import net.F53.HorseBuff.utils.RenderUtils; +import net.minecraft.client.model.Model; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.entity.equipment.EquipmentRenderer; +import net.minecraft.client.render.entity.model.HorseEntityModel; +import net.minecraft.client.render.entity.model.LlamaEntityModel; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.ColorHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(value = EquipmentRenderer.class, priority = 960) +public abstract class TransparentEquipment { + + @WrapOperation(method = "render(Lnet/minecraft/item/equipment/EquipmentModel$LayerType;Lnet/minecraft/util/Identifier;Lnet/minecraft/client/model/Model;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/util/Identifier;)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getArmorCutoutNoCull(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;")) + RenderLayer makeRenderLayerTranslucent(Identifier texture, Operation original, @Local(argsOnly = true) Model model, @Share("alpha") LocalIntRef alpha) { + if(model instanceof ExtendedRideableEquippableEntityModel extendedRideableEquippableEntityModel) { + alpha.set(RenderUtils.getAlpha(extendedRideableEquippableEntityModel.horsebuff$isPlayerPassenger())); + } + if (alpha.get() == 255) return original.call(texture); + return RenderLayer.getItemEntityTranslucentCull(texture); + } + + @ModifyArg(method = "render(Lnet/minecraft/item/equipment/EquipmentModel$LayerType;Lnet/minecraft/util/Identifier;Lnet/minecraft/client/model/Model;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/util/Identifier;)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/Model;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V"), + index = 4) + int setOpacityForRender(int color, @Local(argsOnly = true) Model model, @Share("alpha") LocalIntRef alpha) { + if(model instanceof HorseEntityModel || model instanceof LlamaEntityModel) { + return ColorHelper.withAlpha(Math.min(Math.max(0, ColorHelper.getAlpha(color)), alpha.get()), color); + } + return color; + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentMarkings.java b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentHorseMarkings.java similarity index 68% rename from src/main/java/net/F53/HorseBuff/mixin/Client/TransparentMarkings.java rename to src/main/java/net/F53/HorseBuff/mixin/Client/TransparentHorseMarkings.java index cffd412..0db0e40 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentMarkings.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentHorseMarkings.java @@ -5,32 +5,34 @@ import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.Share; import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; +import net.F53.HorseBuff.render.entity.state.ExtendedRideableEntityRenderState; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.feature.HorseMarkingFeatureRenderer; import net.minecraft.client.render.entity.model.HorseEntityModel; +import net.minecraft.client.render.entity.state.HorseEntityRenderState; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.passive.HorseEntity; import net.minecraft.util.Identifier; -import net.minecraft.util.math.ColorHelper.Argb; +import net.minecraft.util.math.ColorHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import static net.F53.HorseBuff.utils.RenderUtils.getAlpha; @Mixin(value = HorseMarkingFeatureRenderer.class, priority = 960) -public class TransparentMarkings { - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/passive/HorseEntity;FFFFFF)V", +public abstract class TransparentHorseMarkings { + + @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/HorseEntityRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getEntityTranslucent(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;")) - RenderLayer makeRenderLayerTranslucent(Identifier texture, Operation original, @Local(argsOnly = true) HorseEntity horseEntity, @Share("alpha") LocalIntRef alpha) { - alpha.set(getAlpha(horseEntity)); + RenderLayer makeRenderLayerTranslucent(Identifier texture, Operation original, @Local(argsOnly = true) HorseEntityRenderState horseEntityRenderState, @Share("alpha") LocalIntRef alpha) { + alpha.set(getAlpha(((ExtendedRideableEntityRenderState) horseEntityRenderState).horsebuff$isPlayerPassenger())); if (alpha.get() == 255) return original.call(texture); return RenderLayer.getItemEntityTranslucentCull(texture); } - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/passive/HorseEntity;FFFFFF)V", + @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/HorseEntityRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/HorseEntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;II)V")) - void modifyOverlayAlpha(HorseEntityModel instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, Operation original, @Share("alpha") LocalIntRef alpha) { - instance.render(matrixStack, vertexConsumer, light, overlay, Argb.withAlpha(alpha.get(), 0xFFFFFF)); + void modifyOverlayAlpha(HorseEntityModel instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, Operation original, @Share("alpha") LocalIntRef alpha) { + instance.render(matrixStack, vertexConsumer, light, overlay, ColorHelper.withAlpha(alpha.get(), 0xFFFFFF)); } } diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentLlamaDecor.java b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentLlamaDecor.java deleted file mode 100644 index 93a9485..0000000 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentLlamaDecor.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.F53.HorseBuff.mixin.Client; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.Share; -import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.render.entity.feature.LlamaDecorFeatureRenderer; -import net.minecraft.client.render.entity.model.LlamaEntityModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.passive.LlamaEntity; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.ColorHelper; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import static net.F53.HorseBuff.utils.RenderUtils.getAlpha; - -@Mixin(value = LlamaDecorFeatureRenderer.class, priority = 960) -public class TransparentLlamaDecor { - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/passive/LlamaEntity;FFFFFF)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getEntityCutoutNoCull(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;")) - RenderLayer modifyOverlayLayer(Identifier texture, Operation original, @Local(argsOnly = true) LlamaEntity llamaEntity, @Share("alpha") LocalIntRef alpha) { - alpha.set(getAlpha(llamaEntity)); - if (alpha.get() == 255) return original.call(texture); - return RenderLayer.getItemEntityTranslucentCull(texture); - } - - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/passive/LlamaEntity;FFFFFF)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/LlamaEntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;II)V")) - void modifyOverlayAlpha(LlamaEntityModel instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, Operation original, @Share("alpha") LocalIntRef alpha) { - instance.render(matrixStack, vertexConsumer, light, overlay, ColorHelper.Argb.withAlpha(alpha.get(), 0xFFFFFF)); - } -} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Server/AllowRaft.java b/src/main/java/net/F53/HorseBuff/mixin/Server/AllowRaft.java index fce8a02..f772d5a 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Server/AllowRaft.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Server/AllowRaft.java @@ -4,22 +4,24 @@ import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.Entity; import net.minecraft.entity.passive.AbstractHorseEntity; -import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.entity.vehicle.AbstractBoatEntity; +import net.minecraft.entity.vehicle.RaftEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -@Mixin(BoatEntity.class) +@Mixin(AbstractBoatEntity.class) public abstract class AllowRaft { + @ModifyReturnValue(method = "isSmallerThanBoat", at = @At("RETURN")) - private boolean allowRaft(boolean original, @Local(argsOnly = true)Entity entity){ - if (entity instanceof AbstractHorseEntity && hb$thiz().getVariant() == BoatEntity.Type.BAMBOO) + private boolean allowRaft(boolean original, @Local(argsOnly = true) Entity entity) { + if (entity instanceof AbstractHorseEntity && horsebuff$thiz() instanceof RaftEntity) return true; return original; } @Unique - private BoatEntity hb$thiz() { - return ((BoatEntity)(Object)this); + private AbstractBoatEntity horsebuff$thiz() { + return ((AbstractBoatEntity) (Object) this); } } diff --git a/src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.java b/src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.java index b128e0a..084edae 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.java @@ -20,14 +20,15 @@ // - 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(new Identifier("horse-buff", "mounted-step-height"), 0.1, EntityAttributeModifier.Operation.ADD_VALUE); + EntityAttributeModifier horsebuff$mountedStepHeight = new EntityAttributeModifier(Identifier.of("horse-buff", "mounted-step-height"), 0.1, EntityAttributeModifier.Operation.ADD_VALUE); @Unique - EntityAttributeModifier mountedBreakSpeed = new EntityAttributeModifier(new Identifier("horse-buff", "mounted-break-speed"), 5, EntityAttributeModifier.Operation.ADD_MULTIPLIED_BASE); + EntityAttributeModifier horsebuff$mountedBreakSpeed = new EntityAttributeModifier(Identifier.of("horse-buff", "mounted-break-speed"), 5, EntityAttributeModifier.Operation.ADD_MULTIPLIED_BASE); @Override public boolean startRiding(Entity entity, boolean force) { @@ -36,13 +37,13 @@ public boolean startRiding(Entity entity, boolean force) { return result; if (ModConfig.getInstance().stepHeight) { - EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT); - if (stepHeight != null) stepHeight.addTemporaryModifier(mountedStepHeight); + EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.STEP_HEIGHT); + if (stepHeight != null) stepHeight.addTemporaryModifier(horsebuff$mountedStepHeight); } if (ModConfig.getInstance().breakSpeed) { - EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED); - if (breakSpeed != null) breakSpeed.addTemporaryModifier(mountedBreakSpeed); + EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.BLOCK_BREAK_SPEED); + if (breakSpeed != null) breakSpeed.addTemporaryModifier(horsebuff$mountedBreakSpeed); } return result; } @@ -59,11 +60,11 @@ public void stopRiding() { return; } - EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT); - if (stepHeight != null) stepHeight.removeModifier(mountedStepHeight); + EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.STEP_HEIGHT); + if (stepHeight != null) stepHeight.removeModifier(horsebuff$mountedStepHeight); - EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED); - if (breakSpeed != null) breakSpeed.removeModifier(mountedBreakSpeed); + EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.BLOCK_BREAK_SPEED); + if (breakSpeed != null) breakSpeed.removeModifier(horsebuff$mountedBreakSpeed); super.stopRiding(); } diff --git a/src/main/java/net/F53/HorseBuff/mixin/Server/MovementCheck.java b/src/main/java/net/F53/HorseBuff/mixin/Server/MovementCheck.java index 391be71..8b34fd0 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Server/MovementCheck.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Server/MovementCheck.java @@ -11,7 +11,8 @@ // Disable movement checks for Players on Horses, fixing MC-100830 @Mixin(value = ServerPlayNetworkHandler.class, priority = 960) -public class MovementCheck { +public abstract class MovementCheck { + @Shadow public ServerPlayerEntity player; // TODO: figure out safer alternative to ModifyConstant here (not easy) diff --git a/src/main/java/net/F53/HorseBuff/mixin/Server/NoBuck.java b/src/main/java/net/F53/HorseBuff/mixin/Server/NoBuck.java index 9eeca1f..de57972 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Server/NoBuck.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Server/NoBuck.java @@ -1,29 +1,28 @@ -package net.F53.HorseBuff.mixin.Server; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import net.F53.HorseBuff.config.ModConfig; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.passive.AbstractHorseEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(value = AbstractHorseEntity.class, priority = 960) -public class NoBuck { - @ModifyReturnValue(method = "isAngry", at = @At("RETURN")) - private boolean isAngry(boolean original) { - AbstractHorseEntity instance = hb$thiz(); - if (ModConfig.getInstance().noBuck - && !instance.jumping - && instance.isTame() - && instance.getControllingPassenger() != null) { - return false; - } - return original; - } - - @Unique - private AbstractHorseEntity hb$thiz() { - return ((AbstractHorseEntity)(Object)this); - } -} +package net.F53.HorseBuff.mixin.Server; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import net.F53.HorseBuff.config.ModConfig; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.passive.AbstractHorseEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(value = AbstractHorseEntity.class, priority = 960) +public abstract class NoBuck { + + @Shadow protected boolean jumping; + @Shadow public abstract boolean isTame(); + @Shadow public abstract LivingEntity getControllingPassenger(); + + @ModifyReturnValue(method = "isAngry", at = @At("RETURN")) + private boolean isAngry(boolean original) { + if (ModConfig.getInstance().noBuck + && jumping + && isTame() + && getControllingPassenger() != null) { + return false; + } + return original; + } +} diff --git a/src/main/java/net/F53/HorseBuff/mixin/Server/NoWander.java b/src/main/java/net/F53/HorseBuff/mixin/Server/NoWander.java index baad7dd..7c13fcc 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Server/NoWander.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Server/NoWander.java @@ -12,17 +12,18 @@ // Lower wander speed for saddled horses @Mixin(value = LivingEntity.class, priority = 960) public abstract class NoWander { + @ModifyArg(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;travel(Lnet/minecraft/util/math/Vec3d;)V")) private Vec3d lowerWanderSpeed(Vec3d input) { if (ModConfig.getInstance().noWander - && (hb$thiz() instanceof AbstractHorseEntity horse + && (horsebuff$thiz() instanceof AbstractHorseEntity horse && horse.isSaddled())) return(Vec3d.ZERO); return input; } @Unique - private LivingEntity hb$thiz() { + private LivingEntity horsebuff$thiz() { return ((LivingEntity)(Object)this); } } diff --git a/src/main/java/net/F53/HorseBuff/render/entity/model/ExtendedRideableEquippableEntityModel.java b/src/main/java/net/F53/HorseBuff/render/entity/model/ExtendedRideableEquippableEntityModel.java new file mode 100644 index 0000000..8bfac30 --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/render/entity/model/ExtendedRideableEquippableEntityModel.java @@ -0,0 +1,6 @@ +package net.F53.HorseBuff.render.entity.model; + +public interface ExtendedRideableEquippableEntityModel { + void horsebuff$setPlayerPassenger(boolean playerPassenger); + boolean horsebuff$isPlayerPassenger(); +} diff --git a/src/main/java/net/F53/HorseBuff/render/entity/state/ExtendedRideableEntityRenderState.java b/src/main/java/net/F53/HorseBuff/render/entity/state/ExtendedRideableEntityRenderState.java new file mode 100644 index 0000000..e3a6dd0 --- /dev/null +++ b/src/main/java/net/F53/HorseBuff/render/entity/state/ExtendedRideableEntityRenderState.java @@ -0,0 +1,8 @@ +package net.F53.HorseBuff.render.entity.state; + +public interface ExtendedRideableEntityRenderState { + void horsebuff$setId(int id); + int horsebuff$getId(); + void horsebuff$setPlayerPassenger(boolean playerPassenger); + boolean horsebuff$isPlayerPassenger(); +} diff --git a/src/main/java/net/F53/HorseBuff/utils/RenderUtils.java b/src/main/java/net/F53/HorseBuff/utils/RenderUtils.java index 88e5d33..64b9304 100644 --- a/src/main/java/net/F53/HorseBuff/utils/RenderUtils.java +++ b/src/main/java/net/F53/HorseBuff/utils/RenderUtils.java @@ -1,25 +1,34 @@ -package net.F53.HorseBuff.utils; - -import net.F53.HorseBuff.config.ModConfig; -import net.minecraft.client.MinecraftClient; -import net.minecraft.entity.Entity; - -public class RenderUtils { - public static boolean isJeb(Entity entity) { - return ModConfig.getInstance().jeb_Horses && entity.hasCustomName() && "jeb_".equals(entity.getName().getString()); - } - - public static int getAlpha(Entity horse) { - ModConfig.FadeConfig pitchFadeConfig = ModConfig.getInstance().pitchFade; - if (!pitchFadeConfig.enabled) return 255; - MinecraftClient client = MinecraftClient.getInstance(); - if (client.player == null || !client.options.getPerspective().isFirstPerson() || !horse.hasPassenger(client.player)) - return 255; - - int minAlpha = 255 - Math.round(pitchFadeConfig.maxTransparency * 2.25f); - int rate = (255 - minAlpha) / (pitchFadeConfig.startAngle - pitchFadeConfig.endAngle); - int unclampedAlpha = Math.round(rate * (client.player.renderPitch - pitchFadeConfig.endAngle)); - - return Math.min(Math.max(unclampedAlpha, minAlpha), 255); - } -} +package net.F53.HorseBuff.utils; + +import net.F53.HorseBuff.config.ModConfig; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.state.CamelEntityRenderState; +import net.minecraft.client.render.entity.state.LivingEntityRenderState; +import net.minecraft.client.render.entity.state.LivingHorseEntityRenderState; +import net.minecraft.client.render.entity.state.LlamaEntityRenderState; + +public class RenderUtils { + public static boolean isJeb(LivingEntityRenderState entityRenderState) { + return ModConfig.getInstance().jeb_Horses && entityRenderState.customName != null && "jeb_".equals(entityRenderState.customName.getString()); + } + + public static int getAlpha(boolean isPlayerPassenger) { + ModConfig.FadeConfig pitchFadeConfig = ModConfig.getInstance().pitchFade; + if (!pitchFadeConfig.enabled) return 255; + MinecraftClient client = MinecraftClient.getInstance(); + if (client.player == null || !client.options.getPerspective().isFirstPerson() || !isPlayerPassenger) + return 255; + + int minAlpha = 255 - Math.round(pitchFadeConfig.maxTransparency * 2.25f); + int rate = (255 - minAlpha) / (pitchFadeConfig.startAngle - pitchFadeConfig.endAngle); + int unclampedAlpha = Math.round(rate * (client.player.renderPitch - pitchFadeConfig.endAngle)); + + return Math.min(Math.max(unclampedAlpha, minAlpha), 255); + } + + public static boolean isRideableEntityRenderState(LivingEntityRenderState livingEntityRenderState) { + return livingEntityRenderState instanceof LivingHorseEntityRenderState || + livingEntityRenderState instanceof LlamaEntityRenderState || + livingEntityRenderState instanceof CamelEntityRenderState; + } +} diff --git a/src/main/resources/assets/horsebuff/lang/en_us.json b/src/main/resources/assets/horsebuff/lang/en_us.json index 32a7eca..6e072af 100644 --- a/src/main/resources/assets/horsebuff/lang/en_us.json +++ b/src/main/resources/assets/horsebuff/lang/en_us.json @@ -9,12 +9,6 @@ "text.autoconfig.HorseBuff.option.noWander": "No Horse Wandering", "text.autoconfig.HorseBuff.option.noWander.@Tooltip": "Yes - saddled horses wont wander.\nNo - saddled horses will wander", - "text.autoconfig.HorseBuff.option.fairBreeds": "Breeding Changes", - "text.autoconfig.HorseBuff.option.fairBreeds.@Tooltip": "Yes - game uses alternate breeding algorithm.\nNo - game uses vanilla breeding algorithm", - - "text.autoconfig.HorseBuff.option.portalPatch": "Ride Through Portals", - "text.autoconfig.HorseBuff.option.portalPatch.@Tooltip": "Yes - Allows you to travel through nether and end portals while mounted on horseback.\nNo - vanilla behavior", - "text.autoconfig.HorseBuff.option.rubberBand": "Fix Rubberbanding on Stairs", "text.autoconfig.HorseBuff.option.rubberBand.@Tooltip": "Yes - Increases server tolerance for Horse movement speed, fixing rubberbanding.\nNo - vanilla behavior", diff --git a/src/main/resources/assets/horsebuff/lang/es_mx.json b/src/main/resources/assets/horsebuff/lang/es_mx.json index 90c2e15..8c118ec 100644 --- a/src/main/resources/assets/horsebuff/lang/es_mx.json +++ b/src/main/resources/assets/horsebuff/lang/es_mx.json @@ -9,12 +9,6 @@ "text.autoconfig.HorseBuff.option.noWander": "Los Caballos no vagan", "text.autoconfig.HorseBuff.option.noWander.@Tooltip": "Sí: los caballos con silla no vagarán. No: los caballos con silla vagarán", - "text.autoconfig.HorseBuff.option.fairBreeds": "Cambios en el algoritmo de cría", - "text.autoconfig.HorseBuff.option.fairBreeds.@Tooltip": "Sí: el juego utiliza un algoritmo de cría alternativo. No: el juego utiliza el algoritmo de cría estándar", - - "text.autoconfig.HorseBuff.option.portalPatch": "Viajar a través de Portales", - "text.autoconfig.HorseBuff.option.portalPatch.@Tooltip": "Sí: te permite viajar a través de portales del Nether y del End mientras estás montado en un caballo. No: comportamiento estándar", - "text.autoconfig.HorseBuff.option.rubberBand": "Corregir el Retroceso en las Escaleras", "text.autoconfig.HorseBuff.option.rubberBand.@Tooltip": "Sí: aumenta la tolerancia del servidor para la velocidad de movimiento del caballo, corrigiendo el retroceso. No: comportamiento estándar", diff --git a/src/main/resources/assets/horsebuff/lang/ru_ru.json b/src/main/resources/assets/horsebuff/lang/ru_ru.json index ccaadc0..4f54f98 100644 --- a/src/main/resources/assets/horsebuff/lang/ru_ru.json +++ b/src/main/resources/assets/horsebuff/lang/ru_ru.json @@ -9,12 +9,6 @@ "text.autoconfig.HorseBuff.option.noWander": "Отключить блуждание лошадей", "text.autoconfig.HorseBuff.option.noWander.@Tooltip": "Да — осёдланные лошади не будут блуждать.\nНет — осёдланные лошади будут блуждать.", - "text.autoconfig.HorseBuff.option.fairBreeds": "Изменения в размножении", - "text.autoconfig.HorseBuff.option.fairBreeds.@Tooltip": "Да — будет использоваться альтернативный алгоритм разведения.\nНет — будет использоваться ванильный алгоритм разведения.", - - "text.autoconfig.HorseBuff.option.portalPatch": "Езда через порталы", - "text.autoconfig.HorseBuff.option.portalPatch.@Tooltip": "Да — Позволяет вам путешествовать через порталы Незера и Энда верхом на лошади.\nНет — ванильное поведение.", - "text.autoconfig.HorseBuff.option.rubberBand": "Исправить застревание на ступеньках", "text.autoconfig.HorseBuff.option.rubberBand.@Tooltip": "Да — Увеличивает толерантность сервера к скорости передвижения лошади, устраняя застревание.\nНет — ванильное поведение.", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 627f1d2..978efc5 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -2,7 +2,6 @@ "schemaVersion": 1, "id": "horsebuff", "version": "${version}", - "accessWidener": "horsebuff.accesswidener", "name": "HorseBuff", "description": "Makes Horses better by removing stupid things", "authors": [ @@ -31,8 +30,8 @@ ], "depends": { "fabricloader": ">=0.15.11", - "minecraft": ">=1.21", - "java": ">=17", + "minecraft": ">=1.21.3", + "java": ">=21", "fabric-api": "*", "cloth-config": "*" }, diff --git a/src/main/resources/horsebuff.accesswidener b/src/main/resources/horsebuff.accesswidener deleted file mode 100644 index 229ad34..0000000 --- a/src/main/resources/horsebuff.accesswidener +++ /dev/null @@ -1,5 +0,0 @@ -accessWidener v2 named - -accessible method net/minecraft/util/Identifier (Ljava/lang/String;Ljava/lang/String;)V - -accessible field net/minecraft/entity/passive/AbstractHorseEntity jumping Z diff --git a/src/main/resources/horsebuff.mixins.json b/src/main/resources/horsebuff.mixins.json index 4b606ef..72c9628 100644 --- a/src/main/resources/horsebuff.mixins.json +++ b/src/main/resources/horsebuff.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "net.F53.HorseBuff.mixin", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_21", "mixins": [ "Server.AllowRaft", "Server.MountedModifiers", @@ -12,13 +12,16 @@ ], "client": [ "Client.HeadPitchOffset", - "Client.HorseRenderer", + "Client.HorseArmorFeatureRendererMixin", "Client.InventoryAccessor", "Client.JebHorseTintable", + "Client.LivingEntityRendererMixin", + "Client.LlamaDecorFeatureRendererMixin", + "Client.RideableEquippableEntityModelMixin", + "Client.RideableEntityRenderStateMixin", "Client.Swim", - "Client.TransparentArmor", - "Client.TransparentLlamaDecor", - "Client.TransparentMarkings" + "Client.TransparentEquipment", + "Client.TransparentHorseMarkings" ], "injectors": { "defaultRequire": 1 From 297c3f6e727a5cea43cf03d13e34ef4d67f40b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Bj=C3=B8rnstad?= Date: Fri, 27 Dec 2024 00:02:30 +0100 Subject: [PATCH 2/2] Port to 1.21.4 * Removed the rubberBand feature as it was fixed in 1.21.4 (snapshot 24w45a) * Removed rubberBand from lang-files * Updated README. Moved rubberBand feature to the legacy section --- README.md | 17 ++++++------- gradle.properties | 12 ++++----- .../net/F53/HorseBuff/config/ModConfig.java | 4 --- .../LlamaDecorFeatureRendererMixin.java | 2 +- .../mixin/Client/TransparentEquipment.java | 4 +-- .../HorseBuff/mixin/Server/MovementCheck.java | 25 ------------------- .../assets/horsebuff/lang/en_us.json | 3 --- .../assets/horsebuff/lang/es_mx.json | 3 --- .../assets/horsebuff/lang/ru_ru.json | 3 --- src/main/resources/fabric.mod.json | 2 +- src/main/resources/horsebuff.mixins.json | 1 - 11 files changed, 18 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/net/F53/HorseBuff/mixin/Server/MovementCheck.java diff --git a/README.md b/README.md index faa777f..a87a13b 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,6 @@ Improve horses by removing stupid stuff and adding useful stuff. ![player sitting in a bamboo raft in a river with a horse](https://cdn.modrinth.com/data/cached_images/d2faef4b56e873ee8a20816b5276e52aa1b20bbc.png)
-
- - Fix rubber banding on stairs/slabs "Horse moved wrongly!" - (MC-100830) - - - ![side by side comparison of going up a staircase with/without the mod. The without frequently goes back a couple of steps in a disorienting manner. The with doesn't have that and results in travel being faster](https://i.imgur.com/bXu7lt4.gif) -
-
Saddled Horses don't wander @@ -105,6 +96,14 @@ Improve horses by removing stupid stuff and adding useful stuff.
### Legacy features (removed due to them being added to the game officially) +
+ + [Server Side] Fix rubber banding on stairs/slabs "Horse moved wrongly!" + (MC-100830) (1.16.5 - 1.21.3) + + +![side by side comparison of going up a staircase with/without the mod. The without frequently goes back a couple of steps in a disorienting manner. The with doesn't have that and results in travel being faster](https://i.imgur.com/bXu7lt4.gif) +
[Server Side] diff --git a/gradle.properties b/gradle.properties index 8b5388c..f84ef83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop/ -minecraft_version=1.21.3 -yarn_mappings=1.21.3+build.2 +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.2 loader_version=0.16.9 # Mod Properties mod_version=2.2.0 maven_group=com.HorseBuff archives_base_name=HorseBuff # Dependencies -fabric_version=0.112.1+1.21.3 -cloth_config_version=16.0.143 -mod_menu_version=12.0.0 -mixinextras_version=0.4.1 \ No newline at end of file +fabric_version=0.112.2+1.21.4 +cloth_config_version=17.0.144 +mod_menu_version=13.0.0-beta.1 +mixinextras_version=0.3.5 \ No newline at end of file diff --git a/src/main/java/net/F53/HorseBuff/config/ModConfig.java b/src/main/java/net/F53/HorseBuff/config/ModConfig.java index 2af96b6..725c8dc 100644 --- a/src/main/java/net/F53/HorseBuff/config/ModConfig.java +++ b/src/main/java/net/F53/HorseBuff/config/ModConfig.java @@ -14,10 +14,6 @@ public class ModConfig implements ConfigData{ @ConfigEntry.Gui.Tooltip public boolean noWander = true; - @ConfigEntry.Category("Server") - @ConfigEntry.Gui.Tooltip - public boolean rubberBand = true; - @ConfigEntry.Category("Server") @ConfigEntry.Gui.Tooltip public boolean breakSpeed = true; diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/LlamaDecorFeatureRendererMixin.java b/src/main/java/net/F53/HorseBuff/mixin/Client/LlamaDecorFeatureRendererMixin.java index 5fc4d5d..b6d6f63 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/LlamaDecorFeatureRendererMixin.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/LlamaDecorFeatureRendererMixin.java @@ -14,7 +14,7 @@ @Mixin(value = LlamaDecorFeatureRenderer.class, priority = 960) public class LlamaDecorFeatureRendererMixin { - @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/entity/state/LlamaEntityRenderState;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Identifier;I)V", + @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/entity/state/LlamaEntityRenderState;Lnet/minecraft/item/ItemStack;Lnet/minecraft/registry/RegistryKey;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/LlamaEntityModel;setAngles(Lnet/minecraft/client/render/entity/state/LlamaEntityRenderState;)V", shift = At.Shift.AFTER)) void updatePlayerPassenger(CallbackInfo callbackInfo, @Local(argsOnly = true) LlamaEntityRenderState llamaEntityRenderState, @Local LlamaEntityModel llamaEntityModel) { diff --git a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentEquipment.java b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentEquipment.java index da14ac4..6e18603 100644 --- a/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentEquipment.java +++ b/src/main/java/net/F53/HorseBuff/mixin/Client/TransparentEquipment.java @@ -21,7 +21,7 @@ @Mixin(value = EquipmentRenderer.class, priority = 960) public abstract class TransparentEquipment { - @WrapOperation(method = "render(Lnet/minecraft/item/equipment/EquipmentModel$LayerType;Lnet/minecraft/util/Identifier;Lnet/minecraft/client/model/Model;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/util/Identifier;)V", + @WrapOperation(method = "render(Lnet/minecraft/client/render/entity/equipment/EquipmentModel$LayerType;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/client/model/Model;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/util/Identifier;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getArmorCutoutNoCull(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;")) RenderLayer makeRenderLayerTranslucent(Identifier texture, Operation original, @Local(argsOnly = true) Model model, @Share("alpha") LocalIntRef alpha) { if(model instanceof ExtendedRideableEquippableEntityModel extendedRideableEquippableEntityModel) { @@ -31,7 +31,7 @@ RenderLayer makeRenderLayerTranslucent(Identifier texture, Operation=0.15.11", - "minecraft": ">=1.21.3", + "minecraft": ">=1.21.4", "java": ">=21", "fabric-api": "*", "cloth-config": "*" diff --git a/src/main/resources/horsebuff.mixins.json b/src/main/resources/horsebuff.mixins.json index 72c9628..9040af6 100644 --- a/src/main/resources/horsebuff.mixins.json +++ b/src/main/resources/horsebuff.mixins.json @@ -6,7 +6,6 @@ "mixins": [ "Server.AllowRaft", "Server.MountedModifiers", - "Server.MovementCheck", "Server.NoBuck", "Server.NoWander" ],