Skip to content

Commit

Permalink
feat: update to 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurkengewuerz committed Oct 31, 2023
1 parent 16d0c28 commit 684b23a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 71 deletions.
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
18 changes: 9 additions & 9 deletions src/main/java/de/mc8051/clientenhancements/HudInfoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String, Boolean> sortedStates = ClientEnhancementsClient.getKeyController().getSortedStates();
final List<String> 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<String> texts) {
private void drawText(DrawContext drawContext, List<String> texts) {
MinecraftClient client = MinecraftClient.getInstance();
TextRenderer textRenderer = client.inGameHud.getTextRenderer();

Expand All @@ -30,11 +30,11 @@ private void drawText(MatrixStack matrices, List<String> 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
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -55,7 +58,7 @@ private void resetCapeMovement() {
}

private void spawn() {
world.addEntity(getId(), this);
world.addEntity(this);
}

public void despawn() {
Expand All @@ -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();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<Supplier<SkinTextures>> cir) {
// this also loads the cape
CapePlayerHandler.getCapePlayerHandler(profile.getId());
}

@Inject(method = "getCapeTexture", at = @At("TAIL"), cancellable = true)
private void getCapeTexture(CallbackInfoReturnable<Identifier> cir) {
@Inject(method = "getSkinTextures", at = @At("TAIL"), cancellable = true)
private void getCapeTexture(CallbackInfoReturnable<SkinTextures> 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

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;
import org.spongepowered.asm.mixin.injection.At;
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) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/client-enhancements.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"BlockMixin",
"BlockSodiumMixin",
"BrightnessMixin",
"CapeElytraFeatureMixin",
"CapePlayerListMixin",
"EntityInvoker",
"InvisibleMixin",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
}
}

0 comments on commit 684b23a

Please sign in to comment.