Skip to content

Commit d412587

Browse files
committed
Incomplete port to 1.21.10
TODO rendering changes required because RenderSystem and shader colours were gutted.
1 parent 558a213 commit d412587

File tree

17 files changed

+91
-78
lines changed

17 files changed

+91
-78
lines changed

src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/ResourcePreloaderMod.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static void downloadPacks() {
7272
Util.nonCriticalIoPool().execute(() -> downloadPack(rpOption, downloadsDirectory, SHA1, headers, proxy, () -> {
7373
counter.getAndDecrement();
7474
if (counter.get() <= 0 && getConfig().toastComplete) {
75-
SystemToast.add(Minecraft.getInstance().getToasts(), SystemToast.SystemToastId.PERIODIC_NOTIFICATION, Component.translatable("key.lemclienthelper.alldownloadcomplete"), null);
75+
SystemToast.add(Minecraft.getInstance().getToastManager(), SystemToast.SystemToastId.PERIODIC_NOTIFICATION, Component.translatable("key.lemclienthelper.alldownloadcomplete"), null);
7676
}
7777
}));
7878
}
@@ -114,7 +114,7 @@ public static void setStatus(UUID packID, Component status, Component status2) {
114114

115115
private static Map<String, String> getHeaders(User session) {
116116
WorldVersion gameVersion = SharedConstants.getCurrentVersion();
117-
return Map.of("X-Minecraft-Username", session.getName(), "X-Minecraft-UUID", UndashedUuid.toString(session.getProfileId()), "X-Minecraft-Version", gameVersion.getName(), "X-Minecraft-Version-ID", gameVersion.getId(), "X-Minecraft-Pack-Format", String.valueOf(gameVersion.getPackVersion(PackType.CLIENT_RESOURCES)), "User-Agent", "Minecraft Java/" + gameVersion.getName());
117+
return Map.of("X-Minecraft-Username", session.getName(), "X-Minecraft-UUID", UndashedUuid.toString(session.getProfileId()), "X-Minecraft-Version", gameVersion.name(), "X-Minecraft-Version-ID", gameVersion.id(), "X-Minecraft-Pack-Format", String.valueOf(gameVersion.packVersion(PackType.CLIENT_RESOURCES)), "User-Agent", "Minecraft Java/" + gameVersion.name());
118118
}
119119

120120
private static HttpUtil.DownloadProgressListener createListener(AllPacks.RPOption rpOption, Runnable onComplete) {

src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/ExtendedSlot.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package net.kyrptonaught.lemclienthelper.SmallInv;
22

33

4-
import com.mojang.datafixers.util.Pair;
54
import net.minecraft.resources.ResourceLocation;
65
import net.minecraft.world.entity.player.Player;
76
import net.minecraft.world.inventory.Slot;
87
import net.minecraft.world.item.ItemStack;
9-
import org.jetbrains.annotations.Nullable;
108

119
import java.util.Optional;
1210

@@ -67,8 +65,7 @@ public int getMaxStackSize(ItemStack stack) {
6765
return baseSlot.getMaxStackSize(stack);
6866
}
6967

70-
@Nullable
71-
public Pair<ResourceLocation, ResourceLocation> getNoItemIcon() {
68+
public ResourceLocation getNoItemIcon() {
7269
return baseSlot.getNoItemIcon();
7370
}
7471

src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/SmallInvMod.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.kyrptonaught.lemclienthelper.LEMClientHelperMod;
66
import net.minecraft.client.KeyMapping;
77
import net.minecraft.core.component.DataComponents;
8+
import net.minecraft.resources.ResourceLocation;
89
import net.minecraft.world.item.Items;
910
import net.minecraft.world.entity.player.Player;
1011
import net.minecraft.world.item.ItemStack;
@@ -23,7 +24,7 @@ public class SmallInvMod {
2324
public static void onInitialize() {
2425
LEMClientHelperMod.configManager.registerFile(MOD_ID, new SmallInvConfig());
2526
LEMClientHelperMod.configManager.load(MOD_ID);
26-
closeSmallInvKey = KeyBindingHelper.registerKeyBinding(new KeyMapping(LEMClientHelperMod.MOD_ID + ".key.closesmallinv", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_I, "key.category." + LEMClientHelperMod.MOD_ID));
27+
closeSmallInvKey = KeyBindingHelper.registerKeyBinding(new KeyMapping(LEMClientHelperMod.MOD_ID + ".key.closesmallinv", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_I, KeyMapping.Category.register(ResourceLocation.fromNamespaceAndPath(LEMClientHelperMod.MOD_ID, "keys"))));
2728

2829
registerSmallSlot(5, 55, 9);
2930
registerSmallSlot(6, 55, 27);
@@ -50,7 +51,7 @@ public static boolean isSmallInv(Player player) {
5051
if (!getConfig().enabled) return false;
5152

5253
//give @p knowledge_book{display:{Name:'{"text":" "}'},SmallInv:1,CustomModelData:1}
53-
for (ItemStack itemStack : player.getInventory().items) {
54+
for (ItemStack itemStack : player.getInventory().getNonEquipmentItems()) {
5455
if (isSmallSlot(itemStack))
5556
return true;
5657
}
@@ -83,6 +84,6 @@ public static boolean isKeybindPressed(int pressedKeyCode, boolean isMouse) {
8384
public static boolean isSmallSlot(ItemStack stack) {
8485
return stack.is(Items.KNOWLEDGE_BOOK) &&
8586
stack.has(DataComponents.CUSTOM_DATA) &&
86-
stack.get(DataComponents.CUSTOM_DATA).contains("SmallInv");
87+
stack.getOrDefault(DataComponents.CUSTOM_DATA,null).copyTag().contains("SmallInv");
8788
}
8889
}

src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderArea.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public double getLerpSpeed() {
4848
}
4949

5050
@Override
51-
public long getLerpRemainingTime() {
51+
public long getLerpTime() {
5252
return 0;
5353
}
5454

src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/ArmorHudRenderer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public static void onHudRender(GuiGraphics context, DeltaTracker v) {
3232
if (client.player != null && ArmorHudMod.shouldDisplayArmor() && !client.options.hideGui) {
3333
int height = client.getWindow().getGuiScaledHeight();
3434

35-
context.pose().pushPose();
35+
context.pose().pushMatrix();
3636
context.pose().translate(HudMod.getConfig().xOffset, height / 2f, 0);
3737
context.pose().scale(HudMod.getConfig().armorHudScale, HudMod.getConfig().armorHudScale, 1f);
3838
context.pose().translate(0, -32, 0);
3939
context.setColor(1f, 1f, 1f, HudMod.getConfig().transparency);
4040

4141
for (int i = 0; i < 4; i++) {
42-
ItemStack armorStack = client.player.getInventory().getArmor(i);
42+
ItemStack armorStack = client.player.getInventory().getItem(i);
4343
int y = 16 * (3 - i);
4444
if (armorStack.isEmpty()) {
4545
draw(context, EMPTY_SLOTS[i], 0, y);
@@ -49,15 +49,15 @@ public static void onHudRender(GuiGraphics context, DeltaTracker v) {
4949
}
5050
}
5151
context.setColor(1f, 1f, 1f, 1f);
52-
context.pose().popPose();
52+
context.pose().popMatrix();
5353
}
5454
}
5555

5656
public static void onHudRenderDummy(GuiGraphics context, float xOffset, float scale) {
5757
Minecraft client = Minecraft.getInstance();
5858
int height = client.getWindow().getGuiScaledHeight();
5959

60-
context.pose().pushPose();
60+
context.pose().pushMatrix();
6161
context.pose().translate(xOffset, height / 2f, 0);
6262
context.pose().scale(scale, scale, 1f);
6363
context.pose().translate(0, -32, 0);
@@ -76,7 +76,7 @@ public static void onHudRenderDummy(GuiGraphics context, float xOffset, float sc
7676
}
7777
}
7878
context.setColor(1f, 1f, 1f, 1f);
79-
context.pose().popPose();
79+
context.pose().popMatrix();
8080
}
8181

8282
private static void draw(GuiGraphics context, ResourceLocation texture, float x, float y) {

src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/BannerRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ public static void render(GuiGraphics context, float lastDur) {
4545
int x = (width/2) - (int)((24 * shieldScale)/2);
4646
int y = ((13 * height)/50) - (int)((34 * shieldScale)/2);
4747

48-
context.pose().pushPose();
48+
context.pose().pushMatrix();
4949
RenderSystem.enableBlend();
5050

5151
if (elapsed >= 0.1f) { renderParticles(context,elapsed,(width/2),height); }
5252
renderShield(context,x,y);
5353
if (elapsed >= (16f/30f)) { renderBanner(context,elapsed,width,height); }
5454

55-
context.pose().popPose();
55+
context.pose().popMatrix();
5656

5757
if (elapsed >= elapsedMax) {
5858
reset();

src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/GenericHudMod.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
77
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
88
import net.fabricmc.loader.api.FabricLoader;
9-
import net.kyrptonaught.lemclienthelper.hud.genericHud.HideVanillaHUD;
109
import net.kyrptonaught.lemclienthelper.hud.genericHud.packets.BannerPacket;
1110
import net.kyrptonaught.lemclienthelper.hud.genericHud.packets.PlayerBarPacket;
1211

@@ -45,8 +44,6 @@
4544
import wily.legacy.client.screen.compat.SodiumCompat;
4645
import wily.legacy.init.LegacyRegistries;
4746
import wily.legacy.network.TopMessage;
48-
import wily.legacy.util.MCAccount;
49-
import wily.legacy.util.ScreenUtil;
5047

5148
import java.util.Optional;
5249

@@ -64,15 +61,15 @@ public static void onInitialize() {
6461
LegacyOptions.CLIENT_STORAGE.load();
6562
UIAccessor accessor = FactoryScreenUtil.getGuiAccessor();
6663
accessor.getStaticDefinitions().add(UIDefinition.createBeforeInit((a) -> {
67-
if ((Boolean)LegacyMixinOptions.legacyGui.get()) {
64+
if (LegacyMixinOptions.legacyGui.get()) {
6865
a.getElements().put(FactoryGuiElement.EXPERIENCE_BAR.name() + ".isVisible", () -> {
69-
return HideVanillaHUD.visibe.getValue(HideVanillaHUD.HUD_ELEMENT.EXPERIENCE) && HideVanillaHUD.visibe.getValue(HideVanillaHUD.HUD_ELEMENT.STATS) && HideVanillaHUD.visibe.getValue(HideVanillaHUD.HUD_ELEMENT.ALL);
66+
return HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.EXPERIENCE, true) && HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.STATS,true) && HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.ALL, true);
7067
});
7168
a.getElements().put(FactoryGuiElement.PLAYER_HEALTH.name() + ".isVisible", () -> {
72-
return HideVanillaHUD.visibe.getValue(HideVanillaHUD.HEARTS.HOTBAR) && HideVanillaHUD.visibe.getValue(HideVanillaHUD.HUD_ELEMENT.STATS) && HideVanillaHUD.visibe.getValue(HideVanillaHUD.HUD_ELEMENT.ALL);
69+
return HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.HEARTS, true) && HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.STATS,true) && HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.ALL, true);
7370
});
7471
a.getElements().put(FactoryGuiElement.HOTBAR.name() + ".isVisible", () -> {
75-
return HideVanillaHUD.visibe.getValue(HideVanillaHUD.HUD_ELEMENT.HOTBAR) && HideVanillaHUD.visibe.getValue(HideVanillaHUD.HUD_ELEMENT.ALL);
72+
return HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.HOTBAR, true) && HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.ALL, true);
7673
});
7774
}
7875
}));
@@ -86,7 +83,7 @@ public static void onInitialize() {
8683
PayloadTypeRegistry.playS2C().register(PlayerBarPacket.PACKET_ID, PlayerBarPacket.codec);
8784
ClientPlayNetworking.registerGlobalReceiver(PlayerBarPacket.PACKET_ID, ((payload, context) -> {
8885
SHOULD_RENDER_PLAYERBAR = payload.enabled();
89-
HideVanillaHUD.visibe.put(HideVanillaHUD.HUD_ELEMENT.EXPERIENCE, !payload.enabled());
86+
HideVanillaHUD.visible.put(HideVanillaHUD.HUD_ELEMENT.EXPERIENCE, !payload.enabled());
9087
}));
9188

9289
PayloadTypeRegistry.playS2C().register(BannerPacket.PACKET_ID, BannerPacket.codec);
@@ -130,7 +127,7 @@ public static void onInitialize() {
130127
new serverInfoPackets.phasePacket(
131128
ServerInfoData.MINIGAME_PHASES.values()[IntegerArgumentType.getInteger(context,"phase")]));
132129
ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"),
133-
new BannerPacket(ComponentArgument.getComponent(context,"text"), Optional.of(FloatArgumentType.getFloat(context, "elapsedMax"))));
130+
new BannerPacket(ComponentArgument.getRawComponent(context,"text"), Optional.of(FloatArgumentType.getFloat(context, "elapsedMax"))));
134131
return 0;
135132
})).executes(context -> {
136133
ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"),
@@ -143,7 +140,7 @@ public static void onInitialize() {
143140
new serverInfoPackets.phasePacket(
144141
ServerInfoData.MINIGAME_PHASES.values()[IntegerArgumentType.getInteger(context, "phase")]));
145142
ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"),
146-
new BannerPacket(ComponentArgument.getComponent(context, "text"),Optional.empty()));
143+
new BannerPacket(ComponentArgument.getRawComponent(context, "text"),Optional.empty()));
147144
return 0;
148145
})))))))));
149146

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
package net.kyrptonaught.lemclienthelper.hud.glideHud;
1+
package net.kyrptonaught.lemclienthelper.hud.genericHud;
22

