diff --git a/build.gradle b/build.gradle index 6e97a7f..9136d1b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.7-SNAPSHOT' + id 'fabric-loom' version "1.13-SNAPSHOT" id 'maven-publish' } @@ -21,29 +21,32 @@ loom { dependencies { // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + mappings loom.officialMojangMappings() modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation('net.kyrptonaught:kyrptconfig:1.6.1-1.21') - include('net.kyrptonaught:kyrptconfig:1.6.1-1.21') + modImplementation("net.kyrptonaught:kyrptconfig:${project.kyrptconfig_version}") + include("net.kyrptonaught:kyrptconfig:${project.kyrptconfig_version}") - modImplementation ("com.terraformersmc:modmenu:11.0.1"){ + modImplementation ("com.terraformersmc:modmenu:${project.modmenu_version}"){ transitive(false) } - modImplementation "com.ptsmods:devlogin:3.5" + modImplementation "com.ptsmods:devlogin:${project.devlogin_version}" //midnightcontrols - modImplementation "maven.modrinth:obsidianui:0.2.6+mc1.21-fabric" - modImplementation "maven.modrinth:midnightlib:1.5.7-fabric" - modImplementation "maven.modrinth:midnightcontrols:1.9.7+1.21" + modImplementation "maven.modrinth:obsidianui:${project.obsidianui_version}" + modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" + modImplementation "maven.modrinth:midnightcontrols:${project.midnightcontrols_version}" api('org.aperlambda:lambdajcommon:1.8.1') { exclude group: 'com.google.code.gson' exclude group: 'com.google.guava' } + + modCompileOnly("maven.modrinth:legacy4j:${project.legacy4j_version}") + modCompileOnly("maven.modrinth:factory-api:${project.factoryapi_version}") } base { diff --git a/gradle.properties b/gradle.properties index 8e47d61..d1bb2b4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,27 @@ org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true +# Loom Properties +loom_version=1.13-SNAPSHOT + # Fabric Properties -minecraft_version=1.21 -yarn_mappings=1.21+build.2 -loader_version=0.15.11 +minecraft_version=1.21.10 +loader_version=0.17.3 # Fabric API -fabric_version=0.100.4+1.21 +fabric_version=0.138.3+1.21.10 # Mod Properties -mod_version=0.0.27-1.21 +mod_version=0.0.28-1.21.10 maven_group=net.kyrptonaught -archives_base_name=lemclienthelper \ No newline at end of file +archives_base_name=lemclienthelper + +# Dependency Properties +kyrptconfig_version=1.6.1-1.21.4 +modmenu_version=16.0.0-rc.1 +devlogin_version=3.5 +obsidianui_version=0.2.12+mc1.21.6-fabric +midnightlib_version=1.8.3+1.21.9-fabric +midnightcontrols_version=1.11.3-beta.3-fabric +legacy4j_version=1.21.10-1.8.5.2545.5+fabric +factoryapi_version=1.21.10-2.2.6.2545.1+fabric diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..8bdaf60 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index dab2a01..6d023f1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataMod.java index 09ede56..17c84a3 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataMod.java @@ -12,8 +12,13 @@ public static boolean isOptifineLoaded(FabricLoader loader) { return loader.isModLoaded("optifabric") || loader.isModLoaded("optifine"); } + public static boolean isL4JLoaded(FabricLoader loader) { + return loader.isModLoaded("legacy"); + } + public static boolean isControllerModLoaded(FabricLoader loader) { return loader.isModLoaded("midnightcontrols") || + // loader.isModLoaded("legacy") || // Should L4J be counted as a controller mod? loader.isModLoaded("lambdacontrols") || loader.isModLoaded("controllable") || loader.isModLoaded("controllermod"); diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataNetworking.java b/src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataNetworking.java index 3713bd1..4e7c877 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataNetworking.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/ClientData/ClientDataNetworking.java @@ -6,13 +6,13 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking; import net.fabricmc.loader.api.FabricLoader; import net.kyrptonaught.lemclienthelper.ServerConfigs.ServerConfigsMod; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.util.Identifier; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; import java.util.concurrent.CompletableFuture; public class ClientDataNetworking { - public static final Identifier HAS_MODS_PACKET = Identifier.of("scoreboardplayerinfo", "has_mods_packet"); + public static final ResourceLocation HAS_MODS_PACKET = ResourceLocation.fromNamespaceAndPath("scoreboardplayerinfo", "has_mods_packet"); @Environment(EnvType.CLIENT) @@ -20,10 +20,16 @@ public static void sendHasLEMPacket() { ClientLoginNetworking.registerGlobalReceiver(HAS_MODS_PACKET, (client, handler, buf, listenerAdder) -> { FabricLoader loader = FabricLoader.getInstance(); - PacketByteBuf respondeBuf = new PacketByteBuf(Unpooled.buffer()); + FriendlyByteBuf respondeBuf = new FriendlyByteBuf(Unpooled.buffer()); respondeBuf.writeBoolean(true); //LEMClientHelper, Always true + // TODO: Start sending LCH version, this can help when diagnosing issues caused by differences between + // server Heirloom ver and client LCH ver. + // respondeBuf.writeString(LEMClientHelperMod.MOD_VERSION); respondeBuf.writeBoolean(ClientDataMod.isOptifineLoaded(loader)); respondeBuf.writeBoolean(ClientDataMod.isControllerModLoaded(loader)); + // TODO: Send L4J info, + // (Note, probably should also send version for this, as L4J tends to change alot update to update.) + // respondeBuf.writeBoolean(ClientDataMod.isL4JLoaded(loader)); respondeBuf.writeInt(ServerConfigsMod.getConfig().guiScale); respondeBuf.writeInt(ServerConfigsMod.getConfig().panScale); diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/LEMClientHelperMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/LEMClientHelperMod.java index 831706c..41e221c 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/LEMClientHelperMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/LEMClientHelperMod.java @@ -7,17 +7,22 @@ import net.kyrptonaught.lemclienthelper.ClientData.ClientDataMod; import net.kyrptonaught.lemclienthelper.ResourcePreloader.ResourcePreloaderMod; import net.kyrptonaught.lemclienthelper.ServerConfigs.ServerConfigsMod; +import net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoMod; import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvMod; import net.kyrptonaught.lemclienthelper.SpectateSqueaker.SpectateSqueakerMod; import net.kyrptonaught.lemclienthelper.TakeEverything.TakeEverythingMod; import net.kyrptonaught.lemclienthelper.customWorldBorder.CustomWorldBorderMod; import net.kyrptonaught.lemclienthelper.hud.HudMod; import net.kyrptonaught.lemclienthelper.syncedKeybinds.SyncedKeybindsMod; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; +import net.minecraft.client.KeyMapping; +import com.mojang.blaze3d.platform.InputConstants; public class LEMClientHelperMod implements ClientModInitializer { public static final String MOD_ID = "lemclienthelper"; + + //TODO Find a better way to get this value. + public static final String MOD_VERSION = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow().getMetadata().getVersion().getFriendlyString(); + public static ConfigManager.MultiConfigManager configManager = new ConfigManager.MultiConfigManager(MOD_ID); @@ -27,6 +32,7 @@ public void onInitializeClient() { ResourcePreloaderMod.onInitialize(); SmallInvMod.onInitialize(); ClientDataMod.onInitialize(); + ServerInfoMod.onInitialize(); SyncedKeybindsMod.onInitialize(); SpectateSqueakerMod.onInitialize(); ServerConfigsMod.onInitialize(); @@ -43,14 +49,14 @@ public static void registerControllerKeys() { TakeEverythingMod.registerControllerKeys(); } - public static boolean isKeybindPressed(KeyBinding keyBinding, int pressedKeyCode, boolean isMouse) { - InputUtil.Key keycode = KeyBindingHelper.getBoundKeyOf(keyBinding); + public static boolean isKeybindPressed(KeyMapping keyBinding, int pressedKeyCode, boolean isMouse) { + InputConstants.Key keycode = KeyBindingHelper.getBoundKeyOf(keyBinding); if (isMouse) { - if (keycode.getCategory() != InputUtil.Type.MOUSE) return false; + if (keycode.getType() != InputConstants.Type.MOUSE) return false; } else { - if (keycode.getCategory() != InputUtil.Type.KEYSYM) return false; + if (keycode.getType() != InputConstants.Type.KEYSYM) return false; } - return keycode.getCode() == pressedKeyCode; + return keycode.getValue() == pressedKeyCode; } } \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/AllPacks.java b/src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/AllPacks.java index be8c125..7ff5d3c 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/AllPacks.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/AllPacks.java @@ -1,6 +1,6 @@ package net.kyrptonaught.lemclienthelper.ResourcePreloader; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; @@ -14,8 +14,8 @@ public static class RPOption { public String url; public UUID uuid; - public Text status; - public Text status2; + public Component status; + public Component status2; } } \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/ResourcePreloaderMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/ResourcePreloaderMod.java index 0621e1e..07e9130 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/ResourcePreloaderMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/ResourcePreloader/ResourcePreloaderMod.java @@ -2,20 +2,20 @@ import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; +import com.mojang.realmsclient.Unit; import com.mojang.util.UndashedUuid; import net.kyrptonaught.jankson.Jankson; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; -import net.minecraft.GameVersion; import net.minecraft.SharedConstants; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.realms.SizeUnit; -import net.minecraft.client.session.Session; -import net.minecraft.client.toast.SystemToast; -import net.minecraft.resource.ResourceType; -import net.minecraft.text.Text; -import net.minecraft.util.NetworkUtils; -import net.minecraft.util.Util; -import net.minecraft.util.path.CacheFiles; +import net.minecraft.WorldVersion; +import net.minecraft.client.Minecraft; +import net.minecraft.client.User; +import net.minecraft.client.gui.components.toasts.SystemToast; +import net.minecraft.network.chat.Component; +import net.minecraft.server.packs.DownloadCacheCleaner; +import net.minecraft.server.packs.PackType; +import net.minecraft.util.HttpUtil; +import net.minecraft.Util; import java.io.InputStream; import java.net.Proxy; @@ -61,18 +61,18 @@ public static void getPackList() { } public static void downloadPacks() { - Path downloadsDirectory = MinecraftClient.getInstance().runDirectory.toPath().resolve("downloads"); + Path downloadsDirectory = Minecraft.getInstance().gameDirectory.toPath().resolve("downloads"); HashFunction SHA1 = Hashing.sha1(); - Map headers = getHeaders(MinecraftClient.getInstance().getSession()); - Proxy proxy = MinecraftClient.getInstance().getNetworkProxy(); + Map headers = getHeaders(Minecraft.getInstance().getUser()); + Proxy proxy = Minecraft.getInstance().getProxy(); AtomicInteger counter = new AtomicInteger(allPacks.packs.size()); for (AllPacks.RPOption rpOption : allPacks.packs) { if (!checkPack(rpOption.uuid)) { - Util.getDownloadWorkerExecutor().execute(() -> downloadPack(rpOption, downloadsDirectory, SHA1, headers, proxy, () -> { + Util.nonCriticalIoPool().execute(() -> downloadPack(rpOption, downloadsDirectory, SHA1, headers, proxy, () -> { counter.getAndDecrement(); if (counter.get() <= 0 && getConfig().toastComplete) { - SystemToast.add(MinecraftClient.getInstance().getToastManager(), SystemToast.Type.PERIODIC_NOTIFICATION, Text.translatable("key.lemclienthelper.alldownloadcomplete"), null); + SystemToast.add(Minecraft.getInstance().getToastManager(), SystemToast.SystemToastId.PERIODIC_NOTIFICATION, Component.translatable("key.lemclienthelper.alldownloadcomplete"), null); } })); } @@ -81,21 +81,21 @@ public static void downloadPacks() { public static void downloadPack(AllPacks.RPOption rpOption, Path downloadsDirectory, HashFunction SHA1, Map headers, Proxy proxy, Runnable onComplete) { try { - NetworkUtils.download(downloadsDirectory.resolve(rpOption.uuid.toString()), new URL(rpOption.url), headers, SHA1, null, 0xFA00000, proxy, createListener(rpOption, onComplete)); + HttpUtil.downloadFile(downloadsDirectory.resolve(rpOption.uuid.toString()), new URL(rpOption.url), headers, SHA1, null, 0xFA00000, proxy, createListener(rpOption, onComplete)); } catch (Exception e) { e.printStackTrace(); - setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloaderror"), null); + setStatus(rpOption.uuid, Component.translatable("key.lemclienthelper.downloaderror"), null); } } public static void deletePacks() { - CacheFiles.clear(MinecraftClient.getInstance().runDirectory.toPath().resolve("downloads"), 0); + DownloadCacheCleaner.vacuumCacheDir(Minecraft.getInstance().gameDirectory.toPath().resolve("downloads"), 0); } private static boolean checkPack(UUID packID) { - Path downloadsDirectory = MinecraftClient.getInstance().runDirectory.toPath().resolve("downloads"); + Path downloadsDirectory = Minecraft.getInstance().gameDirectory.toPath().resolve("downloads"); if (Files.exists(downloadsDirectory.resolve(packID.toString()))) { - setStatus(packID, Text.translatable("key.lemclienthelper.alreadydownloaded"), null); + setStatus(packID, Component.translatable("key.lemclienthelper.alreadydownloaded"), null); return true; } @@ -103,7 +103,7 @@ private static boolean checkPack(UUID packID) { return false; } - public static void setStatus(UUID packID, Text status, Text status2) { + public static void setStatus(UUID packID, Component status, Component status2) { for (AllPacks.RPOption rpOption : allPacks.packs) { if (rpOption.uuid == packID) { rpOption.status = status; @@ -112,41 +112,41 @@ public static void setStatus(UUID packID, Text status, Text status2) { } } - private static Map getHeaders(Session session) { - GameVersion gameVersion = SharedConstants.getGameVersion(); - return Map.of("X-Minecraft-Username", session.getUsername(), "X-Minecraft-UUID", UndashedUuid.toString(session.getUuidOrNull()), "X-Minecraft-Version", gameVersion.getName(), "X-Minecraft-Version-ID", gameVersion.getId(), "X-Minecraft-Pack-Format", String.valueOf(gameVersion.getResourceVersion(ResourceType.CLIENT_RESOURCES)), "User-Agent", "Minecraft Java/" + gameVersion.getName()); + private static Map getHeaders(User session) { + WorldVersion gameVersion = SharedConstants.getCurrentVersion(); + 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()); } - private static NetworkUtils.DownloadListener createListener(AllPacks.RPOption rpOption, Runnable onComplete) { - return new NetworkUtils.DownloadListener() { + private static HttpUtil.DownloadProgressListener createListener(AllPacks.RPOption rpOption, Runnable onComplete) { + return new HttpUtil.DownloadProgressListener() { private OptionalLong contentLength = OptionalLong.empty(); - private Text getProgress(long writtenBytes) { - return this.contentLength.isPresent() ? Text.translatable("download.pack.progress.percent", writtenBytes * 100L / this.contentLength.getAsLong()) : Text.translatable("download.pack.progress.bytes", SizeUnit.getUserFriendlyString(writtenBytes)); + private Component getProgress(long writtenBytes) { + return this.contentLength.isPresent() ? Component.translatable("download.pack.progress.percent", writtenBytes * 100L / this.contentLength.getAsLong()) : Component.translatable("download.pack.progress.bytes", Unit.humanReadable(writtenBytes)); } @Override - public void onStart() { - setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloading"), null); + public void requestStart() { + setStatus(rpOption.uuid, Component.translatable("key.lemclienthelper.downloading"), null); } @Override - public void onContentLength(OptionalLong contentLength) { + public void downloadStart(OptionalLong contentLength) { this.contentLength = contentLength; - setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloading"), getProgress(0L)); + setStatus(rpOption.uuid, Component.translatable("key.lemclienthelper.downloading"), getProgress(0L)); } @Override - public void onProgress(long writtenBytes) { - setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloading"), getProgress(writtenBytes)); + public void downloadedBytes(long writtenBytes) { + setStatus(rpOption.uuid, Component.translatable("key.lemclienthelper.downloading"), getProgress(writtenBytes)); } @Override - public void onFinish(boolean success) { + public void requestFinished(boolean success) { if (!success) { - setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloaderror"), null); + setStatus(rpOption.uuid, Component.translatable("key.lemclienthelper.downloaderror"), null); } else { - setStatus(rpOption.uuid, Text.translatable("key.lemclienthelper.downloadcomplete"), null); + setStatus(rpOption.uuid, Component.translatable("key.lemclienthelper.downloadcomplete"), null); } onComplete.run(); } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoData.java b/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoData.java new file mode 100644 index 0000000..c8a8db3 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoData.java @@ -0,0 +1,112 @@ +package net.kyrptonaught.lemclienthelper.ServerInfo; + +public class ServerInfoData { + private static GAME_MODES GAME_MODE = GAME_MODES.CASUAL; + private static MINIGAME_TYPES MINIGAME = MINIGAME_TYPES.BATTLE; + private static MINIGAME_PHASES PHASE = MINIGAME_PHASES.NONE; + + private static byte[] PLAYER_STATUS = new byte[]{1,0,1,1,1,0,-1,-1}; + + /** + * Minigame types + *
    + *
  • BATTLE + *
  • TUMBLE + *
  • GLIDE + *
