diff --git a/gradle.properties b/gradle.properties index 3f5e624..1cbb937 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,17 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G # Fabric Properties -# check these on https://modmuss50.me/fabric.html -minecraft_version=1.19.4 -yarn_mappings=1.19.4+build.2 -loader_version=0.14.19 +# check these on https://fabricmc.net/develop/ +minecraft_version=1.20.2 +yarn_mappings=1.20.2+build.4 +loader_version=0.14.24 # see https://linkie.shedaniel.dev/dependencies -cloth_config_version=10.0.96 -modmenu_version=6.1.0-rc.4 +cloth_config_version=12.0.109 +modmenu_version=8.0.0-beta.2 # Mod Properties -mod_version=1.5-SNAPSHOT +mod_version=1.6-SNAPSHOT maven_group=de.mc8051 archives_base_name=client-enhancements # Dependencies -# check this on https://modmuss50.me/fabric.html -fabric_version=0.77.0+1.19.4 +# check this on https://fabricmc.net/develop/ +fabric_version=0.90.4+1.20.2 diff --git a/src/main/java/de/mc8051/clientenhancements/HudInfoRenderer.java b/src/main/java/de/mc8051/clientenhancements/HudInfoRenderer.java index c455318..69c0111 100644 --- a/src/main/java/de/mc8051/clientenhancements/HudInfoRenderer.java +++ b/src/main/java/de/mc8051/clientenhancements/HudInfoRenderer.java @@ -4,7 +4,7 @@ import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; import java.util.List; @@ -14,14 +14,14 @@ public class HudInfoRenderer implements HudRenderCallback { @Override - public void onHudRender(MatrixStack matrices, float delta) { + public void onHudRender(DrawContext drawContext, float tickDelta) { if (!ClientEnhancements.config.getConfig().HUD_VISIBLE) return; final TreeMap sortedStates = ClientEnhancementsClient.getKeyController().getSortedStates(); final List activeMods = sortedStates.entrySet().stream().filter(Map.Entry::getValue).map(entry -> Text.translatable(entry.getKey()).getString()).toList(); - drawText(matrices, activeMods); + drawText(drawContext, activeMods); } - private void drawText(MatrixStack matrices, List texts) { + private void drawText(DrawContext drawContext, List texts) { MinecraftClient client = MinecraftClient.getInstance(); TextRenderer textRenderer = client.inGameHud.getTextRenderer(); @@ -30,11 +30,11 @@ private void drawText(MatrixStack matrices, List texts) { final String text = texts.get(index); final Text generatedText = Text.of(text); - textRenderer.drawWithShadow( - matrices, - generatedText, - 2, 2 + ((2 + stringHeight) * index), - 0xffffff + drawContext.drawText( + textRenderer, + generatedText, + 2, 2 + ((2 + stringHeight) * index), + 0xffffff, true ); } } diff --git a/src/main/java/de/mc8051/clientenhancements/client/FakePlayerEntity.java b/src/main/java/de/mc8051/clientenhancements/client/FakePlayerEntity.java index 721f9d5..fa08230 100644 --- a/src/main/java/de/mc8051/clientenhancements/client/FakePlayerEntity.java +++ b/src/main/java/de/mc8051/clientenhancements/client/FakePlayerEntity.java @@ -3,6 +3,7 @@ import com.mojang.authlib.GameProfile; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.util.SkinTextures; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.data.DataTracker; @@ -13,6 +14,8 @@ public class FakePlayerEntity extends AbstractClientPlayerEntity { + // inspired by https://github.com/Wurst-Imperium/Wurst7/blob/master/src/main/java/net/wurstclient/util/FakePlayerEntity.java + private ClientPlayerEntity player; private ClientWorld world; @@ -55,7 +58,7 @@ private void resetCapeMovement() { } private void spawn() { - world.addEntity(getId(), this); + world.addEntity(this); } public void despawn() { @@ -65,12 +68,4 @@ public void despawn() { public void resetPlayerPosition() { player.refreshPositionAndAngles(getX(), getY(), getZ(), getYaw(), getPitch()); } - - @Override - public Identifier getSkinTexture() { - if (hasSkinTexture()) - return super.getSkinTexture(); - else - return player.getSkinTexture(); - } } diff --git a/src/main/java/de/mc8051/clientenhancements/mixin/CapeElytraFeatureMixin.java b/src/main/java/de/mc8051/clientenhancements/mixin/CapeElytraFeatureMixin.java deleted file mode 100644 index 95ff863..0000000 --- a/src/main/java/de/mc8051/clientenhancements/mixin/CapeElytraFeatureMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.mc8051.clientenhancements.mixin; - -import de.mc8051.clientenhancements.CapePlayerHandler; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.entity.feature.ElytraFeatureRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ElytraFeatureRenderer.class) -public class CapeElytraFeatureMixin { - - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;canRenderCapeTexture()Z")) - private boolean toggleCustomElytra(AbstractClientPlayerEntity abstractClientPlayerEntity) { - - final CapePlayerHandler capePlayerHandler = CapePlayerHandler.getCapePlayerHandler(abstractClientPlayerEntity.getGameProfile().getId()); - if (capePlayerHandler != null) { - return capePlayerHandler.hasElytraTexture(); - } - return abstractClientPlayerEntity.canRenderCapeTexture(); - } - -} diff --git a/src/main/java/de/mc8051/clientenhancements/mixin/CapePlayerListMixin.java b/src/main/java/de/mc8051/clientenhancements/mixin/CapePlayerListMixin.java index a3131c1..677c75e 100644 --- a/src/main/java/de/mc8051/clientenhancements/mixin/CapePlayerListMixin.java +++ b/src/main/java/de/mc8051/clientenhancements/mixin/CapePlayerListMixin.java @@ -1,37 +1,49 @@ package de.mc8051.clientenhancements.mixin; import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import de.mc8051.clientenhancements.CapePlayerHandler; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.SkinTextures; 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.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.function.Supplier; + @Mixin(PlayerListEntry.class) public class CapePlayerListMixin { - @Shadow @Final private GameProfile profile; - @Shadow private boolean texturesLoaded; + // inspired by https://github.com/CaelTheColher/Capes/ - @Inject(method = "loadTextures", at = @At("HEAD")) - private void loadTextures(CallbackInfo ci) { - if (!texturesLoaded) { - // this also loads the cape - CapePlayerHandler.getCapePlayerHandler(profile.getId()); - } + @Shadow + @Final + private GameProfile profile; + + @Inject(method = "texturesSupplier", at = @At("HEAD")) + private static void loadTextures(GameProfile profile, CallbackInfoReturnable> cir) { + // this also loads the cape + CapePlayerHandler.getCapePlayerHandler(profile.getId()); } - @Inject(method = "getCapeTexture", at = @At("TAIL"), cancellable = true) - private void getCapeTexture(CallbackInfoReturnable cir) { + @Inject(method = "getSkinTextures", at = @At("TAIL"), cancellable = true) + private void getCapeTexture(CallbackInfoReturnable cir) { + final CapePlayerHandler capePlayerHandler = CapePlayerHandler.getCapePlayerHandler(profile.getId()); if (capePlayerHandler != null && capePlayerHandler.hasCape()) { - cir.setReturnValue(capePlayerHandler.getCape()); + + SkinTextures oldTextures = cir.getReturnValue(); + Identifier capeTexture = capePlayerHandler.getCape(); + Identifier elytraTexture = capePlayerHandler.hasElytraTexture() ? capeTexture : new Identifier("textures/entity/elytra.png"); + SkinTextures newTextures = new SkinTextures( + oldTextures.texture(), oldTextures.textureUrl(), + capeTexture, elytraTexture, + oldTextures.model(), oldTextures.secure()); + + cir.setReturnValue(newTextures); } } diff --git a/src/main/java/de/mc8051/clientenhancements/mixin/PacketOutputMixin.java b/src/main/java/de/mc8051/clientenhancements/mixin/PacketOutputMixin.java index 5c765d4..271e6f9 100644 --- a/src/main/java/de/mc8051/clientenhancements/mixin/PacketOutputMixin.java +++ b/src/main/java/de/mc8051/clientenhancements/mixin/PacketOutputMixin.java @@ -2,6 +2,8 @@ import de.mc8051.clientenhancements.client.ClientEnhancementsClient; import de.mc8051.clientenhancements.client.modules.Freecam; +import net.minecraft.client.network.ClientCommonNetworkHandler; +import net.minecraft.network.listener.ClientCommonPacketListener; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import org.spongepowered.asm.mixin.Mixin; @@ -9,11 +11,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.network.listener.ClientPlayPacketListener; - -@Mixin(ClientPlayNetworkHandler.class) -public abstract class PacketOutputMixin implements ClientPlayPacketListener { +@Mixin(ClientCommonNetworkHandler.class) +public abstract class PacketOutputMixin implements ClientCommonPacketListener { @Inject(at = {@At("HEAD")}, method = {"sendPacket(Lnet/minecraft/network/packet/Packet;)V"}, cancellable = true) private void onSendPacket(Packet packet, CallbackInfo ci) { diff --git a/src/main/resources/client-enhancements.mixins.json b/src/main/resources/client-enhancements.mixins.json index 3eb7c82..8afd239 100644 --- a/src/main/resources/client-enhancements.mixins.json +++ b/src/main/resources/client-enhancements.mixins.json @@ -11,7 +11,6 @@ "BlockMixin", "BlockSodiumMixin", "BrightnessMixin", - "CapeElytraFeatureMixin", "CapePlayerListMixin", "EntityInvoker", "InvisibleMixin", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9c04535..15e0627 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,9 +30,9 @@ "client-enhancements.mixins.json" ], "depends": { - "fabricloader": ">=0.14.19", + "fabricloader": ">=0.14.24", "fabric": "*", - "minecraft": ">=1.19", + "minecraft": ">=1.20", "cloth-config": "*" } }