33
import java.util.HashMap;
44

5-
import net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData;
6-
import net.kyrptonaught.lemclienthelper.hud.HudMod;
7-
import net.minecraft.client.DeltaTracker;
8-
import net.minecraft.client.Minecraft;
9-
import net.minecraft.client.gui.GuiGraphics;
10-
import net.minecraft.resources.ResourceLocation;
11-
import net.minecraft.util.Mth;
12-
135
public class HideVanillaHUD {
14-
public static final enum HUD_ELEMENT {
6+
7+
/**
8+
* <pre>
9+
* ALL - All Elements
10+
* EXPERIENCE - Experience Bar/Locator Bar
11+
* HEARTS - Player health
12+
* HOTBAR - Player hotbar
13+
* HUNGER - Player hunger
14+
* STATS - EXPERIENCE, HEARTS, &, HUNGER
15+
* </pre>
16+
*/
17+
public enum HUD_ELEMENT {
1518
ALL,
1619
EXPERIENCE,
1720
HEARTS,
@@ -22,10 +25,4 @@ public static final enum HUD_ELEMENT {
2225

2326
public static HashMap<HUD_ELEMENT, Boolean> visible;
2427

25-
init {
26-
visible.clear();
27-
HUD_ELEMENT.forEach(element ->
28-
visibe.putIfAbsent(element, true)
29-
);
30-
}
3128
}

src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/HideVanillaHUDPacket.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.kyrptonaught.lemclienthelper.hud.genericHud.packets;
22

33
import net.kyrptonaught.lemclienthelper.hud.genericHud.HideVanillaHUD;
4+
import net.kyrptonaught.lemclienthelper.hud.glideHud.GlideHudMod;
45
import net.minecraft.network.RegistryFriendlyByteBuf;
56
import net.minecraft.network.chat.Component;
67
import net.minecraft.network.codec.ByteBufCodecs;
@@ -14,8 +15,8 @@
1415
/**
1516
* HideVanillaHUDPacket sends banner to client
1617
*
17-
* @param element an enumerator, HOTBAR, HEARTS, HUNGER, STATS (Hearts & Hunger), ALL (Hearts, Hunger, & Hotbar).
18-
* @param visibe boolean, Is the element visible, false for hidden, true for shown.
18+
* @param element HideVanillaHUD.HUD_ELEMENT, {@link HideVanillaHUD.HUD_ELEMENT}.
19+
* @param visible boolean, Is the element visible, false for hidden, true for shown.
1920
*/
2021
public record HideVanillaHUDPacket(HideVanillaHUD.HUD_ELEMENT element, boolean visible) implements CustomPacketPayload {
2122
public static final Type<HideVanillaHUDPacket> PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("hud", "hidevanilla"));

src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/GlideHudRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static void onHudRender(GuiGraphics context, DeltaTracker v) {
4444
int height = client.getWindow().getGuiScaledHeight();
4545
int width = client.getWindow().getGuiScaledWidth();
4646

47-
context.pose().pushPose();
47+
context.pose().pushMatrix();
4848
context.pose().translate((width - HudMod.getConfig().xOffset), height / 2f, 0);
4949
context.pose().scale(HudMod.getConfig().armorHudScale, HudMod.getConfig().armorHudScale, 1f);
5050
context.pose().translate(0, -24, 0);
@@ -54,7 +54,7 @@ public static void onHudRender(GuiGraphics context, DeltaTracker v) {
5454
renderSpeedometer(context, client);
5555
if (ServerInfoData.getGamemode() == ServerInfoData.GAME_MODES.SCORE_ATTACK) {renderScore(context, client);}
5656
context.setColor(1f, 1f, 1f, 1f);
57-
context.pose().popPose();
57+
context.pose().popMatrix();
5858
}
5959
}
6060

0 commit comments

Comments
 (0)