+ */ + public enum MINIGAME_TYPES { + BATTLE, + TUMBLE, + GLIDE, + } + + /** + * Gamemodes types + * + *
    + *
  • CUSTOM + *
+ * Battle specific: + *
    + *
  • CASUAL + *
  • COMPETITIVE + *
+ * Tumble specific: + *
    + *
  • SNOWBALLS + *
  • SHOVELS + *
  • MIXED + *
+ * Glide specific: + *
    + *
  • TIME_ATTACK + *
  • SCORE_ATTACK + *
+ */ + public enum GAME_MODES { + CUSTOM, + + CASUAL, + COMPETITIVE, + + SNOWBALLS, + SHOVELS, + MIXED, + + TIME_ATTACK, + SCORE_ATTACK + } + + /** + * Minigame phase + *
    + *
  • NONE + *
  • LOADING + *
  • COUNTDOWN + *
  • RUNNING + *
  • SHOWDOWN + *
  • END + *
+ */ + public enum MINIGAME_PHASES { + NONE, + LOADING, + COUNTDOWN, + RUNNING, + SHOWDOWN, + END + } + + public static void setMinigame(MINIGAME_TYPES minigame) { + MINIGAME = minigame; + } + + public static MINIGAME_TYPES getMinigame() { + return MINIGAME; + } + + public static void setGamemode(GAME_MODES gameMode) { + GAME_MODE = gameMode; + } + + public static GAME_MODES getGamemode() { + return GAME_MODE; + } + + public static void setPhase(MINIGAME_PHASES phase) { + PHASE = phase; + } + + public static MINIGAME_PHASES getPhase() { + return PHASE; + } + + public static void setPlayerStatus(byte[] playerStatus) { + PLAYER_STATUS = playerStatus; + } + + public static byte[] getPlayerStatus() { + return PLAYER_STATUS; + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoMod.java new file mode 100644 index 0000000..a90bc39 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoMod.java @@ -0,0 +1,10 @@ +package net.kyrptonaught.lemclienthelper.ServerInfo; + +/** + * Any and all information that could possibly be used by the client, not tied to rendering. + */ +public class ServerInfoMod { + public static void onInitialize() { + ServerInfoNetworking.onInitialize(); + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoNetworking.java b/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoNetworking.java new file mode 100644 index 0000000..d9d8888 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/ServerInfoNetworking.java @@ -0,0 +1,44 @@ +package net.kyrptonaught.lemclienthelper.ServerInfo; + +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import net.kyrptonaught.lemclienthelper.ServerInfo.packets.serverInfoPackets; + +public class ServerInfoNetworking { + public static void onInitialize() { + PayloadTypeRegistry.playS2C().register(serverInfoPackets.serverInfoPacket.PACKET_ID, serverInfoPackets.serverInfoPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(serverInfoPackets.serverInfoPacket.PACKET_ID, ((payload, context) -> { + ServerInfoData.setMinigame(payload.minigame()); + ServerInfoData.setGamemode(payload.gamemode()); + ServerInfoData.setPhase(payload.phase()); + ServerInfoData.setPlayerStatus(payload.playerStatus()); + })); + + PayloadTypeRegistry.playS2C().register(serverInfoPackets.minigamePacket.PACKET_ID, serverInfoPackets.minigamePacket.codec); + ClientPlayNetworking.registerGlobalReceiver(serverInfoPackets.minigamePacket.PACKET_ID, ((payload, context) -> ServerInfoData.setMinigame(payload.minigame()))); + + PayloadTypeRegistry.playS2C().register(serverInfoPackets.gamemodePacket.PACKET_ID, serverInfoPackets.gamemodePacket.codec); + ClientPlayNetworking.registerGlobalReceiver(serverInfoPackets.gamemodePacket.PACKET_ID, ((payload, context) -> ServerInfoData.setGamemode(payload.gamemode()))); + + PayloadTypeRegistry.playS2C().register(serverInfoPackets.phasePacket.PACKET_ID, serverInfoPackets.phasePacket.codec); + ClientPlayNetworking.registerGlobalReceiver(serverInfoPackets.phasePacket.PACKET_ID, ((payload, context) -> ServerInfoData.setPhase(payload.phase()))); + + PayloadTypeRegistry.playS2C().register(serverInfoPackets.playerStatusPacket.PACKET_ID, serverInfoPackets.playerStatusPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(serverInfoPackets.serverInfoPacket.PACKET_ID, ((payload, context) -> ServerInfoData.setPlayerStatus(payload.playerStatus()))); + + PayloadTypeRegistry.playS2C().register(serverInfoPackets.serverInfoIndicesPacket.PACKET_ID, serverInfoPackets.serverInfoIndicesPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(serverInfoPackets.serverInfoIndicesPacket.PACKET_ID, ((payload, context) -> { + ServerInfoData.setMinigame(ServerInfoData.MINIGAME_TYPES.values()[payload.minigame()]); + ServerInfoData.setGamemode(ServerInfoData.GAME_MODES.values()[payload.gamemode()]); + ServerInfoData.setPhase(ServerInfoData.MINIGAME_PHASES.values()[payload.phase()]); + ServerInfoData.setPlayerStatus(payload.playerStatus()); + })); + + PayloadTypeRegistry.playS2C().register(serverInfoPackets.gamemodeIndexPacket.PACKET_ID, serverInfoPackets.gamemodeIndexPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(serverInfoPackets.gamemodeIndexPacket.PACKET_ID, ((payload, context) -> ServerInfoData.setGamemode(ServerInfoData.GAME_MODES.values()[payload.gamemode()]))); + + PayloadTypeRegistry.playS2C().register(serverInfoPackets.phaseIndexPacket.PACKET_ID, serverInfoPackets.phaseIndexPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(serverInfoPackets.phaseIndexPacket.PACKET_ID, ((payload, context) -> ServerInfoData.setPhase(ServerInfoData.MINIGAME_PHASES.values()[payload.phase()]))); + + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/packets/serverInfoPackets.java b/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/packets/serverInfoPackets.java new file mode 100644 index 0000000..0689171 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/ServerInfo/packets/serverInfoPackets.java @@ -0,0 +1,175 @@ +package net.kyrptonaught.lemclienthelper.ServerInfo.packets; + +import net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +public class serverInfoPackets { + /** + *
serverInfoPacket, sends all information to client
+     *
+     * See Example Packet,
+     * Casual Battle game, in the lobby, w/ 4 players, 2 are not ready.
+     *
+     * 
+     * new serverInfoPacket(
+     *      ServerInfoData.MINIGAME_TYPES.BATTLE,
+     *      ServerInfoData.GAME_MODES.CASUAL,
+     *      ServerInfoData.MINIGAME_PHASES.NONE,
+     *      new byte[]{0,0,1,1}
+     * );
+     * 
+ * + * @param minigame {@link ServerInfoData.MINIGAME_TYPES}. Minigame the client is in. + * + * @param gamemode {@link ServerInfoData.GAME_MODES}. Gamemode the game is in. + * + * @param phase {@link ServerInfoData.MINIGAME_PHASES}, Phase the game is in. + * + * @param playerStatus byte[], -1 — Spectating; 0 — Dead/Not Ready; 1 — Alive/Ready; + * + * @see gamemodePacket gamemodePacket + * @see playerStatusPacket playerStatusPacket + * @see phasePacket phasePacket + */ + public record serverInfoPacket(ServerInfoData.MINIGAME_TYPES minigame, ServerInfoData.GAME_MODES gamemode, ServerInfoData.MINIGAME_PHASES phase, byte[] playerStatus) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("serverinfo", "serverinfo_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.idMapper(i -> ServerInfoData.MINIGAME_TYPES.values()[i], ServerInfoData.MINIGAME_TYPES::ordinal), serverInfoPacket::minigame, + ByteBufCodecs.idMapper(i -> ServerInfoData.GAME_MODES.values()[i], ServerInfoData.GAME_MODES::ordinal), serverInfoPacket::gamemode, + ByteBufCodecs.idMapper(i -> ServerInfoData.MINIGAME_PHASES.values()[i], ServerInfoData.MINIGAME_PHASES::ordinal), serverInfoPacket::phase, + ByteBufCodecs.BYTE_ARRAY, serverInfoPacket::playerStatus, + serverInfoPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } + public record serverInfoIndicesPacket(int minigame, int gamemode, int phase, byte[] playerStatus) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("serverinfo", "serverinfo_indices_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.INT, serverInfoIndicesPacket::minigame, + ByteBufCodecs.INT, serverInfoIndicesPacket::gamemode, + ByteBufCodecs.INT, serverInfoIndicesPacket::phase, + ByteBufCodecs.BYTE_ARRAY, serverInfoIndicesPacket::playerStatus, + serverInfoIndicesPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } + + /** + * minigamePacket, sends minigame to client + * + * @param minigame {@link ServerInfoData.MINIGAME_TYPES}. Minigame the client is in. + * + * @deprecated Minigame should not be changed after {@link serverInfoPacket serverInfoPacket} is sent. + * @see serverInfoPacket serverInfoPacket + */ + @SuppressWarnings("DeprecatedIsStillUsed") + @Deprecated + public record minigamePacket(ServerInfoData.MINIGAME_TYPES minigame) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("serverinfo", "minigame_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.idMapper(i -> ServerInfoData.MINIGAME_TYPES.values()[i], ServerInfoData.MINIGAME_TYPES::ordinal), minigamePacket::minigame, + minigamePacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } + + /** + *
gamemodePacket, sends gamemode to client
+     * Intended for use when not in round.
+ * + * @param gamemode {@link ServerInfoData.GAME_MODES}. Gamemode the client is in. + * + */ + public record gamemodePacket(ServerInfoData.GAME_MODES gamemode) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("serverinfo", "gamemode_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.idMapper(i -> ServerInfoData.GAME_MODES.values()[i], ServerInfoData.GAME_MODES::ordinal), gamemodePacket::gamemode, + gamemodePacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } + public record gamemodeIndexPacket(int gamemode) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("serverinfo", "gamemode_index_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.INT, gamemodeIndexPacket::gamemode, + gamemodeIndexPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } + + /** + * phasePacket, sends phase to client + * + * @param phase {@link ServerInfoData.MINIGAME_PHASES}. Phase the game is in. + * + */ + public record phasePacket(ServerInfoData.MINIGAME_PHASES phase) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("serverinfo", "phase_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.idMapper(i -> ServerInfoData.MINIGAME_PHASES.values()[i], ServerInfoData.MINIGAME_PHASES::ordinal), phasePacket::phase, + phasePacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } + public record phaseIndexPacket(int phase) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("serverinfo", "phase_index_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.INT, phaseIndexPacket::phase, + phaseIndexPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } + + /** + *
playerStatusPacket, sends player statuses to client.
+     *
+     * new byte[]{0,1,0,-1} 4 players, players 1 & 3 are either not ready or dead, player 4 is spectating.
+     * 
+ * + * @param playerStatus byte[], -1 — Spectating; 0 — Dead/Not Ready; 1 — Alive/Ready; + */ + public record playerStatusPacket(byte[] playerStatus) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("serverinfo", "playerstatus_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.BYTE_ARRAY, playerStatusPacket::playerStatus, + playerStatusPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/ExtendedSlot.java b/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/ExtendedSlot.java index 9697b1d..294fc4a 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/ExtendedSlot.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/ExtendedSlot.java @@ -1,12 +1,10 @@ package net.kyrptonaught.lemclienthelper.SmallInv; -import com.mojang.datafixers.util.Pair; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.slot.Slot; -import net.minecraft.util.Identifier; -import org.jetbrains.annotations.Nullable; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; import java.util.Optional; @@ -14,97 +12,96 @@ public class ExtendedSlot extends Slot { private final Slot baseSlot; public ExtendedSlot(Slot slot) { - super(slot.inventory, slot.getIndex(), slot.x, slot.y); + super(slot.container, slot.getContainerSlot(), slot.x, slot.y); baseSlot = slot; - this.id = slot.id; + this.index = slot.index; } - public void onQuickTransfer(ItemStack newItem, ItemStack original) { - baseSlot.onQuickTransfer(newItem, original); + public void onQuickCraft(ItemStack newItem, ItemStack original) { + baseSlot.onQuickCraft(newItem, original); } - protected void onCrafted(ItemStack stack, int amount) { - super.onCrafted(stack, amount); + protected void onQuickCraft(ItemStack stack, int amount) { + super.onQuickCraft(stack, amount); } - protected void onTake(int amount) { - super.onTake(amount); + protected void onSwapCraft(int amount) { + super.onSwapCraft(amount); } - protected void onCrafted(ItemStack stack) { - super.onCrafted(stack); + protected void checkTakeAchievements(ItemStack stack) { + super.checkTakeAchievements(stack); } - public void onTakeItem(PlayerEntity player, ItemStack stack) { - baseSlot.onTakeItem(player, stack); + public void onTake(Player player, ItemStack stack) { + baseSlot.onTake(player, stack); } - public boolean canInsert(ItemStack stack) { - return baseSlot.canInsert(stack); + public boolean mayPlace(ItemStack stack) { + return baseSlot.mayPlace(stack); } - public ItemStack getStack() { - return baseSlot.getStack(); + public ItemStack getItem() { + return baseSlot.getItem(); } - public boolean hasStack() { - return baseSlot.hasStack(); + public boolean hasItem() { + return baseSlot.hasItem(); } - public void setStack(ItemStack stack) { - baseSlot.setStack(stack); + public void setByPlayer(ItemStack stack) { + baseSlot.setByPlayer(stack); } - public void markDirty() { - baseSlot.markDirty(); + public void setChanged() { + baseSlot.setChanged(); } - public int getMaxItemCount() { - return baseSlot.getMaxItemCount(); + public int getMaxStackSize() { + return baseSlot.getMaxStackSize(); } - public int getMaxItemCount(ItemStack stack) { - return baseSlot.getMaxItemCount(stack); + public int getMaxStackSize(ItemStack stack) { + return baseSlot.getMaxStackSize(stack); } - @Nullable - public Pair getBackgroundSprite() { - return baseSlot.getBackgroundSprite(); + public ResourceLocation getNoItemIcon() { + return baseSlot.getNoItemIcon(); } - public ItemStack takeStack(int amount) { - return baseSlot.takeStack(amount); + public ItemStack remove(int amount) { + return baseSlot.remove(amount); } - public boolean canTakeItems(PlayerEntity playerEntity) { - return baseSlot.canTakeItems(playerEntity); + public boolean mayPickup(Player playerEntity) { + return baseSlot.mayPickup(playerEntity); } - public boolean isEnabled() { - return baseSlot.isEnabled(); + public boolean isActive() { + return baseSlot.isActive(); } - public Optional tryTakeStackRange(int min, int max, PlayerEntity player) { - return baseSlot.tryTakeStackRange(min, max, player); + public Optional tryRemove(int min, int max, Player player) { + return baseSlot.tryRemove(min, max, player); } - public ItemStack takeStackRange(int min, int max, PlayerEntity player) { - return baseSlot.takeStackRange(min, max, player); + public ItemStack safeTake(int min, int max, Player player) { + return baseSlot.safeTake(min, max, player); } - public ItemStack insertStack(ItemStack stack) { - return baseSlot.insertStack(stack); + public ItemStack safeInsert(ItemStack stack) { + return baseSlot.safeInsert(stack); } - public ItemStack insertStack(ItemStack stack, int count) { - return baseSlot.insertStack(stack, count); + public ItemStack safeInsert(ItemStack stack, int count) { + return baseSlot.safeInsert(stack, count); } - public boolean canTakePartial(PlayerEntity player) { - return baseSlot.canTakePartial(player); + public boolean allowModification(Player player) { + return baseSlot.allowModification(player); } - public int getIndex() { - return baseSlot.getIndex(); + public int getContainerSlot() { + return baseSlot.getContainerSlot(); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/MovableSlot.java b/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/MovableSlot.java index 604cb64..cb1b0dd 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/MovableSlot.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/MovableSlot.java @@ -1,6 +1,6 @@ package net.kyrptonaught.lemclienthelper.SmallInv; -import net.minecraft.screen.slot.Slot; +import net.minecraft.world.inventory.Slot; public class MovableSlot extends ExtendedSlot { public boolean isEnabled = true; @@ -11,8 +11,8 @@ public MovableSlot(Slot slot) { } @Override - public boolean isEnabled() { - return isEnabled && super.isEnabled(); + public boolean isActive() { + return isEnabled && super.isActive(); } public void setPos(int x, int y) { diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/SmallInvMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/SmallInvMod.java index e665e72..9aa34a5 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/SmallInvMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/SmallInv/SmallInvMod.java @@ -1,15 +1,16 @@ package net.kyrptonaught.lemclienthelper.SmallInv; +import com.mojang.blaze3d.platform.InputConstants; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Pair; +import net.minecraft.client.KeyMapping; +import net.minecraft.core.component.DataComponents; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Items; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import org.lwjgl.glfw.GLFW; +import oshi.util.tuples.Pair; import java.util.HashMap; @@ -18,12 +19,12 @@ public class SmallInvMod { public static String MOD_ID = "smallinv"; public static HashMap> SMALLINVSLOTS = new HashMap<>(); - public static KeyBinding closeSmallInvKey; + public static KeyMapping closeSmallInvKey; public static void onInitialize() { LEMClientHelperMod.configManager.registerFile(MOD_ID, new SmallInvConfig()); LEMClientHelperMod.configManager.load(MOD_ID); - closeSmallInvKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(LEMClientHelperMod.MOD_ID + ".key.closesmallinv", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_I, "key.category." + LEMClientHelperMod.MOD_ID)); + 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")))); registerSmallSlot(5, 55, 9); registerSmallSlot(6, 55, 27); @@ -45,12 +46,12 @@ public static SmallInvConfig getConfig() { return (SmallInvConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); } - public static boolean isSmallInv(PlayerEntity player) { + public static boolean isSmallInv(Player player) { //if (true) return true; // force enabling for testing if (!getConfig().enabled) return false; //give @p knowledge_book{display:{Name:'{"text":" "}'},SmallInv:1,CustomModelData:1} - for (ItemStack itemStack : player.getInventory().main) { + for (ItemStack itemStack : player.getInventory().getNonEquipmentItems()) { if (isSmallSlot(itemStack)) return true; } @@ -58,9 +59,9 @@ public static boolean isSmallInv(PlayerEntity player) { } public static void tryMoveSlot(MovableSlot slot) { - if (SMALLINVSLOTS.containsKey(slot.id)) { - Pair pos = SMALLINVSLOTS.get(slot.id); - slot.setPos(pos.getLeft(), pos.getRight()); + if (SMALLINVSLOTS.containsKey(slot.index)) { + Pair pos = SMALLINVSLOTS.get(slot.index); + slot.setPos(pos.getA(), pos.getB()); slot.isEnabled = true; } else slot.isEnabled = false; } @@ -70,19 +71,19 @@ private static void registerSmallSlot(int id, int x, int y) { } public static boolean isKeybindPressed(int pressedKeyCode, boolean isMouse) { - InputUtil.Key keycode = KeyBindingHelper.getBoundKeyOf(closeSmallInvKey); + InputConstants.Key keycode = KeyBindingHelper.getBoundKeyOf(closeSmallInvKey); if (isMouse) { - if (keycode.getCategory() != InputUtil.Type.MOUSE) return false; + if (keycode.getType() != InputConstants.Type.MOUSE) return false; } else { - if (keycode.getCategory() != InputUtil.Type.KEYSYM) return false; + if (keycode.getType() != InputConstants.Type.KEYSYM) return false; } - return keycode.getCode() == pressedKeyCode; + return keycode.getValue() == pressedKeyCode; } public static boolean isSmallSlot(ItemStack stack) { - return stack.isOf(Items.KNOWLEDGE_BOOK) && - stack.contains(DataComponentTypes.CUSTOM_DATA) && - stack.get(DataComponentTypes.CUSTOM_DATA).contains("SmallInv"); + return stack.is(Items.KNOWLEDGE_BOOK) && + stack.has(DataComponents.CUSTOM_DATA) && + stack.getOrDefault(DataComponents.CUSTOM_DATA,null).copyTag().contains("SmallInv"); } } \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/SpectateSqueaker/SqueakPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/SpectateSqueaker/SqueakPacket.java index 86ae8bc..1930bee 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/SpectateSqueaker/SqueakPacket.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/SpectateSqueaker/SqueakPacket.java @@ -1,17 +1,17 @@ package net.kyrptonaught.lemclienthelper.SpectateSqueaker; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; -public record SqueakPacket(boolean enabled) implements CustomPayload { - public static final Id PACKET_ID = new Id<>(Identifier.of(SpectateSqueakerMod.MOD_ID, "squeak_packet")); - public static final PacketCodec codec = PacketCodecs.BOOL.xmap(SqueakPacket::new, SqueakPacket::enabled).cast(); +public record SqueakPacket(boolean enabled) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath(SpectateSqueakerMod.MOD_ID, "squeak_packet")); + public static final StreamCodec codec = ByteBufCodecs.BOOL.map(SqueakPacket::new, SqueakPacket::enabled).cast(); @Override - public Id getId() { + public Type type() { return PACKET_ID; } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingMod.java index 96cf492..e127c3b 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingMod.java @@ -1,16 +1,16 @@ package net.kyrptonaught.lemclienthelper.TakeEverything; +import com.mojang.blaze3d.platform.InputConstants; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.kyrptonaught.kyrptconfig.config.NonConflicting.NonConflictingKeyBinding; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; +import net.minecraft.client.KeyMapping; public class TakeEverythingMod { public static String MOD_ID = "take_everything"; - public static KeyBinding takeEverythingKey; + public static KeyMapping takeEverythingKey; public static void onInitialize() { LEMClientHelperMod.configManager.registerFile(MOD_ID, new TakeEverythingConfig()); @@ -33,7 +33,7 @@ public static void registerControllerKeys() { LambdControlsCompat.register(); } - public static boolean isKeybindPressed(int pressedKeyCode, InputUtil.Type type) { + public static boolean isKeybindPressed(int pressedKeyCode, InputConstants.Type type) { return getConfig().keybinding.matches(pressedKeyCode, type); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingPacket.java index 649df14..7fe5420 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingPacket.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/TakeEverything/TakeEverythingPacket.java @@ -1,17 +1,18 @@ package net.kyrptonaught.lemclienthelper.TakeEverything; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; -public record TakeEverythingPacket(boolean enabled) implements CustomPayload { - public static final Id PACKET_ID = new Id<>(Identifier.of("takeeverything", "take_everything_packet")); - public static final PacketCodec codec = PacketCodecs.BOOL.xmap(TakeEverythingPacket::new, TakeEverythingPacket::enabled).cast(); +public record TakeEverythingPacket(boolean enabled) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("takeeverything", "take_everything_packet")); + public static final StreamCodec codec = ByteBufCodecs.BOOL.map(TakeEverythingPacket::new, TakeEverythingPacket::enabled).cast(); @Override - public Id getId() { + public Type type() { return PACKET_ID; } + } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/config/ArmorHudPreviewItem.java b/src/main/java/net/kyrptonaught/lemclienthelper/config/ArmorHudPreviewItem.java index db399f4..15f8aa2 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/config/ArmorHudPreviewItem.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/config/ArmorHudPreviewItem.java @@ -1,17 +1,17 @@ package net.kyrptonaught.lemclienthelper.config; import net.kyrptonaught.kyrptconfig.config.screen.items.BooleanItem; -import net.kyrptonaught.lemclienthelper.hud.ArmorHudRenderer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; +import net.kyrptonaught.lemclienthelper.hud.armorHud.ArmorHudRenderer; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; public class ArmorHudPreviewItem extends BooleanItem { - public ArmorHudPreviewItem(Text name, Boolean value, Boolean defaultValue) { + public ArmorHudPreviewItem(Component name, Boolean value, Boolean defaultValue) { super(name, value, defaultValue); } @Override - public void render2(DrawContext context, int x, int y, int mouseX, int mouseY, float delta) { + public void render2(GuiGraphics context, int x, int y, int mouseX, int mouseY, float delta) { super.render2(context, x, y, mouseX, mouseY, delta); if (value) { ArmorHudRenderer.onHudRenderDummy(context, 20, 1); diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java b/src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java index 239c6eb..01aa229 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java @@ -21,28 +21,28 @@ import net.kyrptonaught.lemclienthelper.syncedKeybinds.SyncedKeybind; import net.kyrptonaught.lemclienthelper.syncedKeybinds.SyncedKeybindsConfig; import net.kyrptonaught.lemclienthelper.syncedKeybinds.SyncedKeybindsMod; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; public class ModMenuIntegration implements ModMenuApi { @Override public ConfigScreenFactory getModConfigScreenFactory() { return (screen) -> { - ConfigScreen configScreen = new ConfigScreen(screen, Text.translatable("key.lemclienthelper.title")); + ConfigScreen configScreen = new ConfigScreen(screen, Component.translatable("key.lemclienthelper.title")); configScreen.setSavingEvent(() -> { LEMClientHelperMod.configManager.save(); }); //Resource Preloader ResourcePreloaderConfig config = ResourcePreloaderMod.getConfig(); - ConfigSection rplSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.resourcepreloader")); + ConfigSection rplSection = new ConfigSection(configScreen, Component.translatable("key.lemclienthelper.resourcepreloader")); - rplSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.toastcomplete"), config.toastComplete, true).setSaveConsumer(val -> config.toastComplete = val)); + rplSection.addConfigItem(new BooleanItem(Component.translatable("key.lemclienthelper.toastcomplete"), config.toastComplete, true).setSaveConsumer(val -> config.toastComplete = val)); - SubItem sub = new SubItem<>(Text.translatable("key.lemclienthelper.packdownloads"), true); + SubItem sub = new SubItem<>(Component.translatable("key.lemclienthelper.packdownloads"), true); - rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.deletePacks")).setClickEvent(() -> { + rplSection.addConfigItem(new ButtonItem(Component.translatable("key.lemclienthelper.deletePacks")).setClickEvent(() -> { configScreen.save(); ResourcePreloaderMod.deletePacks(); ResourcePreloaderMod.getPackList(); @@ -50,13 +50,13 @@ public ConfigScreenFactory getModConfigScreenFactory() { })); - rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.previewList")).setClickEvent(() -> { + rplSection.addConfigItem(new ButtonItem(Component.translatable("key.lemclienthelper.previewList")).setClickEvent(() -> { configScreen.save(); ResourcePreloaderMod.getPackList(); addPacksToSub(sub); })); - rplSection.addConfigItem(new ButtonItem(Text.translatable("key.lemclienthelper.startdownload")).setClickEvent(() -> { + rplSection.addConfigItem(new ButtonItem(Component.translatable("key.lemclienthelper.startdownload")).setClickEvent(() -> { configScreen.save(); ResourcePreloaderMod.getPackList(); ResourcePreloaderMod.downloadPacks(); @@ -68,14 +68,14 @@ public ConfigScreenFactory getModConfigScreenFactory() { //Server Configs ServerConfigsConfig serverConfig = ServerConfigsMod.getConfig(); - ConfigSection serverConfigSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.serverconfig")); + ConfigSection serverConfigSection = new ConfigSection(configScreen, Component.translatable("key.lemclienthelper.serverconfig")); - IntegerItem guiItem = (IntegerItem) serverConfigSection.addConfigItem(new IntegerItem(Text.translatable("key.lemclienthelper.serverconfig.guiscale"), serverConfig.guiScale, 0)); + IntegerItem guiItem = (IntegerItem) serverConfigSection.addConfigItem(new IntegerItem(Component.translatable("key.lemclienthelper.serverconfig.guiscale"), serverConfig.guiScale, 0)); guiItem.setMinMax(0, 4); guiItem.setSaveConsumer(val -> serverConfig.guiScale = val); guiItem.setToolTipWithNewLine("key.lemclienthelper.serverconfig.guiscale.tooltip"); - IntegerItem panItem = (IntegerItem) serverConfigSection.addConfigItem(new IntegerItem(Text.translatable("key.lemclienthelper.serverconfig.panscale"), serverConfig.panScale, 0)); + IntegerItem panItem = (IntegerItem) serverConfigSection.addConfigItem(new IntegerItem(Component.translatable("key.lemclienthelper.serverconfig.panscale"), serverConfig.panScale, 0)); panItem.setMinMax(0, 4); panItem.setSaveConsumer(val -> serverConfig.panScale = val); panItem.setToolTipWithNewLine("key.lemclienthelper.serverconfig.panscale.tooltip"); @@ -83,45 +83,46 @@ public ConfigScreenFactory getModConfigScreenFactory() { //Hud HudConfig clientGUI = HudMod.getConfig(); - ConfigSection clientGUISection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.clientgui")); + ConfigSection clientGUISection = new ConfigSection(configScreen, Component.translatable("key.lemclienthelper.clientgui")); - clientGUISection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.clientgui.enabled"), clientGUI.enabled, true).setSaveConsumer(val -> clientGUI.enabled = val)); - clientGUISection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.clientgui.alwaysshow"), clientGUI.alwaysEnabled, false).setSaveConsumer(val -> clientGUI.alwaysEnabled = val)); + clientGUISection.addConfigItem(new BooleanItem(Component.translatable("key.lemclienthelper.clientgui.enabled"), clientGUI.enabled, true).setSaveConsumer(val -> clientGUI.enabled = val)); + clientGUISection.addConfigItem(new BooleanItem(Component.translatable("key.lemclienthelper.clientgui.alwaysshow"), clientGUI.alwaysEnabled, false).setSaveConsumer(val -> clientGUI.alwaysEnabled = val)); + clientGUISection.addConfigItem(new BooleanItem(Component.translatable("key.lemclienthelper.clientgui.glidealwaysshow"), clientGUI.glideAlwaysEnabled, true).setSaveConsumer(val -> clientGUI.glideAlwaysEnabled = val)); - FloatItem armorHudScale = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Text.translatable("key.lemclienthelper.clientgui.armorscale"), clientGUI.armorHudScale, 1f)); + FloatItem armorHudScale = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Component.translatable("key.lemclienthelper.clientgui.armorscale"), clientGUI.armorHudScale, 1f)); armorHudScale.setMinMax(1f, 4f); armorHudScale.setSaveConsumer(val -> clientGUI.armorHudScale = val); armorHudScale.setToolTipWithNewLine("key.lemclienthelper.clientgui.armorscale.tooltip"); - FloatItem armorHudXOffset = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Text.translatable("key.lemclienthelper.clientgui.xOffset"), clientGUI.xOffset, 20f)); + FloatItem armorHudXOffset = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Component.translatable("key.lemclienthelper.clientgui.xOffset"), clientGUI.xOffset, 20f)); armorHudXOffset.setMinMax(0f, 100f); armorHudXOffset.setSaveConsumer(val -> clientGUI.xOffset = val); armorHudXOffset.setToolTipWithNewLine("key.lemclienthelper.clientgui.xOffset.tooltip"); - FloatItem armorHudTransparency = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Text.translatable("key.lemclienthelper.clientgui.transparency"), clientGUI.transparency, .75f)); + FloatItem armorHudTransparency = (FloatItem) clientGUISection.addConfigItem(new FloatItem(Component.translatable("key.lemclienthelper.clientgui.transparency"), clientGUI.transparency, .75f)); armorHudTransparency.setMinMax(0f, 1f); armorHudTransparency.setSaveConsumer(val -> clientGUI.transparency = val); armorHudTransparency.setToolTipWithNewLine("key.lemclienthelper.clientgui.transparency.tooltip"); - //clientGUISection.addConfigItem(new ArmorHudPreviewItem(Text.translatable("key.lemclienthelper.clientgui.displaypreview"), clientGUI.enabled, false)); + //clientGUISection.addConfigItem(new ArmorHudPreviewItem(Component.translatable("key.lemclienthelper.clientgui.displaypreview"), clientGUI.enabled, false)); //Small Inv - ConfigSection smallInvSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.smallinv")); - smallInvSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.smallinv.enabled"), SmallInvMod.getConfig().enabled, true).setSaveConsumer(val -> SmallInvMod.getConfig().enabled = val)); + ConfigSection smallInvSection = new ConfigSection(configScreen, Component.translatable("key.lemclienthelper.smallinv")); + smallInvSection.addConfigItem(new BooleanItem(Component.translatable("key.lemclienthelper.smallinv.enabled"), SmallInvMod.getConfig().enabled, true).setSaveConsumer(val -> SmallInvMod.getConfig().enabled = val)); //Synced Keybinds SyncedKeybindsConfig syncedKeybindsConfig = SyncedKeybindsMod.getConfig(); - ConfigSection syncedKeybinds = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.syncedkeybinds")); + ConfigSection syncedKeybinds = new ConfigSection(configScreen, Component.translatable("key.lemclienthelper.syncedkeybinds")); - SubItem syncedKeybindItems = new SubItem<>(Text.translatable("key.lemclienthelper.syncedkeys"), true); + SubItem syncedKeybindItems = new SubItem<>(Component.translatable("key.lemclienthelper.syncedkeys"), true); syncedKeybindItems.setToolTipWithNewLine("key.lemclienthelper.syncedkeys.tooltip"); syncedKeybinds.addConfigItem(syncedKeybindItems); - for (Identifier id : syncedKeybindsConfig.keybinds.keySet()) { + for (ResourceLocation id : syncedKeybindsConfig.keybinds.keySet()) { SyncedKeybindsConfig.KeybindConfigItem keybindConfigItem = syncedKeybindsConfig.keybinds.get(id); - KeybindItem keybindItem = (KeybindItem) new KeybindItem(Text.translatable(id.toTranslationKey("lch.key.sync")), keybindConfigItem.keybinding, keybindConfigItem.defaultKeybinding).setSaveConsumer(val -> { + KeybindItem keybindItem = (KeybindItem) new KeybindItem(Component.translatable(id.toLanguageKey("lch.key.sync")), keybindConfigItem.keybinding, keybindConfigItem.defaultKeybinding).setSaveConsumer(val -> { keybindConfigItem.keybinding = val; SyncedKeybind syncedKeybind = SyncedKeybindsMod.syncedKeybindList.get(id); if (syncedKeybind != null) @@ -138,7 +139,7 @@ public void addPacksToSub(SubItem sub) { if (ResourcePreloaderMod.allPacks != null && ResourcePreloaderMod.allPacks.packs.size() > 0) { sub.clearConfigItems(); ResourcePreloaderMod.allPacks.packs.forEach(rpOption -> { - sub.addConfigItem(new ResourcepackDownloadItem(rpOption).setToolTip(Text.literal(rpOption.url))); + sub.addConfigItem(new ResourcepackDownloadItem(rpOption).setToolTip(Component.literal(rpOption.url))); }); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/config/ResourcepackDownloadItem.java b/src/main/java/net/kyrptonaught/lemclienthelper/config/ResourcepackDownloadItem.java index 713dc66..b8e335c 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/config/ResourcepackDownloadItem.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/config/ResourcepackDownloadItem.java @@ -2,16 +2,16 @@ import net.kyrptonaught.kyrptconfig.config.screen.items.ConfigItem; import net.kyrptonaught.lemclienthelper.ResourcePreloader.AllPacks; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; public class ResourcepackDownloadItem extends ConfigItem { private final AllPacks.RPOption rpOption; public ResourcepackDownloadItem(AllPacks.RPOption option) { - super(Text.literal(option.packname), null, null); + super(Component.literal(option.packname), null, null); this.rpOption = option; } @@ -21,20 +21,20 @@ public int getContentSize() { } @Override - public void render(DrawContext context, int x, int y, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics context, int x, int y, int mouseX, int mouseY, float delta) { super.render(context, x, y, mouseX, mouseY, delta); - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + Font textRenderer = Minecraft.getInstance().font; if (rpOption.status != null) { - int titleX = MinecraftClient.getInstance().getWindow().getScaledWidth() - 90; + int titleX = Minecraft.getInstance().getWindow().getGuiScaledWidth() - 90; if (rpOption.status2 == null) { - context.drawCenteredTextWithShadow(textRenderer, rpOption.status, titleX, y + 10 - 4, 16777215); + context.drawCenteredString(textRenderer, rpOption.status, titleX, y + 10 - 4, 16777215); } else { //Text task = (Text.literal("")).append(progressListener.task).append(" " + progressListener.progress + "%"); - context.drawCenteredTextWithShadow(textRenderer, rpOption.status, titleX, y + 2, 16777215); - context.drawCenteredTextWithShadow(textRenderer, rpOption.status2, titleX, y + 11, 16777215); + context.drawCenteredString(textRenderer, rpOption.status, titleX, y + 2, 16777215); + context.drawCenteredString(textRenderer, rpOption.status2, titleX, y + 11, 16777215); } } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderArea.java b/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderArea.java index 9e73796..acdfbff 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderArea.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderArea.java @@ -1,12 +1,12 @@ package net.kyrptonaught.lemclienthelper.customWorldBorder; -import net.minecraft.util.function.BooleanBiFunction; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.border.WorldBorder; -import net.minecraft.world.border.WorldBorderStage; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.level.border.BorderStatus; +import net.minecraft.world.level.border.WorldBorder; -public class CustomWorldBorderArea implements WorldBorder.Area { +public class CustomWorldBorderArea implements WorldBorder.BorderExtent { private final WorldBorder worldBorder; private final double xSize, zSize; @@ -18,22 +18,22 @@ public CustomWorldBorderArea(WorldBorder worldBorder, double xSize, double zSize @Override - public double getBoundWest() { + public double getMinX() { return worldBorder.getCenterX() - xSize; } @Override - public double getBoundEast() { + public double getMaxX() { return worldBorder.getCenterX() + xSize; } @Override - public double getBoundNorth() { + public double getMinZ() { return worldBorder.getCenterZ() - zSize; } @Override - public double getBoundSouth() { + public double getMaxZ() { return worldBorder.getCenterZ() + zSize; } @@ -43,40 +43,40 @@ public double getSize() { } @Override - public double getShrinkingSpeed() { + public double getLerpSpeed() { return 0; } @Override - public long getSizeLerpTime() { + public long getLerpTime() { return 0; } @Override - public double getSizeLerpTarget() { + public double getLerpTarget() { return 0; } @Override - public WorldBorderStage getStage() { - return WorldBorderStage.STATIONARY; + public BorderStatus getStatus() { + return BorderStatus.STATIONARY; } @Override - public void onMaxRadiusChanged() { + public void onAbsoluteMaxSizeChange() { } @Override - public void onCenterChanged() { + public void onCenterChange() { } @Override - public WorldBorder.Area getAreaInstance() { + public WorldBorder.BorderExtent update() { return this; } @Override - public VoxelShape asVoxelShape() { - return VoxelShapes.combineAndSimplify(VoxelShapes.UNBOUNDED, VoxelShapes.cuboid(Math.floor(this.getBoundWest()), Double.NEGATIVE_INFINITY, Math.floor(this.getBoundNorth()), Math.ceil(this.getBoundEast()), Double.POSITIVE_INFINITY, Math.ceil(this.getBoundSouth())), BooleanBiFunction.ONLY_FIRST); + public VoxelShape getCollisionShape() { + return Shapes.join(Shapes.INFINITY, Shapes.box(Math.floor(this.getMinX()), Double.NEGATIVE_INFINITY, Math.floor(this.getMinZ()), Math.ceil(this.getMaxX()), Double.POSITIVE_INFINITY, Math.ceil(this.getMaxZ())), BooleanOp.ONLY_FIRST); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderNetworking.java b/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderNetworking.java index 71e757c..30467e9 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderNetworking.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderNetworking.java @@ -5,11 +5,11 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.kyrptonaught.lemclienthelper.customWorldBorder.duckInterface.CustomWorldBorder; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; public class CustomWorldBorderNetworking { - public static void sendCustomWorldBorderPacket(ServerPlayerEntity player, double xCenter, double zCenter, double xSize, double zSize) { + public static void sendCustomWorldBorderPacket(ServerPlayer player, double xCenter, double zCenter, double xSize, double zSize) { ServerPlayNetworking.send(player, new CustomWorldBorderPacket(xCenter, zCenter, xSize, zSize)); } @@ -17,8 +17,8 @@ public static void sendCustomWorldBorderPacket(ServerPlayerEntity player, double public static void registerReceive() { ClientPlayNetworking.registerGlobalReceiver(CustomWorldBorderPacket.PACKET_ID, ((payload, context) -> { context.client().execute(() -> { - ((CustomWorldBorder) context.client().world.getWorldBorder()).setShape(payload.xCenter(), payload.zCenter(), payload.xSize(), payload.zSize()); - context.client().world.getWorldBorder().setWarningBlocks(0); + ((CustomWorldBorder) context.client().level.getWorldBorder()).setShape(payload.xCenter(), payload.zCenter(), payload.xSize(), payload.zSize()); + context.client().level.getWorldBorder().setWarningBlocks(0); }); })); } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderPacket.java index 830cdc1..bfdc788 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderPacket.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/customWorldBorder/CustomWorldBorderPacket.java @@ -1,21 +1,21 @@ package net.kyrptonaught.lemclienthelper.customWorldBorder; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; public record CustomWorldBorderPacket(double xCenter, double zCenter, double xSize, - double zSize) implements CustomPayload { - public static final Id PACKET_ID = new Id<>(Identifier.of("customworldborder", "customborder")); - public static final PacketCodec codec = PacketCodec.of(CustomWorldBorderPacket::write, CustomWorldBorderPacket::read); + double zSize) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("customworldborder", "customborder")); + public static final StreamCodec codec = StreamCodec.ofMember(CustomWorldBorderPacket::write, CustomWorldBorderPacket::read); - public static CustomWorldBorderPacket read(RegistryByteBuf buf) { + public static CustomWorldBorderPacket read(RegistryFriendlyByteBuf buf) { return new CustomWorldBorderPacket(buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readDouble()); } - public void write(RegistryByteBuf buf) { + public void write(RegistryFriendlyByteBuf buf) { buf.writeDouble(xCenter); buf.writeDouble(zCenter); buf.writeDouble(xSize); @@ -23,7 +23,7 @@ public void write(RegistryByteBuf buf) { } @Override - public Id getId() { + public Type type() { return PACKET_ID; } } \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/ArmorHudPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/ArmorHudPacket.java deleted file mode 100644 index f13e265..0000000 --- a/src/main/java/net/kyrptonaught/lemclienthelper/hud/ArmorHudPacket.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.kyrptonaught.lemclienthelper.hud; - -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; - -public record ArmorHudPacket(boolean enabled) implements CustomPayload { - public static final Id PACKET_ID = new Id<>(Identifier.of("armorhud", "armor_hud_render_enable")); - public static final PacketCodec codec = PacketCodecs.BOOL.xmap(ArmorHudPacket::new, ArmorHudPacket::enabled).cast(); - - @Override - public Id getId() { - return PACKET_ID; - } -} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/ArmorHudRenderer.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/ArmorHudRenderer.java deleted file mode 100644 index d441c24..0000000 --- a/src/main/java/net/kyrptonaught/lemclienthelper/hud/ArmorHudRenderer.java +++ /dev/null @@ -1,88 +0,0 @@ -package net.kyrptonaught.lemclienthelper.hud; - -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.*; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Identifier; -import org.joml.Matrix4f; - -import java.util.List; - -public class ArmorHudRenderer { - private static final Identifier[] EMPTY_SLOTS = new Identifier[]{ - Identifier.of("minecraft", "textures/item/empty_armor_slot_boots.png"), - Identifier.of("minecraft", "textures/item/empty_armor_slot_leggings.png"), - Identifier.of("minecraft", "textures/item/empty_armor_slot_chestplate.png"), - Identifier.of("minecraft", "textures/item/empty_armor_slot_helmet.png") - }; - - public static void onHudRender(DrawContext context, RenderTickCounter v) { - MinecraftClient client = MinecraftClient.getInstance(); - //HudMod.SHOULD_RENDER_ARMOR = true; - if (client.player != null && HudMod.shouldDisplay() && !client.options.hudHidden) { - int height = client.getWindow().getScaledHeight(); - - context.getMatrices().push(); - context.getMatrices().translate(HudMod.getConfig().xOffset, height / 2f, 0); - context.getMatrices().scale(HudMod.getConfig().armorHudScale, HudMod.getConfig().armorHudScale, 1f); - context.getMatrices().translate(0, -32, 0); - context.setShaderColor(1f, 1f, 1f, HudMod.getConfig().transparency); - - for (int i = 0; i < 4; i++) { - ItemStack armorStack = client.player.getInventory().getArmorStack(i); - int y = 16 * (3 - i); - if (armorStack.isEmpty()) { - draw(context, EMPTY_SLOTS[i], 0, y); - } else { - context.drawItem(armorStack, 0, y); - context.drawItemInSlot(client.textRenderer, armorStack, 0, y); - } - } - context.setShaderColor(1f, 1f, 1f, 1f); - context.getMatrices().pop(); - } - } - - public static void onHudRenderDummy(DrawContext context, float xOffset, float scale) { - MinecraftClient client = MinecraftClient.getInstance(); - int height = client.getWindow().getScaledHeight(); - - context.getMatrices().push(); - context.getMatrices().translate(xOffset, height / 2f, 0); - context.getMatrices().scale(scale, scale, 1f); - context.getMatrices().translate(0, -32, 0); - context.setShaderColor(1f, 1f, 1f, HudMod.getConfig().transparency); - - List armors = List.of(Items.GOLDEN_HELMET.getDefaultStack(), ItemStack.EMPTY, Items.GOLDEN_LEGGINGS.getDefaultStack(), Items.GOLDEN_BOOTS.getDefaultStack()); - - for (int i = 0; i < 4; i++) { - ItemStack armorStack = armors.get(i); - int y = 16 * (3 - i); - if (armorStack.isEmpty()) { - draw(context, EMPTY_SLOTS[i], 0, y); - } else { - context.drawItem(armorStack, 0, y); - context.drawItemInSlot(client.textRenderer, armorStack, 0, y); - } - } - context.setShaderColor(1f, 1f, 1f, 1f); - context.getMatrices().pop(); - } - - private static void draw(DrawContext context, Identifier texture, float x, float y) { - RenderSystem.setShaderTexture(0, texture); - RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); - RenderSystem.enableBlend(); - Matrix4f matrix4f = context.getMatrices().peek().getPositionMatrix(); - BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); - bufferBuilder.vertex(matrix4f, x, y, 0f).color(1f, 1f, 1f, 1f).texture(0f, 0f); - bufferBuilder.vertex(matrix4f, x, y + 16, 0f).color(1, 1f, 1f, 1f).texture(0f, 1f); - bufferBuilder.vertex(matrix4f, x + 16, y + 16, 0f).color(1f, 1f, 1f, 1f).texture(1f, 1f); - bufferBuilder.vertex(matrix4f, x + 16, y, 0f).color(1f, 1f, 1f, 1f).texture(1f, 0f); - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); - RenderSystem.disableBlend(); - } -} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java index 035ced0..f4d7c23 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java @@ -7,6 +7,8 @@ public class HudConfig implements AbstractConfigFile { public boolean alwaysEnabled = false; + public boolean glideAlwaysEnabled = false; + public float armorHudScale = 1; public float xOffset = 20; diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java index 43d148b..ff23ddd 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java @@ -1,37 +1,23 @@ package net.kyrptonaught.lemclienthelper.hud; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; -import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; +import net.kyrptonaught.lemclienthelper.hud.armorHud.ArmorHudMod; +import net.kyrptonaught.lemclienthelper.hud.genericHud.GenericHudMod; +import net.kyrptonaught.lemclienthelper.hud.glideHud.GlideHudMod; +import wily.legacy.Legacy4JClient; public class HudMod { public static String MOD_ID = "hud"; - - public static boolean SHOULD_RENDER_ARMOR = false; - - - public static void onInitialize() { + public static void onInitialize(){ LEMClientHelperMod.configManager.registerFile(MOD_ID, new HudConfig()); LEMClientHelperMod.configManager.load(MOD_ID); - //register hud's here - HudRenderCallback.EVENT.register(ArmorHudRenderer::onHudRender); - - ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> SHOULD_RENDER_ARMOR = false); - PayloadTypeRegistry.playS2C().register(ArmorHudPacket.PACKET_ID, ArmorHudPacket.codec); - - ClientPlayNetworking.registerGlobalReceiver(ArmorHudPacket.PACKET_ID, ((payload, context) -> { - SHOULD_RENDER_ARMOR = payload.enabled(); - - })); + GenericHudMod.onInitialize(); + ArmorHudMod.onInitialize(); + GlideHudMod.onInitialize(); } - public static boolean shouldDisplay() { - return getConfig().alwaysEnabled || SHOULD_RENDER_ARMOR; - } public static HudConfig getConfig() { return (HudConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/ArmorHudMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/ArmorHudMod.java new file mode 100644 index 0000000..bdbe7e5 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/ArmorHudMod.java @@ -0,0 +1,33 @@ +package net.kyrptonaught.lemclienthelper.hud.armorHud; + +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; +import net.kyrptonaught.lemclienthelper.hud.HudConfig; +import net.kyrptonaught.lemclienthelper.hud.armorHud.packets.ArmorHudPacket; + +public class ArmorHudMod { + public static String MOD_ID = "hud"; + + public static boolean SHOULD_RENDER_ARMOR = false; + + public static void onInitialize() { + HudRenderCallback.EVENT.register(ArmorHudRenderer::onHudRender); + + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> SHOULD_RENDER_ARMOR = false); + + PayloadTypeRegistry.playS2C().register(ArmorHudPacket.PACKET_ID, ArmorHudPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(ArmorHudPacket.PACKET_ID, ((payload, context) -> SHOULD_RENDER_ARMOR = payload.enabled())); + } + + public static boolean shouldDisplayArmor() { + return getConfig().alwaysEnabled || SHOULD_RENDER_ARMOR; + } + + + public static HudConfig getConfig() { + return (HudConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/ArmorHudRenderer.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/ArmorHudRenderer.java new file mode 100644 index 0000000..633a1de --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/ArmorHudRenderer.java @@ -0,0 +1,95 @@ +package net.kyrptonaught.lemclienthelper.hud.armorHud; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.BufferUploader; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.kyrptonaught.lemclienthelper.hud.HudMod; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import org.joml.Matrix4f; + +import java.util.List; + +public class ArmorHudRenderer { + private static final ResourceLocation[] EMPTY_SLOTS = new ResourceLocation[]{ + ResourceLocation.fromNamespaceAndPath("minecraft", "textures/item/empty_armor_slot_boots.png"), + ResourceLocation.fromNamespaceAndPath("minecraft", "textures/item/empty_armor_slot_leggings.png"), + ResourceLocation.fromNamespaceAndPath("minecraft", "textures/item/empty_armor_slot_chestplate.png"), + ResourceLocation.fromNamespaceAndPath("minecraft", "textures/item/empty_armor_slot_helmet.png") + }; + + public static void onHudRender(GuiGraphics context, DeltaTracker v) { + Minecraft client = Minecraft.getInstance(); + //HudMod.SHOULD_RENDER_ARMOR = true; + if (client.player != null && ArmorHudMod.shouldDisplayArmor() && !client.options.hideGui) { + int height = client.getWindow().getGuiScaledHeight(); + + context.pose().pushMatrix(); + context.pose().translate(HudMod.getConfig().xOffset, height / 2f, 0); + context.pose().scale(HudMod.getConfig().armorHudScale, HudMod.getConfig().armorHudScale, 1f); + context.pose().translate(0, -32, 0); + context.setColor(1f, 1f, 1f, HudMod.getConfig().transparency); + + for (int i = 0; i < 4; i++) { + ItemStack armorStack = client.player.getInventory().getItem(i); + int y = 16 * (3 - i); + if (armorStack.isEmpty()) { + draw(context, EMPTY_SLOTS[i], 0, y); + } else { + context.renderItem(armorStack, 0, y); + context.renderItemDecorations(client.font, armorStack, 0, y); + } + } + context.setColor(1f, 1f, 1f, 1f); + context.pose().popMatrix(); + } + } + + public static void onHudRenderDummy(GuiGraphics context, float xOffset, float scale) { + Minecraft client = Minecraft.getInstance(); + int height = client.getWindow().getGuiScaledHeight(); + + context.pose().pushMatrix(); + context.pose().translate(xOffset, height / 2f, 0); + context.pose().scale(scale, scale, 1f); + context.pose().translate(0, -32, 0); + context.setColor(1f, 1f, 1f, HudMod.getConfig().transparency); + + List armors = List.of(Items.GOLDEN_HELMET.getDefaultInstance(), ItemStack.EMPTY, Items.GOLDEN_LEGGINGS.getDefaultInstance(), Items.GOLDEN_BOOTS.getDefaultInstance()); + + for (int i = 0; i < 4; i++) { + ItemStack armorStack = armors.get(i); + int y = 16 * (3 - i); + if (armorStack.isEmpty()) { + draw(context, EMPTY_SLOTS[i], 0, y); + } else { + context.renderItem(armorStack, 0, y); + context.renderItemDecorations(client.font, armorStack, 0, y); + } + } + context.setColor(1f, 1f, 1f, 1f); + context.pose().popMatrix(); + } + + private static void draw(GuiGraphics context, ResourceLocation texture, float x, float y) { + RenderSystem.setShaderTexture(0, texture); + RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + RenderSystem.enableBlend(); + Matrix4f matrix4f = context.pose().last().pose(); + BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + bufferBuilder.addVertex(matrix4f, x, y, 0f).setColor(1f, 1f, 1f, 1f).setUv(0f, 0f); + bufferBuilder.addVertex(matrix4f, x, y + 16, 0f).setColor(1, 1f, 1f, 1f).setUv(0f, 1f); + bufferBuilder.addVertex(matrix4f, x + 16, y + 16, 0f).setColor(1f, 1f, 1f, 1f).setUv(1f, 1f); + bufferBuilder.addVertex(matrix4f, x + 16, y, 0f).setColor(1f, 1f, 1f, 1f).setUv(1f, 0f); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); + RenderSystem.disableBlend(); + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/packets/ArmorHudPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/packets/ArmorHudPacket.java new file mode 100644 index 0000000..e9f332d --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/armorHud/packets/ArmorHudPacket.java @@ -0,0 +1,17 @@ +package net.kyrptonaught.lemclienthelper.hud.armorHud.packets; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +public record ArmorHudPacket(boolean enabled) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("armorhud", "armor_hud_render_enable")); + public static final StreamCodec codec = ByteBufCodecs.BOOL.map(ArmorHudPacket::new, ArmorHudPacket::enabled).cast(); + + @Override + public Type type() { + return PACKET_ID; + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/BannerRenderer.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/BannerRenderer.java new file mode 100644 index 0000000..cd25644 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/BannerRenderer.java @@ -0,0 +1,139 @@ +package net.kyrptonaught.lemclienthelper.hud.genericHud; + +import net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ARGB; +import net.minecraft.util.Mth; + +import static net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData.GAME_MODES.*; +import static net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData.MINIGAME_PHASES.*; +import static net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData.MINIGAME_TYPES.*; + +public class BannerRenderer { + private static final ResourceLocation SHIELD = ResourceLocation.fromNamespaceAndPath("lemclienthelper","textures/gui/shield.png"); + private static final ResourceLocation BANNER = ResourceLocation.fromNamespaceAndPath("lemclienthelper","textures/gui/banner.png"); + private static final ResourceLocation PARTICLE = ResourceLocation.fromNamespaceAndPath("minecraft","textures/particle/effect_4.png"); + private static final Minecraft client = Minecraft.getInstance(); + private static final Font textRenderer = client.font; + + private static float elapsed = 0.0f; + private static float elapsedMax = 3.0f; + + private static float shieldScale = 0.0f; + private static float bannerScale = 0.0f; + private static float bannerWidth = 0.0f; + private static float textTrans = 0.0f; + + private static ResourceLocation shield_icon = ResourceLocation.fromNamespaceAndPath("lemclienthelper","textures/gui/battle/shield_icon.png"); + + public static void onHudRender(GuiGraphics context, DeltaTracker v) { + if (GenericHudMod.BANNER_RECEIVED) { + float lastDur = (v.getGameTimeDeltaTicks() / 20f); + render(context, lastDur); + } + } + + public static void render(GuiGraphics context, float lastDur) { + int width = client.getWindow().getGuiScaledWidth(); + int height = client.getWindow().getGuiScaledHeight(); + elapsed += lastDur; + + int x = (width/2) - (int)((24 * shieldScale)/2); + int y = ((13 * height)/50) - (int)((34 * shieldScale)/2); + + context.pose().pushMatrix(); + + if (elapsed >= 0.1f) { renderParticles(context,elapsed,(width/2),height); } + renderShield(context,x,y); + if (elapsed >= (16f/30f)) { renderBanner(context,elapsed,width,height); } + + context.pose().popMatrix(); + + if (elapsed >= elapsedMax) { + reset(); + } + } + + private static void reset() { + GenericHudMod.BANNER_RECEIVED = false; + elapsed = 0.0f; + shieldScale = 0.0f; + bannerScale = 0.0f; + bannerWidth = 0.0f; + textTrans = 0.0f; + } + + private static void renderBanner(GuiGraphics context, float elapsed, int width, int height) { + bannerScale = Mth.lerp((elapsed/(24f/30f)), bannerScale,2.4f); + bannerWidth = Mth.lerp((elapsed/(24f/30f)), bannerWidth, (textRenderer.width(GenericHudMod.BANNER_TEXT)-((4*(int)bannerScale)))); + textTrans = Mth.lerp((elapsed/(40f/30f)),textTrans,1.0f); + + int x = (width/2) - (int)((bannerWidth)/2); + int y = ((13 * height)/50) + (int)((7.5*((2*bannerScale)/2.4f))); + + context.blit(RenderPipelines.GUI_TEXTURED, BANNER, (x-(7*(int)bannerScale)), y,(7*(int)(bannerScale)),8*(int)(bannerScale),0,0,7,8,31,8, ARGB.white(1f)); + context.blit(RenderPipelines.GUI_TEXTURED, BANNER, (x), y, (int) bannerWidth,8*(int)(bannerScale), 7*(int)(bannerScale),0, 1,8,31,8, ARGB.white(1f)); + context.blit(RenderPipelines.GUI_TEXTURED, BANNER, ((width/2)+(int)((bannerWidth)/2)), y,7*(int)(bannerScale),8*(int)(bannerScale),24,0,7,8,31,8, ARGB.white(1f)); + + context.pose().translate(0f,0.25f); + int textColor = ARGB.color((int) (textTrans*255),68, 68, 68); + context.drawString(textRenderer,GenericHudMod.BANNER_TEXT,x-((2*(int)bannerScale)),y+2,textColor,false); + context.pose().translate(0f,-0.25f); + } + + private static void renderParticles(GuiGraphics context, float elapsed, int x, int height) { + float potionPosY = Mth.lerp((elapsed/(24f/30f)), 72f, 56f); + float potionPosX = Mth.lerp((elapsed/(24f/30f)), 16f, 40f); + float posTrans = Mth.lerp((elapsed/(24f/30f)), 1f, 0f); + + int color = ARGB.white(posTrans); + context.blitSprite(RenderPipelines.GUI_TEXTURED, PARTICLE, (x - 8) - (int) potionPosX, (((13 * height) / 50) - (int) ((34 * 2.8f) / 2)) + (int) potionPosY, 16, 16, color); + context.blitSprite(RenderPipelines.GUI_TEXTURED, PARTICLE, (x - 8) + (int) potionPosX, (((13 * height) / 50) - (int) ((34 * 2.8f) / 2)) + (int) potionPosY, 16, 16, color); + } + + private static void renderShield(GuiGraphics context, int x, int y) { + float bigScale = 2.8f; + float standardScale = 2.4f; + + if (elapsed < (8f/30f)){ + shieldScale = Mth.lerp((elapsed/(8f/30f)), shieldScale, bigScale); + } else { + shieldScale = Mth.lerp(((elapsed-(8f/30f))/(8f/30f)), shieldScale, standardScale); + } + + context.blit(SHIELD, x, y,0,0,(int)(24* shieldScale),(int)(34* shieldScale),(int)(24* shieldScale),(int)(34* shieldScale)); + context.blit(shield_icon,x, y,0,0,(int)(24* shieldScale),(int)(34* shieldScale),(int)(24* shieldScale),(int)(34* shieldScale)); + } + + public static void setIcon() { + ServerInfoData.MINIGAME_TYPES Minigame = ServerInfoData.getMinigame(); + ServerInfoData.GAME_MODES Gamemode = ServerInfoData.getGamemode(); + ServerInfoData.MINIGAME_PHASES Phase = ServerInfoData.getPhase(); + if (Phase != SHOWDOWN) { + if (Minigame == BATTLE) { + shield_icon = ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/battle/shield_icon.png"); + } + if (Minigame == TUMBLE) { + shield_icon = ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/tumble/shield_icon.png"); + } + if (Minigame == GLIDE) { + if (Phase == COUNTDOWN) { + shield_icon = ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/glide/shield_icon.png"); + } else { + shield_icon = ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/" + (Gamemode == SCORE_ATTACK ? "stopwatch_icon" : "glide/score_icon") + ".png"); + } + } + } else { + shield_icon = ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/stopwatch_icon.png"); + } + } + + public static void setElapsedMax(float max) { + elapsedMax = max; + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/GenericHudMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/GenericHudMod.java new file mode 100644 index 0000000..a25d3c7 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/GenericHudMod.java @@ -0,0 +1,134 @@ +package net.kyrptonaught.lemclienthelper.hud.genericHud; + +import com.mojang.brigadier.arguments.FloatArgumentType; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry; +import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements; +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import net.fabricmc.loader.api.FabricLoader; +import net.kyrptonaught.lemclienthelper.hud.genericHud.packets.BannerPacket; +import net.kyrptonaught.lemclienthelper.hud.genericHud.packets.PlayerBarPacket; + +import com.mojang.brigadier.arguments.BoolArgumentType; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; +import net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData; +import net.kyrptonaught.lemclienthelper.ServerInfo.packets.serverInfoPackets; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import wily.factoryapi.FactoryAPIClient; +import wily.factoryapi.base.client.UIAccessor; +import wily.factoryapi.base.client.UIDefinition; +import wily.factoryapi.util.FactoryGuiElement; +import wily.factoryapi.util.FactoryScreenUtil; +import wily.legacy.client.*; +import net.minecraft.commands.arguments.ComponentArgument; + +import java.util.Optional; + +public class GenericHudMod { + public static boolean SHOULD_RENDER_PLAYERBAR = false; + + public static boolean BANNER_RECEIVED = false; // Will set to false after banner is finished rendering. + public static Component BANNER_TEXT = null; + + public static void onInitialize() { + boolean l4jLoaded = FabricLoader.getInstance().isModLoaded("legacy"); + + if (l4jLoaded) { + FactoryAPIClient.setup((m) -> { + LegacyOptions.CLIENT_STORAGE.load(); + UIAccessor accessor = FactoryScreenUtil.getGuiAccessor(); + accessor.getStaticDefinitions().add(UIDefinition.createBeforeInit((a) -> { + if (LegacyMixinOptions.legacyGui.get()) { + a.getElements().put(FactoryGuiElement.EXPERIENCE_BAR.name() + ".isVisible", () -> { + 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); + }); + a.getElements().put(FactoryGuiElement.PLAYER_HEALTH.name() + ".isVisible", () -> { + 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); + }); + a.getElements().put(FactoryGuiElement.HOTBAR.name() + ".isVisible", () -> { + return HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.HOTBAR, true) && HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.ALL, true); + }); + } + })); + }); + } + + HudElementRegistry.attachElementAfter(VanillaHudElements.INFO_BAR, ResourceLocation.fromNamespaceAndPath(LEMClientHelperMod.MOD_ID, "player_bar"), PlayerBarRenderer::renderPlayerBar); + HudElementRegistry.attachElementAfter(VanillaHudElements.BOSS_BAR, ResourceLocation.fromNamespaceAndPath(LEMClientHelperMod.MOD_ID, "banner"), BannerRenderer::onHudRender); + + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> SHOULD_RENDER_PLAYERBAR = false); + + PayloadTypeRegistry.playS2C().register(PlayerBarPacket.PACKET_ID, PlayerBarPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(PlayerBarPacket.PACKET_ID, ((payload, context) -> { + SHOULD_RENDER_PLAYERBAR = payload.enabled(); + HideVanillaHUD.visible.put(HideVanillaHUD.HUD_ELEMENT.EXPERIENCE, !payload.enabled()); + })); + + PayloadTypeRegistry.playS2C().register(BannerPacket.PACKET_ID, BannerPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(BannerPacket.PACKET_ID, ((payload, context) -> { + BANNER_TEXT = payload.text(); + BannerRenderer.setElapsedMax(payload.elapsedMax().orElse(3.0f)); + BannerRenderer.setIcon(); + BANNER_RECEIVED = true; + })); + + + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> + dispatcher.register(Commands.literal(LEMClientHelperMod.MOD_ID) + .then(Commands.literal("examplePlayerBar") + .then(Commands.argument("inRound", BoolArgumentType.bool()) + .then(Commands.argument("target", EntityArgument.players()) + .executes(context -> { + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new serverInfoPackets.phasePacket((BoolArgumentType.getBool(context,"inRound") ? ServerInfoData.MINIGAME_PHASES.RUNNING : ServerInfoData.MINIGAME_PHASES.NONE))); + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new PlayerBarPacket(true)); + return 0; + })))))); + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> + dispatcher.register(Commands.literal(LEMClientHelperMod.MOD_ID) + .then(Commands.literal("sendTestBanner") + .then(Commands.argument("target", EntityArgument.players()) + .then(Commands.argument("minigame", IntegerArgumentType.integer(0,2)) + .then(Commands.argument("gamemode", IntegerArgumentType.integer(0,7)) + .then(Commands.argument("phase", IntegerArgumentType.integer(0,5)) + .then(Commands.argument("text", ComponentArgument.textComponent(registryAccess)) + .then(Commands.argument("elapsedMax", FloatArgumentType.floatArg(3f,90f)) + .executes(context -> { + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new serverInfoPackets.minigamePacket( + ServerInfoData.MINIGAME_TYPES.values()[IntegerArgumentType.getInteger(context,"minigame")])); + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new serverInfoPackets.gamemodePacket( + ServerInfoData.GAME_MODES.values()[IntegerArgumentType.getInteger(context,"gamemode")])); + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new serverInfoPackets.phasePacket( + ServerInfoData.MINIGAME_PHASES.values()[IntegerArgumentType.getInteger(context,"phase")])); + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new BannerPacket(ComponentArgument.getRawComponent(context,"text"), Optional.of(FloatArgumentType.getFloat(context, "elapsedMax")))); + return 0; + })).executes(context -> { + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new serverInfoPackets.minigamePacket( + ServerInfoData.MINIGAME_TYPES.values()[IntegerArgumentType.getInteger(context, "minigame")])); + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new serverInfoPackets.gamemodePacket( + ServerInfoData.GAME_MODES.values()[IntegerArgumentType.getInteger(context, "gamemode")])); + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new serverInfoPackets.phasePacket( + ServerInfoData.MINIGAME_PHASES.values()[IntegerArgumentType.getInteger(context, "phase")])); + ServerPlayNetworking.send(EntityArgument.getPlayer(context, "target"), + new BannerPacket(ComponentArgument.getRawComponent(context, "text"),Optional.empty())); + return 0; + }))))))))); + + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/HideVanillaHUD.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/HideVanillaHUD.java new file mode 100644 index 0000000..cd5a01e --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/HideVanillaHUD.java @@ -0,0 +1,28 @@ +package net.kyrptonaught.lemclienthelper.hud.genericHud; + +import java.util.HashMap; + +public class HideVanillaHUD { + + /** + *
+     * ALL - All Elements
+     * EXPERIENCE - Experience Bar/Locator Bar
+     * HEARTS - Player health
+     * HOTBAR - Player hotbar
+     * HUNGER - Player hunger
+     * STATS - EXPERIENCE, HEARTS, &, HUNGER
+     * 
+ */ + public enum HUD_ELEMENT { + ALL, + EXPERIENCE, + HEARTS, + HOTBAR, + HUNGER, + STATS + } + + public static HashMap visible; + +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/PlayerBarRenderer.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/PlayerBarRenderer.java new file mode 100644 index 0000000..da051c5 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/PlayerBarRenderer.java @@ -0,0 +1,101 @@ +package net.kyrptonaught.lemclienthelper.hud.genericHud; + +import net.fabricmc.loader.api.FabricLoader; +import net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ARGB; +import wily.legacy.util.client.LegacyRenderUtil; + +import static net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData.MINIGAME_PHASES.*; + +public class PlayerBarRenderer { + private static final ResourceLocation BIG_PLAYER_ICON_DEAD = ResourceLocation.fromNamespaceAndPath("lem.base", "textures/playerbar/big/dead.png"); + private static final ResourceLocation SMALL_PLAYER_ICON_DEAD = ResourceLocation.fromNamespaceAndPath("lem.base", "textures/playerbar/small/dead.png"); + + private static ResourceLocation BIG_PLAYER_ICONS(int i) { + if (i < 0 || i > 9) { + throw new IllegalStateException("Attempted to fetch player bar icon index of: " + i + ", index must be between 0-9"); + } else { + return ResourceLocation.fromNamespaceAndPath("lem.base", "textures/playerbar/big/" + (i+1) + ".png"); + } + } + + private static ResourceLocation SMALL_PLAYER_ICONS(int i) { + if (i < 0 || i > 15) { + throw new IllegalStateException("Attempted to fetch speedometer needle index of: " + i + ", index must be between 0-15"); + } else { + return ResourceLocation.fromNamespaceAndPath("lem.base", "textures/playerbar/small/" + (i+1) + ".png"); + } + } + + public static void renderPlayerBar(GuiGraphics context, DeltaTracker v){ + Minecraft client = Minecraft.getInstance(); + boolean l4jLoaded = FabricLoader.getInstance().isModLoaded("legacy"); + if (client.player != null && GenericHudMod.SHOULD_RENDER_PLAYERBAR && !client.options.hideGui) { + if (l4jLoaded) {LegacyRenderUtil.prepareHUDRender(context);} else {context.pose().pushMatrix();} + + int hotbarHeight = (int)(32 * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale() : 3f))); + int hotbarWidth = (int)(91 * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))); + int y = context.guiHeight() - hotbarHeight + (int)(3 * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))); + int x = context.guiWidth() / 2 - hotbarWidth; + + byte[] s = ServerInfoData.getPlayerStatus(); // Array of player statuses + int p = ServerInfoData.getPlayerStatus().length; // Amount of player icons + int textureWidth; // Width of texture + float totalWidth; // Width of texture + spacing. + int textureHeight = (int)(5 * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))); + + ServerInfoData.MINIGAME_PHASES Phase = ServerInfoData.getPhase(); + + // Horrible awful, no good, very bad, spacing/centring code. + if (p < 11) { + textureWidth = (int)(17 * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))); + totalWidth = (p > 8 ? 18f : 23f) * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f)); + if (Phase != NONE) { + // If you're wondering about this calculation, + // This is the amount of pixels the matrix is shifted by + // after every icon, in order to evenly space all icons, when there are >8. + // I hope these calculations are so bad, somebody takes + // this code away from me, and completely rewrites it, + // so I never have to see it again. + totalWidth = p > 8 ? (((182f * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))) - (textureWidth * p))/(p - 1)) + textureWidth : (165f/7f) * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f)); + + context.pose().translate((91f * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))),0f); // Shift start to centre of hotbar, + context.pose().translate(((((p - 1) * totalWidth) + textureWidth)/-2f), 0f); // Shift back by half of total playerbar width. + + } + } else { + textureWidth = (int)(10 * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))); + totalWidth = 11f * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f)); + if (Phase != NONE) { + totalWidth = (((182f * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))) - (textureWidth * p))/(p - 1))+ textureWidth; + + context.pose().translate((91f * (3f/(l4jLoaded ? LegacyRenderUtil.getHUDScale(): 3f))),0f); + context.pose().translate(((((p - 1) * totalWidth) + textureWidth)/-2f), 0f); + } + } + + + for (int i = 0; i < p; i++) { + if (i > 0) {context.pose().translate(totalWidth, 0f);} + int c = ARGB.white(1f); + + if (s[i] == 1 && l4jLoaded) {c = ARGB.white(LegacyRenderUtil.getHUDOpacity());} + if ((Phase == NONE && s[i] == 0) || s[i] == -1) {c = ARGB.white((l4jLoaded ? LegacyRenderUtil.getHUDOpacity() : 1f)*(128F/255F));} + + if (p < 11) { + context.blitSprite(RenderPipelines.GUI_TEXTURED, ((s[i] == 0 || s[i] == -1) && (Phase != NONE)) ? BIG_PLAYER_ICON_DEAD : BIG_PLAYER_ICONS(i), x, y, textureWidth, textureHeight, c); + } else { + context.blitSprite(RenderPipelines.GUI_TEXTURED, ((s[i] == 0 || s[i] == -1) && (Phase != NONE)) ? SMALL_PLAYER_ICON_DEAD : SMALL_PLAYER_ICONS(i),x, y, textureWidth, textureHeight, c); + } + } + + if (l4jLoaded) { LegacyRenderUtil.finalizeHUDRender(context); } else { context.pose().popMatrix(); } + + } + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/BannerPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/BannerPacket.java new file mode 100644 index 0000000..3c68052 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/BannerPacket.java @@ -0,0 +1,32 @@ +package net.kyrptonaught.lemclienthelper.hud.genericHud.packets; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.chat.Component; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.ComponentSerialization; + +import java.util.Optional; + +/** + * BannerPacket sends banner to client + * + * @param text Text, banner contents, such as "PLAYER won","Showdown!","0:00,000", etc. + * @param elapsedMax float, length of time in seconds to keep the banner on screen + */ +public record BannerPacket(Component text, Optional elapsedMax) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("hud", "banner")); + public static final StreamCodec codec = StreamCodec.composite( + ComponentSerialization.TRUSTED_STREAM_CODEC, BannerPacket::text, + ByteBufCodecs.optional(ByteBufCodecs.FLOAT), BannerPacket::elapsedMax, + BannerPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/HideVanillaHUDPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/HideVanillaHUDPacket.java new file mode 100644 index 0000000..b07e02a --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/HideVanillaHUDPacket.java @@ -0,0 +1,29 @@ +package net.kyrptonaught.lemclienthelper.hud.genericHud.packets; + +import net.kyrptonaught.lemclienthelper.hud.genericHud.HideVanillaHUD; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +/** + * HideVanillaHUDPacket sends banner to client + * + * @param element HideVanillaHUD.HUD_ELEMENT, {@link HideVanillaHUD.HUD_ELEMENT}. + * @param visible boolean, Is the element visible, false for hidden, true for shown. + */ +public record HideVanillaHUDPacket(HideVanillaHUD.HUD_ELEMENT element, boolean visible) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("hud", "hidevanilla")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.idMapper(i -> HideVanillaHUD.HUD_ELEMENT.values()[i], HideVanillaHUD.HUD_ELEMENT::ordinal), HideVanillaHUDPacket::element, + ByteBufCodecs.BOOL, HideVanillaHUDPacket::visible, + HideVanillaHUDPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/PlayerBarPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/PlayerBarPacket.java new file mode 100644 index 0000000..8f53ddb --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/genericHud/packets/PlayerBarPacket.java @@ -0,0 +1,25 @@ +package net.kyrptonaught.lemclienthelper.hud.genericHud.packets; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +/** + * PlayerBarPacket, send player bar information to client + * + * @param enabled boolean, is the playerbar enabled. + */ +public record PlayerBarPacket(boolean enabled) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("hud", "playerbar_enable")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.BOOL, PlayerBarPacket::enabled, + PlayerBarPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } +} \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/GlideHudMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/GlideHudMod.java new file mode 100644 index 0000000..a3eb1bf --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/GlideHudMod.java @@ -0,0 +1,127 @@ +package net.kyrptonaught.lemclienthelper.hud.glideHud; + +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry; +import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements; +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; +import net.kyrptonaught.lemclienthelper.hud.HudMod; +import net.kyrptonaught.lemclienthelper.hud.glideHud.packets.GlideHudPacket; +import net.kyrptonaught.lemclienthelper.hud.glideHud.packets.GlideScorePacket; +import net.kyrptonaught.lemclienthelper.hud.glideHud.packets.GlideTimerPacket; +import net.kyrptonaught.lemclienthelper.hud.glideHud.packets.GlideTimerTogglePacket; +import net.minecraft.resources.ResourceLocation; + +/* +import com.mojang.brigadier.arguments.BoolArgumentType; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.command.argument.EntityArgumentType; +import net.minecraft.server.command.CommandManager; +*/ + +public class GlideHudMod { + public static boolean SHOULD_RENDER_GLIDE = false; + + public static boolean TIMER_RUNNING = false; + + public static int FINAL_TIME; + + public static int ELAPSED_TIME = 0; + + public static int GLIDE_SCORE = 0; + + public static rings GLIDE_LAST_RING; + + public enum rings { + GREY, + GREEN, + YELLOW, + BLUE + } + + public static void onInitialize() { + HudElementRegistry.attachElementAfter(VanillaHudElements.SCOREBOARD, ResourceLocation.fromNamespaceAndPath(LEMClientHelperMod.MOD_ID, "glide_stats"), GlideHudRenderer::onHudRender); + + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> SHOULD_RENDER_GLIDE = false); + + PayloadTypeRegistry.playS2C().register(GlideHudPacket.PACKET_ID, GlideHudPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(GlideHudPacket.PACKET_ID, ((payload, context) -> SHOULD_RENDER_GLIDE = payload.enabled())); + + PayloadTypeRegistry.playS2C().register(GlideTimerTogglePacket.PACKET_ID, GlideTimerTogglePacket.codec); + ClientPlayNetworking.registerGlobalReceiver(GlideTimerTogglePacket.PACKET_ID, ((payload, context) -> TIMER_RUNNING = payload.enabled())); + + // Was going to include a reset timer packet, but you can also send a timer set packet of 0 before round start. + PayloadTypeRegistry.playS2C().register(GlideTimerPacket.PACKET_ID, GlideTimerPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(GlideTimerPacket.PACKET_ID, ((payload, context) -> FINAL_TIME = payload.ticks())); + + ClientTickEvents.END_CLIENT_TICK.register(event -> { + if (TIMER_RUNNING) { + ELAPSED_TIME = ELAPSED_TIME + 1; //This feels like a poor way of doing things. + } + }); + + PayloadTypeRegistry.playS2C().register(GlideScorePacket.PACKET_ID, GlideScorePacket.codec); + ClientPlayNetworking.registerGlobalReceiver(GlideScorePacket.PACKET_ID, ((payload, context) -> { + GLIDE_SCORE = payload.score(); + GLIDE_LAST_RING = payload.lastRing(); + })); + + PayloadTypeRegistry.playS2C().register(GlideScorePacket.GlideScoreIndexPacket.PACKET_ID, GlideScorePacket.GlideScoreIndexPacket.codec); + ClientPlayNetworking.registerGlobalReceiver(GlideScorePacket.GlideScoreIndexPacket.PACKET_ID, ((payload, context) -> { + GLIDE_SCORE = payload.score(); + GLIDE_LAST_RING = rings.values()[payload.lastRing()]; + })); + + /* + // Debug commands + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> + dispatcher.register(CommandManager.literal(LEMClientHelperMod.MOD_ID) + .then(CommandManager.literal("glide") + .then(CommandManager.argument("target", EntityArgumentType.players()) + .then(CommandManager.literal("timer") + .then(CommandManager.literal("start") + .executes(context -> { + ServerPlayNetworking.send(EntityArgumentType.getPlayer(context, "target"), new GlideTimerTogglePacket(true)); + return 0; + })) + .then(CommandManager.literal("stop") + .executes(context -> { + ServerPlayNetworking.send(EntityArgumentType.getPlayer(context, "target"), new GlideTimerTogglePacket(false)); + return 0; + })) + .then(CommandManager.literal("set") + .then(CommandManager.argument("ticks", IntegerArgumentType.integer()) + .executes(context -> { + ServerPlayNetworking.send(EntityArgumentType.getPlayer(context, "target"), new GlideTimerPacket(IntegerArgumentType.getInteger(context, "ticks"))); + return 0; + })))) + .then(CommandManager.literal("hud") + .then(CommandManager.argument("toggle", BoolArgumentType.bool()) + .then(CommandManager.argument("score", BoolArgumentType.bool()) + .executes( context -> { + ServerPlayNetworking.send(EntityArgumentType.getPlayer(context, "target"), new GlideHudPacket(BoolArgumentType.getBool(context, "toggle"))); + return 0; + })))) + .then(CommandManager.literal("score") + .then(CommandManager.literal("set") + .then(CommandManager.argument("score", IntegerArgumentType.integer()) + .then(CommandManager.argument("lastRing", IntegerArgumentType.integer(0,3)) + .executes(context -> { + ServerPlayNetworking.send(EntityArgumentType.getPlayer(context, "target"), + new GlideScorePacket( + IntegerArgumentType.getInteger(context, "score"), + rings.values()[IntegerArgumentType.getInteger(context, "lastRing")])); + return 0; + })))))))));*/ + } + + + public static boolean shouldDisplayGlide() { + return HudMod.getConfig().glideAlwaysEnabled || SHOULD_RENDER_GLIDE; + } + +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/GlideHudRenderer.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/GlideHudRenderer.java new file mode 100644 index 0000000..b5b8819 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/GlideHudRenderer.java @@ -0,0 +1,105 @@ +package net.kyrptonaught.lemclienthelper.hud.glideHud; + +import net.kyrptonaught.lemclienthelper.ServerInfo.ServerInfoData; +import net.kyrptonaught.lemclienthelper.hud.HudMod; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ARGB; +import net.minecraft.util.Mth; + +public class GlideHudRenderer { + private static final ResourceLocation SPEEDOMETER = ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/glide/speedometer/speedometer.png"); + private static final ResourceLocation STOPWATCH = ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/glide/timer/clock.png"); + + private static ResourceLocation SPEEDOMETER_NEEDLE(int i) { + if (i < 0 || i > 11) { + throw new IllegalStateException("Attempted to fetch speedometer needle index of: " + i + ", index must be between 0-11"); + } else { + return ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/glide/speedometer/needle_" + i + ".png"); + } + } + + private static ResourceLocation SECONDS_HAND(int i) { + if (i < 0 || i > 11) { + throw new IllegalStateException("Attempted to fetch speedometer needle index of: " + i + ", index must be between 0-11"); + } else { + return ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/glide/timer/seconds_" + i + ".png"); + } + } + + private static ResourceLocation MINUTES_HAND(int i) { + if (i < 0 || i > 11) { + throw new IllegalStateException("Attempted to fetch speedometer needle index of: " + i + ", index must be between 0-11"); + } else { + return ResourceLocation.fromNamespaceAndPath("lemclienthelper", "textures/gui/glide/timer/minutes_" + i + ".png"); + } + } + + static int elapsed = 0; + + public static void onHudRender(GuiGraphics context, DeltaTracker v) { + Minecraft client = Minecraft.getInstance(); + if (client.player != null && GlideHudMod.shouldDisplayGlide() && !client.options.hideGui) { + int height = client.getWindow().getGuiScaledHeight(); + int width = client.getWindow().getGuiScaledWidth(); + + context.pose().pushMatrix(); + context.pose().translate((width - HudMod.getConfig().xOffset), height / 2f); + context.pose().scale(HudMod.getConfig().armorHudScale, HudMod.getConfig().armorHudScale); + context.pose().translate(0, -24); + if (ServerInfoData.getGamemode() == ServerInfoData.GAME_MODES.SCORE_ATTACK) {context.pose().translate(0, 24);} + renderStopwatch(context, client); + renderSpeedometer(context, client); + if (ServerInfoData.getGamemode() == ServerInfoData.GAME_MODES.SCORE_ATTACK) {renderScore(context, client);} + context.pose().popMatrix(); + } + } + + + public static void renderStopwatch(GuiGraphics context, Minecraft client) { + context.blitSprite(RenderPipelines.GUI_TEXTURED, STOPWATCH, 0, -50,16,16, HudMod.getConfig().transparency); + if (GlideHudMod.TIMER_RUNNING) { + elapsed = GlideHudMod.ELAPSED_TIME; + GlideHudMod.FINAL_TIME = elapsed; //This prevents the time from displaying 0 if the final time packet is not received. + } if (!GlideHudMod.TIMER_RUNNING) { + elapsed = GlideHudMod.FINAL_TIME; + } + int seconds = (elapsed / 20) % 60; + int minutes = (elapsed / 20) / 60; + int milliseconds = (elapsed * 50) % 1000; + int secondsindex = (seconds / 10) % 11; + int minutesindex = (minutes / 5) % 11; + + context.blitSprite(RenderPipelines.GUI_TEXTURED, SECONDS_HAND(secondsindex), 0, -50, 16,16, HudMod.getConfig().transparency); + context.blitSprite(RenderPipelines.GUI_TEXTURED, MINUTES_HAND(minutesindex), 0, -50, 16,16, HudMod.getConfig().transparency); + + String timer = String.format("%d:%02d.%03d", minutes, seconds, milliseconds); + + int textWidth = client.font.width(timer); + context.pose().scale(1.25f,1.25f); + context.drawString(client.font, timer, (-4 - textWidth), -38, ARGB.white(HudMod.getConfig().transparency), true); + context.pose().scale(0.8f,0.8f); + } + + public static void renderSpeedometer(GuiGraphics context, Minecraft client) { + double mps = client.player.getDeltaMovement().horizontalDistance() * 20; + int needleIndex = Mth.clamp(Mth.floor(0.24 * mps - 0.5), 0, 11); + context.blitSprite(RenderPipelines.GUI_TEXTURED, SPEEDOMETER, 0, -30,16,16, HudMod.getConfig().transparency); + context.blitSprite(RenderPipelines.GUI_TEXTURED, SPEEDOMETER_NEEDLE(needleIndex), 0, -30,16,16, HudMod.getConfig().transparency); + + String speed = String.format("%.2f m/s", mps); + int textWidth = client.font.width(speed); + context.drawString(client.font, speed, (-4 - textWidth), (-30), ARGB.white(HudMod.getConfig().transparency), true); + } + + public static void renderScore(GuiGraphics context, Minecraft client) { + context.blit(SPEEDOMETER, 0, -10,0,0,16,16,16,16); + + String score = String.valueOf(GlideHudMod.GLIDE_SCORE); + int textWidth = client.font.width(score); + context.drawString(client.font, score, (-4 - textWidth), (-30), ARGB.white(HudMod.getConfig().transparency), true); + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideHudPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideHudPacket.java new file mode 100644 index 0000000..bc6ced6 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideHudPacket.java @@ -0,0 +1,26 @@ +package net.kyrptonaught.lemclienthelper.hud.glideHud.packets; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +/** + * GlideHudPacket, tells client to enable/disable the glide hud. + * + * @param enabled boolean, is the hud enabled. + */ +public record GlideHudPacket(boolean enabled) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("glidehud", "glide_hud_render_enable")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.BOOL, GlideHudPacket::enabled, + GlideHudPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } +} + diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideScorePacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideScorePacket.java new file mode 100644 index 0000000..3904e58 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideScorePacket.java @@ -0,0 +1,46 @@ +package net.kyrptonaught.lemclienthelper.hud.glideHud.packets; + +import net.kyrptonaught.lemclienthelper.hud.glideHud.GlideHudMod; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +/** + * GlideScorePacket sets the clients current score. + * + * @param score int, the total score the client has + * @param lastRing {@link GlideHudMod.rings}, GREY, GREEN, YELLOW, BLUE, the last ring collected + * + */ +public record GlideScorePacket(int score, GlideHudMod.rings lastRing) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("glidehud", "glide_score_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.INT, GlideScorePacket::score, + ByteBufCodecs.idMapper(i -> GlideHudMod.rings.values()[i], GlideHudMod.rings::ordinal), GlideScorePacket::lastRing, + GlideScorePacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + + + public record GlideScoreIndexPacket(int score, int lastRing) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("glidehud", "glide_score_index_set")); + public static final StreamCodec codec = StreamCodec.composite( + ByteBufCodecs.INT, GlideScoreIndexPacket::score, + ByteBufCodecs.INT, GlideScoreIndexPacket::lastRing, + GlideScoreIndexPacket::new + ); + + @Override + public Type type() { + return PACKET_ID; + } + } +} + + diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideTimerPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideTimerPacket.java new file mode 100644 index 0000000..f462f5a --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideTimerPacket.java @@ -0,0 +1,22 @@ +package net.kyrptonaught.lemclienthelper.hud.glideHud.packets; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +/** + * GlideTimerPacket, sets the value of the timer + * + * @param ticks int, elapsed time in ticks. + */ +public record GlideTimerPacket(int ticks) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("glidehud", "glide_timer_set")); + public static final StreamCodec codec = ByteBufCodecs.INT.map(GlideTimerPacket::new, GlideTimerPacket::ticks).cast(); + + @Override + public Type type() { + return PACKET_ID; + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideTimerTogglePacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideTimerTogglePacket.java new file mode 100644 index 0000000..2623c54 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/glideHud/packets/GlideTimerTogglePacket.java @@ -0,0 +1,23 @@ +package net.kyrptonaught.lemclienthelper.hud.glideHud.packets; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +/** + * GlideTimerTogglePacket starts/stops the timer. + * + * @param enabled boolean, is the timer running + */ +public record GlideTimerTogglePacket(boolean enabled) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath("glidehud", "glide_timer_toggle")); + public static final StreamCodec codec = ByteBufCodecs.BOOL.map(GlideTimerTogglePacket::new, GlideTimerTogglePacket::enabled).cast(); + + @Override + public Type type() { + return PACKET_ID; + } +} + diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/ResourcePreloader/ClientBuiltInResourcePackProviderMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/ResourcePreloader/ClientBuiltInResourcePackProviderMixin.java index 4929a1a..526e5a3 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/ResourcePreloader/ClientBuiltInResourcePackProviderMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/ResourcePreloader/ClientBuiltInResourcePackProviderMixin.java @@ -1,11 +1,11 @@ package net.kyrptonaught.lemclienthelper.mixin.ResourcePreloader; -import net.minecraft.util.Downloader; +import net.minecraft.server.packs.DownloadQueue; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(Downloader.class) +@Mixin(DownloadQueue.class) public class ClientBuiltInResourcePackProviderMixin { @ModifyConstant(method = "", constant = @Constant(intValue = 20)) diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/HandledScreenMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/HandledScreenMixin.java index 7c7b27b..2f31fd7 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/HandledScreenMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/HandledScreenMixin.java @@ -3,15 +3,17 @@ import net.kyrptonaught.lemclienthelper.SmallInv.MovableSlot; import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvMod; import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.gui.screen.ingame.InventoryScreen; -import net.minecraft.screen.GenericContainerScreenHandler; -import net.minecraft.screen.PlayerScreenHandler; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.text.Text; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.ContainerScreen; +import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; +import net.minecraft.client.gui.screens.inventory.InventoryScreen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.input.KeyEvent; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.network.chat.Component; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ChestMenu; +import net.minecraft.world.inventory.InventoryMenu; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -19,52 +21,52 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(HandledScreen.class) +@Mixin(AbstractContainerScreen.class) public abstract class HandledScreenMixin extends Screen implements SmallInvPlayerInv { @Shadow - protected int playerInventoryTitleY; + protected int inventoryLabelY; @Shadow - public abstract ScreenHandler getScreenHandler(); + public abstract AbstractContainerMenu getMenu(); @Shadow - protected int backgroundHeight; + protected int imageHeight; - protected HandledScreenMixin(Text title) { + protected HandledScreenMixin(Component title) { super(title); } @Inject(method = "init", at = @At("RETURN")) public void setPlayerTitleY(CallbackInfo ci) { if (getIsSmall()) - if (((Object) this instanceof GenericContainerScreen)) this.playerInventoryTitleY += 3; - else this.playerInventoryTitleY += 5; + if (((Object) this instanceof ContainerScreen)) this.inventoryLabelY += 3; + else this.inventoryLabelY += 5; } @Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true) - public void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) { - if (SmallInvMod.isKeybindPressed(keyCode, false)) { + public void keyPressed(KeyEvent keyEvent, CallbackInfoReturnable cir) { + if (SmallInvMod.isKeybindPressed(keyEvent.key(), false)) { setIsSmall(false); cir.setReturnValue(true); } } @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - public void mouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable cir) { - if (SmallInvMod.isKeybindPressed(button, true)) { + public void mouseClicked(MouseButtonEvent mouseButtonEvent, boolean bl, CallbackInfoReturnable cir) { + if (SmallInvMod.isKeybindPressed(mouseButtonEvent.button(), true)) { setIsSmall(false); cir.setReturnValue(true); } } - @Inject(method = "isClickOutsideBounds", at = @At("HEAD"), cancellable = true) - public void isClickOutsideSmallBounds(double mouseX, double mouseY, int left, int top, int button, CallbackInfoReturnable cir) { + @Inject(method = "hasClickedOutside", at = @At("HEAD"), cancellable = true) + public void isClickOutsideSmallBounds(double mouseX, double mouseY, int left, int top, CallbackInfoReturnable cir) { if (getIsSmall()) { - HandledScreen handledScreen = (HandledScreen) (Object) this; + AbstractContainerScreen handledScreen = (AbstractContainerScreen) (Object) this; if (!(handledScreen instanceof InventoryScreen) && - !(handledScreen instanceof CreativeInventoryScreen)) - if (mouseY >= (top + (this.backgroundHeight - 85 + 30))) cir.setReturnValue(true); + !(handledScreen instanceof CreativeModeInventoryScreen)) + if (mouseY >= (top + (this.imageHeight - 85 + 30))) cir.setReturnValue(true); } } @@ -79,14 +81,14 @@ public boolean getIsSmall() { public void setIsSmall(boolean small) { if (!this.isSmallSupported()) return; - if (getIsSmall() && !small) playerInventoryTitleY -= 4; + if (getIsSmall() && !small) inventoryLabelY -= 4; isSmall = small; int setY = -1; - ScreenHandler handler = getScreenHandler(); - if (handler instanceof CreativeInventoryScreen.CreativeScreenHandler) return; + AbstractContainerMenu handler = getMenu(); + if (handler instanceof CreativeModeInventoryScreen.ItemPickerMenu) return; for (int i = 0; i < handler.slots.size(); i++) { if (handler.slots.get(i) instanceof MovableSlot slot) - if (handler instanceof PlayerScreenHandler) { + if (handler instanceof InventoryMenu) { if (small) SmallInvMod.tryMoveSlot(slot); else slot.resetPos(); @@ -94,7 +96,7 @@ public void setIsSmall(boolean small) { if (small) { if (setY == -1) { setY = slot.y + 4; - if (handler instanceof GenericContainerScreenHandler) setY--; + if (handler instanceof ChestMenu) setY--; } if (i >= handler.slots.size() - 9) { slot.setPos(slot.x, setY); diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MidnightControlsMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MidnightControlsMixin.java index 70adc9e..fe2709b 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MidnightControlsMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MidnightControlsMixin.java @@ -1,7 +1,10 @@ package net.kyrptonaught.lemclienthelper.mixin.SmallInv; +import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding; import eu.midnightdust.midnightcontrols.client.controller.InputHandlers; -import net.minecraft.screen.slot.Slot; +import eu.midnightdust.midnightcontrols.client.enums.ButtonState; +import net.minecraft.client.Minecraft; +import net.minecraft.world.inventory.Slot; import org.aperlambda.lambdacommon.utils.Pair; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; @@ -13,8 +16,8 @@ @Mixin(InputHandlers.class) public class MidnightControlsMixin { - @Inject(method = "lambda$handleInventorySlotPad$16", at = @At(value = "HEAD"), cancellable = true) - private static void skipDisabledSlots(int guiLeft, int guiTop, double mouseX, double mouseY, Slot mouseSlot, int direction, Pair entry, CallbackInfoReturnable cir) { - if (!entry.key.isEnabled()) cir.setReturnValue(false); + @Inject(method = "lambda$handleInventorySlotPad$9", at = @At(value = "HEAD"), cancellable = true) + private static void skipDisabledSlots(int direction, Minecraft client, ButtonBinding binding, float value, ButtonState action, CallbackInfoReturnable cir) { + if (!binding.isAvailable()) cir.setReturnValue(false); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MinecraftClientMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MinecraftClientMixin.java index 85a4492..8b83038 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MinecraftClientMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/MinecraftClientMixin.java @@ -2,10 +2,11 @@ import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvMod; import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -13,16 +14,16 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(MinecraftClient.class) +@Mixin(Minecraft.class) public class MinecraftClientMixin { @Shadow @Nullable - public ClientPlayerEntity player; + public LocalPlayer player; - @Inject(method = "setScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", ordinal = 2)) + @Inject(method = "setScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;", ordinal = 2)) public void attemptOpenSmallInv(Screen screen, CallbackInfo ci) { - if (screen instanceof HandledScreen handledScreen) { + if (screen instanceof AbstractContainerScreen handledScreen) { ((SmallInvPlayerInv) handledScreen).setIsSmall(SmallInvMod.isSmallInv(player)); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/ScreenHandlerMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/ScreenHandlerMixin.java index e1ba801..e198bc0 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/ScreenHandlerMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/ScreenHandlerMixin.java @@ -1,12 +1,12 @@ package net.kyrptonaught.lemclienthelper.mixin.SmallInv; import net.kyrptonaught.lemclienthelper.SmallInv.MovableSlot; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.PlayerScreenHandler; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.util.collection.DefaultedList; +import net.minecraft.core.NonNullList; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -15,29 +15,29 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(ScreenHandler.class) +@Mixin(AbstractContainerMenu.class) public abstract class ScreenHandlerMixin { @Shadow @Final - public DefaultedList slots; + public NonNullList slots; @Shadow @Final - private DefaultedList trackedStacks; + private NonNullList lastSlots; @Shadow @Final - private DefaultedList previousTrackedStacks; + private NonNullList remoteSlots; @Inject(method = "addSlot", at = @At("HEAD"), cancellable = true) protected void addSlot(Slot slot, CallbackInfoReturnable cir) { - if (isPlayerScreen() || slot.inventory instanceof PlayerInventory) { + if (isPlayerScreen() || slot.container instanceof Inventory) { slot = new MovableSlot(slot); - slot.id = this.slots.size(); + slot.index = this.slots.size(); this.slots.add(slot); - this.trackedStacks.add(ItemStack.EMPTY); - this.previousTrackedStacks.add(ItemStack.EMPTY); + this.lastSlots.add(ItemStack.EMPTY); + this.remoteSlots.add(ItemStack.EMPTY); cir.setReturnValue(slot); } } @@ -45,6 +45,6 @@ protected void addSlot(Slot slot, CallbackInfoReturnable cir) { @Unique private boolean isPlayerScreen() { //this works but IDEA big mad - return (Object) this instanceof PlayerScreenHandler; + return (Object) this instanceof InventoryMenu; } } \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/AbstractRecipeBookScreenMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/AbstractRecipeBookScreenMixin.java new file mode 100644 index 0000000..ea0791f --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/AbstractRecipeBookScreenMixin.java @@ -0,0 +1,19 @@ +package net.kyrptonaught.lemclienthelper.mixin.SmallInv.invs; + +import net.minecraft.client.gui.components.ImageButton; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(AbstractRecipeBookScreen.class) +public class AbstractRecipeBookScreenMixin { + + @ModifyArg(method = "initButton", at = @At(target = "Lnet/minecraft/client/gui/screens/inventory/AbstractRecipeBookScreen;addRenderableWidget(Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;", value = "INVOKE")) + public GuiEventListener fkRecipeBook(GuiEventListener element) { + if (element instanceof ImageButton button) + RecipeBookWidget.bookWidget = button; + return element; + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/GenericContainerScreenMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/GenericContainerScreenMixin.java index 421afe4..e4515ce 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/GenericContainerScreenMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/GenericContainerScreenMixin.java @@ -1,38 +1,40 @@ package net.kyrptonaught.lemclienthelper.mixin.SmallInv.invs; +import com.mojang.blaze3d.pipeline.RenderPipeline; import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.screen.GenericContainerScreenHandler; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.ContainerScreen; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ChestMenu; 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; -@Mixin(GenericContainerScreen.class) -public abstract class GenericContainerScreenMixin extends HandledScreen implements SmallInvPlayerInv { +@Mixin(ContainerScreen.class) +public abstract class GenericContainerScreenMixin extends AbstractContainerScreen implements SmallInvPlayerInv { @Shadow @Final - private int rows; + private int containerRows; - public GenericContainerScreenMixin(ScreenHandler handler, PlayerInventory inventory, Text title) { - super((GenericContainerScreenHandler) handler, inventory, title); + public GenericContainerScreenMixin(AbstractContainerMenu handler, Inventory inventory, Component title) { + super((ChestMenu) handler, inventory, title); } - @Redirect(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", ordinal = 1)) - public void drawSmallInv(DrawContext instance, Identifier texture, int x, int y, int u, int v, int width, int height) { + @Redirect(method = "renderBg", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blit(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIFFIIII)V", ordinal = 1)) + public void drawSmallInv(GuiGraphics instance, RenderPipeline pipeline, ResourceLocation texture, int x, int y, float f, float g, int u, int v, int width, int height) { if (getIsSmall()) { - int j = (this.height - this.backgroundHeight) / 2; - instance.drawTexture(texture, x, j + this.rows * 18 + 17, 0, 126, this.backgroundWidth, 13); - instance.drawTexture(texture, x, j + (this.rows * 18 + 17) + 12, 0, 193, this.backgroundWidth, 29); - } else instance.drawTexture(texture, x, y, u, v, width, height); + int j = (this.height - this.imageHeight) / 2; + instance.blit(RenderPipelines.GUI_TEXTURED, texture, x, j + this.containerRows * 18 + 17, f, g, 0, 126, this.imageWidth, 13); + instance.blit(RenderPipelines.GUI_TEXTURED, texture, x, j + (this.containerRows * 18 + 17) + 12, f, g, 0, 193, this.imageWidth, 29); + } else instance.blit(RenderPipelines.GUI_TEXTURED, texture, x, y, f, g, u, v, width, height); } @Override diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/InventoryScreenMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/InventoryScreenMixin.java index e9727ce..75ffa69 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/InventoryScreenMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/InventoryScreenMixin.java @@ -1,67 +1,54 @@ package net.kyrptonaught.lemclienthelper.mixin.SmallInv.invs; -import com.mojang.blaze3d.systems.RenderSystem; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.Element; -import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; -import net.minecraft.client.gui.screen.ingame.InventoryScreen; -import net.minecraft.client.gui.widget.TexturedButtonWidget; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.screen.PlayerScreenHandler; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen; +import net.minecraft.client.gui.screens.inventory.InventoryScreen; +import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.InventoryMenu; 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.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(InventoryScreen.class) -public abstract class InventoryScreenMixin extends AbstractInventoryScreen implements SmallInvPlayerInv { +public abstract class InventoryScreenMixin extends AbstractRecipeBookScreen implements SmallInvPlayerInv { @Shadow - private float mouseX; + private float xMouse; @Shadow - private float mouseY; - private static final Identifier TEXTURE = Identifier.of(LEMClientHelperMod.MOD_ID, "textures/gui/legacy_inventory.png"); + private float yMouse; + private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(LEMClientHelperMod.MOD_ID, "textures/gui/legacy_inventory.png"); - private static TexturedButtonWidget bookWidget; - - public InventoryScreenMixin(PlayerScreenHandler screenHandler, PlayerInventory playerInventory, Text text) { - super(screenHandler, playerInventory, text); - } - - @ModifyArg(method = "init", at = @At(target = "Lnet/minecraft/client/gui/screen/ingame/InventoryScreen;addDrawableChild(Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;", value = "INVOKE")) - public Element fkRecipeBook(Element element) { - if (element instanceof TexturedButtonWidget button) - bookWidget = button; - return element; + public InventoryScreenMixin(InventoryMenu screenHandler, RecipeBookComponent recipeBookComponent, Inventory playerInventory, Component text) { + super(screenHandler, recipeBookComponent, playerInventory, text); } - @Inject(method = "drawForeground", at = @At("HEAD"), cancellable = true) - public void smallInvTitle(DrawContext context, int mouseX, int mouseY, CallbackInfo ci) { + @Inject(method = "renderLabels", at = @At("HEAD"), cancellable = true) + public void smallInvTitle(GuiGraphics context, int mouseX, int mouseY, CallbackInfo ci) { if (getIsSmall()) { - context.drawText(this.textRenderer, Text.translatable("container.inventory"), 6, 86, 0x404040, false); + context.drawString(this.font, Component.translatable("container.inventory"), 6, 86, 0x404040, false); ci.cancel(); } } - @Inject(method = "drawBackground", at = @At("HEAD"), cancellable = true) - public void smallInv(DrawContext context, float delta, int mouseX, int mouseY, CallbackInfo ci) { + @Inject(method = "renderBg", at = @At("HEAD"), cancellable = true) + public void smallInv(GuiGraphics context, float delta, int mouseX, int mouseY, CallbackInfo ci) { if (getIsSmall()) { - this.backgroundHeight = 124; - bookWidget.visible = false; - RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); - context.drawTexture(TEXTURE, x, y, 0, 0, this.backgroundWidth, this.backgroundHeight, this.backgroundWidth, this.backgroundHeight); - InventoryScreen.drawEntity(context, x + 26 + 52, y + 8 + 2, x + 75 + 52, y + 78 + 2, 30, 0.0625f, this.mouseX, this.mouseY, this.client.player); + int k = this.leftPos; + int l = this.topPos; + this.imageHeight = 124; + RecipeBookWidget.bookWidget.visible = false; + context.blit(TEXTURE, k, l, 0, 0, this.imageWidth, this.imageHeight, this.imageWidth, this.imageHeight); + InventoryScreen.renderEntityInInventoryFollowsMouse(context, k + 26 + 52, l + 8 + 2, k + 75 + 52, l + 78 + 2, 30, 0.0625f, this.xMouse, this.yMouse, this.minecraft.player); ci.cancel(); } else { - this.backgroundHeight = 166; - bookWidget.visible = true; + this.imageHeight = 166; + RecipeBookWidget.bookWidget.visible = true; } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/MultipleScreenMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/MultipleScreenMixin.java index c351c31..d305f4f 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/MultipleScreenMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/MultipleScreenMixin.java @@ -1,9 +1,12 @@ package net.kyrptonaught.lemclienthelper.mixin.SmallInv.invs; +import com.mojang.blaze3d.pipeline.RenderPipeline; import net.kyrptonaught.lemclienthelper.SmallInv.SmallInvPlayerInv; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ingame.*; -import net.minecraft.util.Identifier; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.*; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -14,28 +17,28 @@ CartographyTableScreen.class, CraftingScreen.class, EnchantmentScreen.class, - ForgingScreen.class, + ItemCombinerScreen.class, AbstractFurnaceScreen.class, - Generic3x3ContainerScreen.class, + DispenserScreen.class, GrindstoneScreen.class, HopperScreen.class, - HorseScreen.class, + HorseInventoryScreen.class, LoomScreen.class, ShulkerBoxScreen.class, StonecutterScreen.class }) public abstract class MultipleScreenMixin implements SmallInvPlayerInv { - @Redirect(method = "drawBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", ordinal = 0)) - public void drawSmallInv(DrawContext instance, Identifier texture, int x, int y, int u, int v, int width, int height) { + @Redirect(method = "renderBg", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blit(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIFFIIII)V", ordinal = 0)) + public void drawSmallInv(GuiGraphics instance, RenderPipeline pipeline, ResourceLocation texture, int x, int y, float f, float g, int u, int v, int width, int height) { if (getIsSmall()) { - if ((HandledScreen) (Object) this instanceof ShulkerBoxScreen) height--; - instance.drawTexture(texture, x, y, 0, 0, width, height - 83); //shrink orig texture + if ((AbstractContainerScreen) (Object) this instanceof ShulkerBoxScreen) height--; + instance.blit(RenderPipelines.GUI_TEXTURED, texture, x, y, f, g, 0, 0, width, height - 83); //shrink orig texture - instance.drawTexture(texture, x, y + (height - 83) - 1, 0, height - 30, width, 30);//draw hotbar - instance.drawTexture(texture, x, y + (height - 83) - 1, 0, height - 86, width, 2); //add extra separator - } else instance.drawTexture(texture, x, y, u, v, width, height); + instance.blit(RenderPipelines.GUI_TEXTURED, texture, x, y + (height - 83) - 1, f, g, 0, height - 30, width, 30);//draw hotbar + instance.blit(RenderPipelines.GUI_TEXTURED, texture, x, y + (height - 83) - 1, f, g, 0, height - 86, width, 2); //add extra separator + } else instance.blit(RenderPipelines.GUI_TEXTURED, texture, x, y, f, g, u, v, width, height); } @Override diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/RecipeBookWidget.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/RecipeBookWidget.java new file mode 100644 index 0000000..2b7dc89 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SmallInv/invs/RecipeBookWidget.java @@ -0,0 +1,7 @@ +package net.kyrptonaught.lemclienthelper.mixin.SmallInv.invs; + +import net.minecraft.client.gui.components.ImageButton; + +public class RecipeBookWidget { + public static ImageButton bookWidget; +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SpectateSquaker/MinecraftClientMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SpectateSquaker/MinecraftClientMixin.java index 1fc6cad..99ac405 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SpectateSquaker/MinecraftClientMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SpectateSquaker/MinecraftClientMixin.java @@ -1,10 +1,11 @@ package net.kyrptonaught.lemclienthelper.mixin.SpectateSquaker; import net.kyrptonaught.lemclienthelper.SpectateSqueaker.SpectateSqueakerNetworking; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.option.GameOptions; -import net.minecraft.entity.Entity; +import net.minecraft.client.Minecraft; +import net.minecraft.client.Options; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -13,23 +14,23 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(MinecraftClient.class) +@Mixin(Minecraft.class) public abstract class MinecraftClientMixin { @Shadow @Nullable - public ClientPlayerEntity player; + public LocalPlayer player; @Shadow public abstract @Nullable Entity getCameraEntity(); @Shadow @Final - public GameOptions options; + public Options options; - @Inject(method = "handleInputEvents", at = @At(value = "TAIL")) + @Inject(method = "handleKeybinds", at = @At(value = "TAIL")) public void trySqueak(CallbackInfo ci) { - if (player != null && player.isSpectator() && (this.player.equals(getCameraEntity())) && options.attackKey.isPressed()) + if (player != null && player.isSpectator() && (this.player.equals(getCameraEntity())) && options.keyAttack.isDown()) SpectateSqueakerNetworking.sendSqueakPacket(); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SyncedKeybinds/GameOptionsMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SyncedKeybinds/GameOptionsMixin.java index 596dddf..d0a6400 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SyncedKeybinds/GameOptionsMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/SyncedKeybinds/GameOptionsMixin.java @@ -1,8 +1,8 @@ package net.kyrptonaught.lemclienthelper.mixin.SyncedKeybinds; import net.kyrptonaught.lemclienthelper.syncedKeybinds.GameOptionKeyExpander; -import net.minecraft.client.option.GameOptions; -import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.KeyMapping; +import net.minecraft.client.Options; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; @@ -12,25 +12,25 @@ import java.util.Arrays; import java.util.List; -@Mixin(GameOptions.class) +@Mixin(Options.class) public class GameOptionsMixin implements GameOptionKeyExpander { @Mutable @Final @Shadow - public KeyBinding[] allKeys; + public KeyMapping[] keyMappings; @Override - public void addSyncedKeybinds(KeyBinding newKeybinding) { - allKeys = Arrays.copyOf(allKeys, allKeys.length + 1); + public void addSyncedKeybinds(KeyMapping newKeybinding) { + keyMappings = Arrays.copyOf(keyMappings, keyMappings.length + 1); - allKeys[allKeys.length - 1] = newKeybinding; + keyMappings[keyMappings.length - 1] = newKeybinding; } @Override - public void removeSyncedKeybinds(KeyBinding newKeybinding) { - List bindings = new ArrayList<>(List.of(allKeys)); + public void removeSyncedKeybinds(KeyMapping newKeybinding) { + List bindings = new ArrayList<>(List.of(keyMappings)); bindings.remove(newKeybinding); - allKeys = bindings.toArray(new KeyBinding[0]); + keyMappings = bindings.toArray(new KeyMapping[0]); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/TakeEverything/ScreenHandlerMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/TakeEverything/ScreenHandlerMixin.java index 71cca2b..0ada107 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/TakeEverything/ScreenHandlerMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/TakeEverything/ScreenHandlerMixin.java @@ -1,28 +1,30 @@ package net.kyrptonaught.lemclienthelper.mixin.TakeEverything; +import com.mojang.blaze3d.platform.InputConstants; import net.kyrptonaught.lemclienthelper.TakeEverything.TakeEverythingMod; import net.kyrptonaught.lemclienthelper.TakeEverything.TakeEverythingNetworking; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.util.InputUtil; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.input.KeyEvent; +import net.minecraft.client.input.MouseButtonEvent; 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.CallbackInfoReturnable; -@Mixin(HandledScreen.class) +@Mixin(AbstractContainerScreen.class) public abstract class ScreenHandlerMixin { @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - private void lephelper$mouseClicked(double x, double y, int button, CallbackInfoReturnable callbackInfoReturnable) { - if (TakeEverythingMod.isKeybindPressed(button, InputUtil.Type.MOUSE)) { + private void lephelper$mouseClicked(MouseButtonEvent mouseButtonEvent, boolean bl, CallbackInfoReturnable callbackInfoReturnable) { + if (TakeEverythingMod.isKeybindPressed(mouseButtonEvent.button(), InputConstants.Type.MOUSE)) { TakeEverythingNetworking.sendTakeEverythingPacket(); callbackInfoReturnable.setReturnValue(true); } } @Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true) - private void lebhelper$keyPressed(int keycode, int scancode, int modifiers, CallbackInfoReturnable callbackInfoReturnable) { - if (TakeEverythingMod.isKeybindPressed(keycode, InputUtil.Type.KEYSYM)) { + private void lebhelper$keyPressed(KeyEvent keyEvent, CallbackInfoReturnable callbackInfoReturnable) { + if (TakeEverythingMod.isKeybindPressed(keyEvent.key(), InputConstants.Type.KEYSYM)) { TakeEverythingNetworking.sendTakeEverythingPacket(); callbackInfoReturnable.setReturnValue(true); } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/bookGui/BookScreenMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/bookGui/BookScreenMixin.java index fb3dc3d..659068c 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/bookGui/BookScreenMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/bookGui/BookScreenMixin.java @@ -1,8 +1,9 @@ package net.kyrptonaught.lemclienthelper.mixin.bookGui; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ingame.BookScreen; -import net.minecraft.text.Style; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.inventory.BookViewScreen; +import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.Style; import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -11,22 +12,22 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(BookScreen.class) +@Mixin(BookViewScreen.class) public class BookScreenMixin { @Unique private static Double mouseX, mouseY; - @Inject(method = "handleTextClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/BookScreen;closeScreen()V")) - public void saveMouse(Style style, CallbackInfoReturnable cir) { - mouseX = MinecraftClient.getInstance().mouse.getX(); - mouseY = MinecraftClient.getInstance().mouse.getY(); + @Inject(method = "handleClickEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/BookViewScreen;closeContainerOnServer()V")) + public void saveMouse(Minecraft minecraft, ClickEvent clickEvent, CallbackInfo ci) { + mouseX = Minecraft.getInstance().mouseHandler.xpos(); + mouseY = Minecraft.getInstance().mouseHandler.ypos(); } @Inject(method = "init", at = @At(value = "HEAD")) public void loadMouse(CallbackInfo ci) { if (mouseX != null && mouseY != null) { - GLFW.glfwSetCursorPos(MinecraftClient.getInstance().getWindow().getHandle(), mouseX, mouseY); + GLFW.glfwSetCursorPos(Minecraft.getInstance().getWindow().handle(), mouseX, mouseY); mouseX = null; mouseY = null; } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/customWorldBorder/WorldBorderMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/customWorldBorder/WorldBorderMixin.java index d2ab42c..32f9dc7 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/customWorldBorder/WorldBorderMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/customWorldBorder/WorldBorderMixin.java @@ -2,8 +2,8 @@ import net.kyrptonaught.lemclienthelper.customWorldBorder.CustomWorldBorderArea; import net.kyrptonaught.lemclienthelper.customWorldBorder.duckInterface.CustomWorldBorder; -import net.minecraft.world.border.WorldBorder; -import net.minecraft.world.border.WorldBorderListener; +import net.minecraft.world.level.border.WorldBorder; +import net.minecraft.world.level.border.BorderChangeListener; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -14,7 +14,7 @@ public abstract class WorldBorderMixin implements CustomWorldBorder { @Shadow - private WorldBorder.Area area; + private WorldBorder.BorderExtent extent; @Shadow public abstract void setCenter(double x, double z); @@ -25,7 +25,7 @@ public abstract class WorldBorderMixin implements CustomWorldBorder { @Override public void setShape(double xCenter, double zCenter, double xSize, double zSize) { setCenter(xCenter, zCenter); - this.area = new CustomWorldBorderArea((WorldBorder) (Object) this, xSize, zSize); + this.extent = new CustomWorldBorderArea((WorldBorder) (Object) this, xSize, zSize); } @Override @@ -35,7 +35,7 @@ public void setShape(double xCenter, double zCenter, double size) { } @Inject(method = "addListener", at = @At("HEAD"), cancellable = true) - public void noListeners(WorldBorderListener listener, CallbackInfo ci) { + public void noListeners(BorderChangeListener listener, CallbackInfo ci) { ci.cancel(); } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/hud/genericHud/HideVanillaHUDMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/hud/genericHud/HideVanillaHUDMixin.java new file mode 100644 index 0000000..87d799c --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/hud/genericHud/HideVanillaHUDMixin.java @@ -0,0 +1,28 @@ +package net.kyrptonaught.lemclienthelper.mixin.hud.genericHud; + + +import net.kyrptonaught.lemclienthelper.hud.genericHud.HideVanillaHUD; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiGraphics; +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; + +@Mixin(Gui.class) +public class HideVanillaHUDMixin { + @Inject(method = "renderHotbarAndDecorations", at= @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/contextualbar/ContextualBarRenderer;render(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V"), cancellable = true) + void disableContextualBar(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) { + if (!HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.EXPERIENCE, true) || !HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.ALL,true)) {ci.cancel();} + } + @Inject(method = "renderHotbarAndDecorations", at= @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/contextualbar/ContextualBarRenderer;renderBackground(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V"), cancellable = true) + void disableContextualBarBg(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) { + if (!HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.EXPERIENCE, true) || !HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.ALL,true)) {ci.cancel();} + } + + @Inject(method = "renderHotbarAndDecorations", at= @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/contextualbar/ContextualBarRenderer;renderExperienceLevel(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/gui/Font;I)V"), cancellable = true) + void disableExperienceLevel(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) { + if (!HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.EXPERIENCE, true) || !HideVanillaHUD.visible.getOrDefault(HideVanillaHUD.HUD_ELEMENT.ALL,true)) {ci.cancel();} + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/hud/genericHud/PlayerBarMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/hud/genericHud/PlayerBarMixin.java new file mode 100644 index 0000000..b3b18b2 --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/hud/genericHud/PlayerBarMixin.java @@ -0,0 +1,19 @@ +package net.kyrptonaught.lemclienthelper.mixin.hud.genericHud; + +import net.kyrptonaught.lemclienthelper.hud.genericHud.GenericHudMod; +import net.kyrptonaught.lemclienthelper.hud.genericHud.PlayerBarRenderer; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiGraphics; +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; + +@Mixin(Gui.class) +public class PlayerBarMixin { + @Inject(method = "renderHotbarAndDecorations", at= @At(value = "HEAD")) + void renderPlayerBar(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci){ + PlayerBarRenderer.renderPlayerBar(guiGraphics,deltaTracker); + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/GameOptionKeyExpander.java b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/GameOptionKeyExpander.java index 2cdeb7f..81082fb 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/GameOptionKeyExpander.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/GameOptionKeyExpander.java @@ -1,10 +1,10 @@ package net.kyrptonaught.lemclienthelper.syncedKeybinds; -import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.KeyMapping; public interface GameOptionKeyExpander { - void addSyncedKeybinds(KeyBinding newKeybinding); + void addSyncedKeybinds(KeyMapping newKeybinding); - void removeSyncedKeybinds(KeyBinding newKeybinding); + void removeSyncedKeybinds(KeyMapping newKeybinding); } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/KeybindPressPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/KeybindPressPacket.java index d8b4d12..c27ee48 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/KeybindPressPacket.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/KeybindPressPacket.java @@ -1,17 +1,16 @@ package net.kyrptonaught.lemclienthelper.syncedKeybinds; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; - -public record KeybindPressPacket(Identifier keybind) implements CustomPayload { - public static final Id PACKET_ID = new Id<>(Identifier.of(SyncedKeybindsMod.MOD_ID, "sync_keybinds_packet")); - public static final PacketCodec codec = Identifier.PACKET_CODEC.xmap(KeybindPressPacket::new, KeybindPressPacket::keybind).cast(); +public record KeybindPressPacket(ResourceLocation keybind) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath(SyncedKeybindsMod.MOD_ID, "sync_keybinds_packet")); + public static final StreamCodec codec = ResourceLocation.STREAM_CODEC.map(KeybindPressPacket::new, KeybindPressPacket::keybind).cast(); @Override - public Id getId() { + public Type type() { return PACKET_ID; } } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncKeybindsPacket.java b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncKeybindsPacket.java index 43af0a3..c103b14 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncKeybindsPacket.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncKeybindsPacket.java @@ -1,33 +1,34 @@ package net.kyrptonaught.lemclienthelper.syncedKeybinds; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; import java.util.HashMap; public record SyncKeybindsPacket( - HashMap keybinds) implements CustomPayload { - public static final Id PACKET_ID = new Id<>(Identifier.of(SyncedKeybindsMod.MOD_ID, "keybind_pressed_packet")); - public static final PacketCodec codec = PacketCodec.of(SyncKeybindsPacket::write, SyncKeybindsPacket::read); + HashMap keybinds) implements CustomPacketPayload { + public static final Type PACKET_ID = new Type<>(ResourceLocation.fromNamespaceAndPath(SyncedKeybindsMod.MOD_ID, "keybind_pressed_packet")); + public static final StreamCodec codec = StreamCodec.ofMember(SyncKeybindsPacket::write, SyncKeybindsPacket::read); - public static SyncKeybindsPacket read(RegistryByteBuf buf) { + public static SyncKeybindsPacket read(RegistryFriendlyByteBuf buf) { int size = buf.readInt(); - HashMap keybinds = new HashMap<>(size); + HashMap keybinds = new HashMap<>(size); for (int i = 0; i < size; i++) { - keybinds.put(buf.readIdentifier(), new SyncedKeybindsConfig.KeybindConfigItem(buf.readString(), buf.readString())); + keybinds.put(buf.readResourceLocation(), new SyncedKeybindsConfig.KeybindConfigItem(buf.readUtf(), buf.readUtf())); } return new SyncKeybindsPacket(keybinds); } - public void write(RegistryByteBuf buf) { + public void write(RegistryFriendlyByteBuf buf) { } @Override - public Id getId() { + public Type type() { return PACKET_ID; } } \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybind.java b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybind.java index 767a3d0..86a4553 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybind.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybind.java @@ -4,15 +4,15 @@ import net.kyrptonaught.kyrptconfig.keybinding.CustomKeyBinding; import net.kyrptonaught.kyrptconfig.keybinding.DisplayOnlyKeyBind; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.util.Identifier; +import net.minecraft.client.KeyMapping; +import net.minecraft.resources.ResourceLocation; public class SyncedKeybind { - public Identifier ID; + public ResourceLocation ID; private final CustomKeyBinding keyBinding; - private KeyBinding vanillaBind; + private KeyMapping vanillaBind; - public SyncedKeybind(Identifier id, SyncedKeybindsConfig.KeybindConfigItem keybindConfigItem) { + public SyncedKeybind(ResourceLocation id, SyncedKeybindsConfig.KeybindConfigItem keybindConfigItem) { this.ID = id; keyBinding = CustomKeyBinding.configDefault(SyncedKeybindsMod.MOD_ID, keybindConfigItem.defaultKeybinding); keyBinding.setRaw(keybindConfigItem.keybinding); @@ -26,10 +26,10 @@ public boolean isHeld() { return keyBinding.isKeybindPressed(); } - public KeyBinding getVanillaBind() { + public KeyMapping getVanillaBind() { if (vanillaBind == null) vanillaBind = new NonConflictingKeyBinding( - ID.toTranslationKey("lch.key.sync"), + ID.toLanguageKey("lch.key.sync"), "key.category." + LEMClientHelperMod.MOD_ID, keyBinding, setKey -> { diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsConfig.java b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsConfig.java index f7a63e4..03969eb 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsConfig.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsConfig.java @@ -1,13 +1,13 @@ package net.kyrptonaught.lemclienthelper.syncedKeybinds; import net.kyrptonaught.kyrptconfig.config.AbstractConfigFile; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import java.util.HashMap; public class SyncedKeybindsConfig implements AbstractConfigFile { - public HashMap keybinds = new HashMap<>(); + public HashMap keybinds = new HashMap<>(); public static class KeybindConfigItem { public String keybinding; diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsMod.java index 96bd423..ea6dff3 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsMod.java @@ -4,15 +4,15 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; -import net.minecraft.client.MinecraftClient; -import net.minecraft.util.Identifier; +import net.minecraft.client.Minecraft; +import net.minecraft.resources.ResourceLocation; import java.util.HashMap; public class SyncedKeybindsMod { public static final String MOD_ID = "syncedkeybinds"; - public static HashMap syncedKeybindList = new HashMap<>(); + public static HashMap syncedKeybindList = new HashMap<>(); public static void onInitialize() { LEMClientHelperMod.configManager.registerGsonFile(MOD_ID, new SyncedKeybindsConfig()); @@ -21,7 +21,7 @@ public static void onInitialize() { PayloadTypeRegistry.playS2C().register(SyncKeybindsPacket.PACKET_ID, SyncKeybindsPacket.codec); SyncedKeybindsNetworking.registerReceivePacket(); ClientTickEvents.START_WORLD_TICK.register((world) -> { - if (MinecraftClient.getInstance().currentScreen == null) { + if (Minecraft.getInstance().screen == null) { syncedKeybindList.values().forEach(syncedKeybind -> { if (syncedKeybind.wasPressed()) SyncedKeybindsNetworking.sendKeyPacket(syncedKeybind.ID); @@ -30,14 +30,14 @@ public static void onInitialize() { }); ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { syncedKeybindList.values().forEach(syncedKeybind -> { - ((GameOptionKeyExpander) MinecraftClient.getInstance().options).removeSyncedKeybinds(syncedKeybind.getVanillaBind()); + ((GameOptionKeyExpander) Minecraft.getInstance().options).removeSyncedKeybinds(syncedKeybind.getVanillaBind()); }); syncedKeybindList.clear(); }); } - public static void registerNewKeybind(Identifier id, String keybind, String controllerbind) { + public static void registerNewKeybind(ResourceLocation id, String keybind, String controllerbind) { getConfig().keybinds.putIfAbsent(id, new SyncedKeybindsConfig.KeybindConfigItem(keybind, controllerbind)); SyncedKeybindsConfig.KeybindConfigItem keybindConfigItem = getConfig().keybinds.get(id); keybindConfigItem.updateDefaults(keybind, controllerbind); @@ -45,7 +45,7 @@ public static void registerNewKeybind(Identifier id, String keybind, String cont SyncedKeybind syncedKeybind = new SyncedKeybind(id, keybindConfigItem); syncedKeybindList.put(id, syncedKeybind); - ((GameOptionKeyExpander) MinecraftClient.getInstance().options).addSyncedKeybinds(syncedKeybind.getVanillaBind()); + ((GameOptionKeyExpander) Minecraft.getInstance().options).addSyncedKeybinds(syncedKeybind.getVanillaBind()); } public static SyncedKeybindsConfig getConfig() { diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsNetworking.java b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsNetworking.java index adb6d9c..6702104 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsNetworking.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/syncedKeybinds/SyncedKeybindsNetworking.java @@ -4,12 +4,12 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; public class SyncedKeybindsNetworking { @Environment(EnvType.CLIENT) - public static void sendKeyPacket(Identifier keyID) { + public static void sendKeyPacket(ResourceLocation keyID) { ClientPlayNetworking.send(new KeybindPressPacket(keyID)); } diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/1.png b/src/main/resources/assets/lem.base/textures/playerbar/big/1.png new file mode 100644 index 0000000..69c02c2 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/1.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/10.png b/src/main/resources/assets/lem.base/textures/playerbar/big/10.png new file mode 100644 index 0000000..6f74472 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/10.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/2.png b/src/main/resources/assets/lem.base/textures/playerbar/big/2.png new file mode 100644 index 0000000..d1c62f5 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/2.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/3.png b/src/main/resources/assets/lem.base/textures/playerbar/big/3.png new file mode 100644 index 0000000..2e3a499 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/3.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/4.png b/src/main/resources/assets/lem.base/textures/playerbar/big/4.png new file mode 100644 index 0000000..c60e0f4 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/4.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/5.png b/src/main/resources/assets/lem.base/textures/playerbar/big/5.png new file mode 100644 index 0000000..72b1fc1 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/5.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/6.png b/src/main/resources/assets/lem.base/textures/playerbar/big/6.png new file mode 100644 index 0000000..42a8657 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/6.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/7.png b/src/main/resources/assets/lem.base/textures/playerbar/big/7.png new file mode 100644 index 0000000..3da985a Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/7.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/8.png b/src/main/resources/assets/lem.base/textures/playerbar/big/8.png new file mode 100644 index 0000000..b2f6480 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/8.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/9.png b/src/main/resources/assets/lem.base/textures/playerbar/big/9.png new file mode 100644 index 0000000..57a0fb0 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/9.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/big/dead.png b/src/main/resources/assets/lem.base/textures/playerbar/big/dead.png new file mode 100644 index 0000000..e83426b Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/big/dead.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/1.png b/src/main/resources/assets/lem.base/textures/playerbar/small/1.png new file mode 100644 index 0000000..5f93119 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/1.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/10.png b/src/main/resources/assets/lem.base/textures/playerbar/small/10.png new file mode 100644 index 0000000..7a5002b Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/10.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/11.png b/src/main/resources/assets/lem.base/textures/playerbar/small/11.png new file mode 100644 index 0000000..0f6b89c Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/11.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/12.png b/src/main/resources/assets/lem.base/textures/playerbar/small/12.png new file mode 100644 index 0000000..d60b8c2 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/12.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/13.png b/src/main/resources/assets/lem.base/textures/playerbar/small/13.png new file mode 100644 index 0000000..c30afd5 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/13.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/14.png b/src/main/resources/assets/lem.base/textures/playerbar/small/14.png new file mode 100644 index 0000000..13ac1ee Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/14.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/15.png b/src/main/resources/assets/lem.base/textures/playerbar/small/15.png new file mode 100644 index 0000000..8412d0b Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/15.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/16.png b/src/main/resources/assets/lem.base/textures/playerbar/small/16.png new file mode 100644 index 0000000..e901a6a Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/16.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/2.png b/src/main/resources/assets/lem.base/textures/playerbar/small/2.png new file mode 100644 index 0000000..0c8e2e0 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/2.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/3.png b/src/main/resources/assets/lem.base/textures/playerbar/small/3.png new file mode 100644 index 0000000..2d7f7d0 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/3.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/4.png b/src/main/resources/assets/lem.base/textures/playerbar/small/4.png new file mode 100644 index 0000000..94bee15 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/4.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/5.png b/src/main/resources/assets/lem.base/textures/playerbar/small/5.png new file mode 100644 index 0000000..f4b0561 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/5.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/6.png b/src/main/resources/assets/lem.base/textures/playerbar/small/6.png new file mode 100644 index 0000000..073c990 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/6.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/7.png b/src/main/resources/assets/lem.base/textures/playerbar/small/7.png new file mode 100644 index 0000000..5e8fbd2 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/7.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/8.png b/src/main/resources/assets/lem.base/textures/playerbar/small/8.png new file mode 100644 index 0000000..eaf1743 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/8.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/9.png b/src/main/resources/assets/lem.base/textures/playerbar/small/9.png new file mode 100644 index 0000000..ff43fa3 Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/9.png differ diff --git a/src/main/resources/assets/lem.base/textures/playerbar/small/dead.png b/src/main/resources/assets/lem.base/textures/playerbar/small/dead.png new file mode 100644 index 0000000..4b98ecc Binary files /dev/null and b/src/main/resources/assets/lem.base/textures/playerbar/small/dead.png differ diff --git a/src/main/resources/assets/lemclienthelper/lang/en_us.json b/src/main/resources/assets/lemclienthelper/lang/en_us.json index dba56c1..894cf23 100644 --- a/src/main/resources/assets/lemclienthelper/lang/en_us.json +++ b/src/main/resources/assets/lemclienthelper/lang/en_us.json @@ -21,9 +21,10 @@ "key.lemclienthelper.downloading": "Downloading...", "key.lemclienthelper.smallinv": "Small Inv", "key.lemclienthelper.smallinv.enabled": "Enabled", - "key.lemclienthelper.clientgui": "Armor HUD", + "key.lemclienthelper.clientgui": "HUD", "key.lemclienthelper.clientgui.enabled": "Enabled Armor HUD", "key.lemclienthelper.clientgui.alwaysshow": "Always Show Armor HUD", + "key.lemclienthelper.clientgui.glidealwaysshow": "Always Show Glide HUD", "key.lemclienthelper.clientgui.armorscale": "Armor HUD Scale Modifier", "key.lemclienthelper.clientgui.armorscale.tooltip": "Sets the scale the Armor HUD will be rendered at.\nValues between 1-4.", "key.lemclienthelper.clientgui.xOffset": "Armor HUD X Offset", diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/banner.png b/src/main/resources/assets/lemclienthelper/textures/gui/banner.png new file mode 100644 index 0000000..b120947 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/banner.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/battle/shield_icon.png b/src/main/resources/assets/lemclienthelper/textures/gui/battle/shield_icon.png new file mode 100644 index 0000000..e9306c2 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/battle/shield_icon.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/score_icon.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/score_icon.png new file mode 100644 index 0000000..1459d9f Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/score_icon.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/shield_icon.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/shield_icon.png new file mode 100644 index 0000000..39fb74d Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/shield_icon.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_0.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_0.png new file mode 100644 index 0000000..8842d7a Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_0.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_1.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_1.png new file mode 100644 index 0000000..459468d Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_1.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_10.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_10.png new file mode 100644 index 0000000..ca71cf9 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_10.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_11.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_11.png new file mode 100644 index 0000000..e229aba Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_11.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_2.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_2.png new file mode 100644 index 0000000..3e26c44 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_2.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_3.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_3.png new file mode 100644 index 0000000..eadf850 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_3.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_4.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_4.png new file mode 100644 index 0000000..b710d82 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_4.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_5.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_5.png new file mode 100644 index 0000000..b22bf84 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_5.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_6.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_6.png new file mode 100644 index 0000000..1572075 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_6.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_7.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_7.png new file mode 100644 index 0000000..1d0a664 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_7.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_8.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_8.png new file mode 100644 index 0000000..02053c0 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_8.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_9.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_9.png new file mode 100644 index 0000000..ebf48a8 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/needle_9.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/speedometer.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/speedometer.png new file mode 100644 index 0000000..1513a23 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/speedometer/speedometer.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/clock.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/clock.png new file mode 100644 index 0000000..5c22499 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/clock.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_0.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_0.png new file mode 100644 index 0000000..2ca85dc Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_0.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_1.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_1.png new file mode 100644 index 0000000..31cc0c8 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_1.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_10.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_10.png new file mode 100644 index 0000000..00b686b Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_10.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_11.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_11.png new file mode 100644 index 0000000..632c40e Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_11.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_2.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_2.png new file mode 100644 index 0000000..eef879c Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_2.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_3.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_3.png new file mode 100644 index 0000000..3d5dd76 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_3.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_4.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_4.png new file mode 100644 index 0000000..289c8b1 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_4.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_5.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_5.png new file mode 100644 index 0000000..7845fae Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_5.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_6.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_6.png new file mode 100644 index 0000000..9c2fbac Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_6.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_7.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_7.png new file mode 100644 index 0000000..a2c4990 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_7.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_8.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_8.png new file mode 100644 index 0000000..add7884 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_8.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_9.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_9.png new file mode 100644 index 0000000..faaac48 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/minutes_9.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_0.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_0.png new file mode 100644 index 0000000..823e2fd Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_0.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_1.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_1.png new file mode 100644 index 0000000..581ade2 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_1.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_10.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_10.png new file mode 100644 index 0000000..2fc4268 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_10.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_11.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_11.png new file mode 100644 index 0000000..207bcfc Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_11.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_2.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_2.png new file mode 100644 index 0000000..fd9671b Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_2.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_3.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_3.png new file mode 100644 index 0000000..54a4f8d Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_3.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_4.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_4.png new file mode 100644 index 0000000..d0c83a0 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_4.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_5.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_5.png new file mode 100644 index 0000000..ae65db9 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_5.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_6.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_6.png new file mode 100644 index 0000000..ce7dd27 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_6.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_7.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_7.png new file mode 100644 index 0000000..1504ec3 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_7.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_8.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_8.png new file mode 100644 index 0000000..201e91a Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_8.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_9.png b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_9.png new file mode 100644 index 0000000..e823ec2 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/glide/timer/seconds_9.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/shield.png b/src/main/resources/assets/lemclienthelper/textures/gui/shield.png new file mode 100644 index 0000000..1cf735b Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/shield.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/stopwatch_icon.png b/src/main/resources/assets/lemclienthelper/textures/gui/stopwatch_icon.png new file mode 100644 index 0000000..f9ec4d1 Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/stopwatch_icon.png differ diff --git a/src/main/resources/assets/lemclienthelper/textures/gui/tumble/shield_icon.png b/src/main/resources/assets/lemclienthelper/textures/gui/tumble/shield_icon.png new file mode 100644 index 0000000..65d1ddd Binary files /dev/null and b/src/main/resources/assets/lemclienthelper/textures/gui/tumble/shield_icon.png differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a6414d4..0c1be72 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "lemclienthelper", - "version": "0.0.27-1.21", + "version": "${version}", "name": "LEM Client Helper", "description": "LEM Client Helper", "authors": [ @@ -16,7 +16,7 @@ "homepage": "https://github.com/Legacy-Edition-Minigames/lemclienthelper", "sources": "https://github.com/Legacy-Edition-Minigames/lemclienthelper" }, - "license": "MIT", + "license": "PolyForm-Perimeter-1.0.0", "icon": "assets/lemclienthelper/icon.png", "environment": "client", "entrypoints": { @@ -36,8 +36,5 @@ ], "depends": { "fabric": "*" - }, - "breaks": { - "legacy": "*" } } diff --git a/src/main/resources/lemclienthelper.accesswidener b/src/main/resources/lemclienthelper.accesswidener index d481a2b..7c721a9 100644 --- a/src/main/resources/lemclienthelper.accesswidener +++ b/src/main/resources/lemclienthelper.accesswidener @@ -1,8 +1,8 @@ accessWidener v1 named # small inv -mutable field net/minecraft/screen/slot/Slot x I -mutable field net/minecraft/screen/slot/Slot y I +mutable field net/minecraft/world/inventory/Slot x I +mutable field net/minecraft/world/inventory/Slot y I # customWorldBorder -accessible class net/minecraft/world/border/WorldBorder$Area \ No newline at end of file +accessible class net/minecraft/world/level/border/WorldBorder$BorderExtent \ No newline at end of file diff --git a/src/main/resources/lemclienthelper.mixins.json b/src/main/resources/lemclienthelper.mixins.json index efd2b7a..0f109f1 100644 --- a/src/main/resources/lemclienthelper.mixins.json +++ b/src/main/resources/lemclienthelper.mixins.json @@ -5,11 +5,13 @@ "client": [ "bookGui.BookScreenMixin", "customWorldBorder.WorldBorderMixin", + "hud.genericHud.PlayerBarMixin", "ResourcePreloader.ClientBuiltInResourcePackProviderMixin", "SmallInv.HandledScreenMixin", "SmallInv.MidnightControlsMixin", "SmallInv.MinecraftClientMixin", "SmallInv.ScreenHandlerMixin", + "SmallInv.invs.AbstractRecipeBookScreenMixin", "SmallInv.invs.GenericContainerScreenMixin", "SmallInv.invs.InventoryScreenMixin", "SmallInv.invs.MultipleScreenMixin",