Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial port to 1.21.3 #80

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.1
loader_version=0.16.9
# Mod Properties
mod_version=2.1.8
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
fabric_version=0.109.0+1.21.3
cloth_config_version=16.0.141
mod_menu_version=12.0.0-beta.1
mixinextras_version=0.3.5
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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 net.minecraft.util.math.ColorHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -36,11 +36,11 @@ int setOpacityAndChromaForRender(int color, @Local(argsOnly = true, ordinal = 1)
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);
color = ColorHelper.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));
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 Argb.withAlpha(alpha.get(), color);
return ColorHelper.withAlpha(alpha.get(), color);
}

@ModifyArg(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
Expand Down
23 changes: 16 additions & 7 deletions src/main/java/net/F53/HorseBuff/mixin/Client/JebHorseTintable.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
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.entity.passive.HorseEntity;
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 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;
@Final
@Shadow
private static Map<HorseColor, Identifier> 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 instance.getVariant();
return TEXTURES.get(horseEntityRenderState.color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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 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;
Expand All @@ -30,6 +30,6 @@ RenderLayer makeRenderLayerTranslucent(Identifier texture, Operation<RenderLayer
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);
return ColorHelper.withAlpha(Math.min(Math.max(0, ColorHelper.getAlpha(color)), alpha.get()), color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RenderLayer modifyOverlayLayer(Identifier texture, Operation<RenderLayer> origin

@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<Void> original, @Share("alpha") LocalIntRef alpha) {
instance.render(matrixStack, vertexConsumer, light, overlay, ColorHelper.Argb.withAlpha(alpha.get(), 0xFFFFFF));
void modifyOverlayAlpha(LlamaEntityModel instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, Operation<Void> original, @Share("alpha") LocalIntRef alpha) {
instance.render(matrixStack, vertexConsumer, light, overlay, ColorHelper.withAlpha(alpha.get(), 0xFFFFFF));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
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",
@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<RenderLayer> 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);
}

@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<Void> 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<Void> original, @Share("alpha") LocalIntRef alpha) {
instance.render(matrixStack, vertexConsumer, light, overlay, ColorHelper.withAlpha(alpha.get(), 0xFFFFFF));
}
}
11 changes: 6 additions & 5 deletions src/main/java/net/F53/HorseBuff/mixin/Server/AllowRaft.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
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)
if (entity instanceof AbstractHorseEntity && hb$thiz() instanceof RaftEntity)
return true;
return original;
}

@Unique
private BoatEntity hb$thiz() {
return ((BoatEntity)(Object)this);
private AbstractBoatEntity hb$thiz() {
return ((AbstractBoatEntity)(Object)this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ protected MountedModifiers(EntityType<? extends LivingEntity> entityType, World
}

@Unique
EntityAttributeModifier mountedStepHeight = new EntityAttributeModifier(new Identifier("horse-buff", "mounted-step-height"), 0.1, EntityAttributeModifier.Operation.ADD_VALUE);
EntityAttributeModifier 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 mountedBreakSpeed = new EntityAttributeModifier(Identifier.of("horse-buff", "mounted-break-speed"), 5, EntityAttributeModifier.Operation.ADD_MULTIPLIED_BASE);

@Override
public boolean startRiding(Entity entity, boolean force) {
Expand All @@ -36,12 +36,12 @@ public boolean startRiding(Entity entity, boolean force) {
return result;

if (ModConfig.getInstance().stepHeight) {
EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT);
EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.STEP_HEIGHT);
if (stepHeight != null) stepHeight.addTemporaryModifier(mountedStepHeight);
}

if (ModConfig.getInstance().breakSpeed) {
EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED);
EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.BLOCK_BREAK_SPEED);
if (breakSpeed != null) breakSpeed.addTemporaryModifier(mountedBreakSpeed);
}
return result;
Expand All @@ -59,10 +59,10 @@ public void stopRiding() {
return;
}

EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT);
EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.STEP_HEIGHT);
if (stepHeight != null) stepHeight.removeModifier(mountedStepHeight);

EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED);
EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.BLOCK_BREAK_SPEED);
if (breakSpeed != null) breakSpeed.removeModifier(mountedBreakSpeed);

super.stopRiding();
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/net/F53/HorseBuff/utils/RenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import net.F53.HorseBuff.config.ModConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.entity.HorseEntityRenderer;
import net.minecraft.client.render.entity.state.HorseEntityRenderState;
import net.minecraft.entity.Entity;
import net.minecraft.text.Text;

public class RenderUtils {
public static boolean isJeb(Entity entity) {
return ModConfig.getInstance().jeb_Horses && entity.hasCustomName() && "jeb_".equals(entity.getName().getString());
public static boolean isJeb(HorseEntityRenderState entity) {
return ModConfig.getInstance().jeb_Horses && entity.customName != null && "jeb_".equals(entity.customName.getString());
}

public static int getAlpha(Entity horse) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/horsebuff.accesswidener
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
accessWidener v2 named

accessible method net/minecraft/util/Identifier <init> (Ljava/lang/String;Ljava/lang/String;)V

accessible field net/minecraft/entity/passive/AbstractHorseEntity jumping Z
Loading