Implemented MixinExtras

This commit is contained in:
FlorianMichael 2023-05-14 20:59:58 +02:00
parent a1ed04d634
commit f54ac0c785
8 changed files with 29 additions and 25 deletions

View File

@ -9,6 +9,10 @@ group = project.maven_group
configurations { configurations {
implementation.extendsFrom libs implementation.extendsFrom libs
api.extendsFrom libs api.extendsFrom libs
implementation.extendsFrom bundleMod
include.extendsFrom bundleMod
annotationProcessor.extendsFrom bundleMod
} }
allprojects { allprojects {
@ -89,6 +93,8 @@ dependencies {
} }
libs "net.lenni0451:Reflect:${project.reflect_version}" libs "net.lenni0451:Reflect:${project.reflect_version}"
bundleMod "com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}"
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}" modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
} }

View File

@ -36,3 +36,4 @@ reflect_version=1.1.0
# other libs # other libs
mod_menu_version=6.1.0-rc.4 mod_menu_version=6.1.0-rc.4
netty_codec_http_version=4.1.90.Final netty_codec_http_version=4.1.90.Final
mixin_extras_version=0.2.0-beta.7

View File

@ -19,6 +19,7 @@ package de.florianmichael.viafabricplus;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.llamalad7.mixinextras.MixinExtrasBootstrap;
import de.florianmichael.viafabricplus.definition.ChatLengthCalculation; import de.florianmichael.viafabricplus.definition.ChatLengthCalculation;
import de.florianmichael.viafabricplus.definition.v1_12_2.FontCacheFix; import de.florianmichael.viafabricplus.definition.v1_12_2.FontCacheFix;
import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings; import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings;
@ -57,6 +58,7 @@ public class ViaFabricPlus {
private final InformationSystem informationSystem = new InformationSystem(); private final InformationSystem informationSystem = new InformationSystem();
public void init() { public void init() {
MixinExtrasBootstrap.init();
PreLoadCallback.EVENT.invoker().onLoad(); PreLoadCallback.EVENT.invoker().onLoad();
// Classic Stuff // Classic Stuff

View File

@ -17,6 +17,7 @@
*/ */
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.ViaFabricPlus;
@ -109,11 +110,9 @@ public abstract class MixinClientPlayNetworkHandler {
} }
} }
@Redirect(method = "onPlayerSpawnPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen;setReady()V")) @WrapWithCondition(method = "onPlayerSpawnPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen;setReady()V"))
public void moveDownloadingTerrainClosing(DownloadingTerrainScreen instance) { public boolean moveDownloadingTerrainClosing(DownloadingTerrainScreen instance) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19)) { return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19);
instance.setReady();
}
} }
@Inject(method = "onPlayerPositionLook", at = @At("RETURN")) @Inject(method = "onPlayerPositionLook", at = @At("RETURN"))
@ -132,11 +131,9 @@ public abstract class MixinClientPlayNetworkHandler {
return constant; return constant;
} }
@Redirect(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) @WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
public void removeNewWarning(Logger instance, String s, Object o) { public boolean removeWarning(Logger instance, String s, Object o) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19_3)) { return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ProtocolVersion.v1_19_3);
instance.warn(s, o);
}
} }
@Redirect(method = "onKeepAlive", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;Ljava/util/function/BooleanSupplier;Ljava/time/Duration;)V")) @Redirect(method = "onKeepAlive", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;Ljava/util/function/BooleanSupplier;Ljava/time/Duration;)V"))

View File

@ -17,6 +17,7 @@
*/ */
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings; import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
@ -63,10 +64,10 @@ public abstract class MixinInGameHud {
// Moving down all remaining elements // Moving down all remaining elements
@Redirect(method = "renderStatusBars", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/hud/InGameHud;scaledHeight:I", opcode = Opcodes.GETFIELD)) @ModifyExpressionValue(method = "renderStatusBars", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/hud/InGameHud;scaledHeight:I", opcode = Opcodes.GETFIELD))
private int moveHealthDown(InGameHud instance) { private int moveHealthDown(int originalValue) {
if (VisualSettings.INSTANCE.removeNewerHudElements.getValue()) return scaledHeight + 6; if (VisualSettings.INSTANCE.removeNewerHudElements.getValue()) return originalValue + 6;
return scaledHeight; return originalValue;
} }
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIIIII)V"), slice = @Slice( @ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIIIII)V"), slice = @Slice(

View File

@ -17,6 +17,7 @@
*/ */
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -56,13 +57,11 @@ public abstract class MixinMinecraftClient implements IMinecraftClient {
@Shadow @Nullable public abstract ClientPlayNetworkHandler getNetworkHandler(); @Shadow @Nullable public abstract ClientPlayNetworkHandler getNetworkHandler();
@Redirect(method = "doItemUse", @WrapWithCondition(method = "doItemUse",
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")), slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V", ordinal = 0)) at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V", ordinal = 0))
private void redirectDoItemUse(HeldItemRenderer heldItemRenderer, Hand hand) { public boolean removeEquipProgressReset(HeldItemRenderer instance, Hand hand) {
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem)) { return ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem);
heldItemRenderer.resetEquipProgress(hand);
}
} }
@Redirect(method = "doItemUse", @Redirect(method = "doItemUse",

View File

@ -89,7 +89,6 @@ public class MixinServerResourcePackProvider {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return instance; return instance;
} }
return instance.toLowerCase(locale); return instance.toLowerCase(locale);
} }
} }

View File

@ -17,6 +17,7 @@
*/ */
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings; import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
@ -88,13 +89,11 @@ public abstract class MixinLivingEntity extends Entity {
return movingDown; return movingDown;
} }
@Redirect(method = "travel", @WrapWithCondition(method = "travel",
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;LEVITATION:Lnet/minecraft/entity/effect/StatusEffect;", ordinal = 0)), slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;LEVITATION:Lnet/minecraft/entity/effect/StatusEffect;", ordinal = 0)),
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;onLanding()V", ordinal = 0)) at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;onLanding()V", ordinal = 0))
private void dontResetLevitationFallDistance(LivingEntity instance) { private boolean dontResetLevitationFallDistance(LivingEntity instance) {
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_12_2)) { return ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_12_2);
instance.onLanding();
}
} }
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSprinting()Z", ordinal = 0)) @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSprinting()Z", ordinal = 0))