From d11403edc7f91bd1e5b92a094ac9f0294838011a Mon Sep 17 00:00:00 2001 From: senseiwells Date: Fri, 21 Jun 2024 11:55:03 +0100 Subject: [PATCH] Update to 1.21 --- build.gradle | 2 +- gradle.properties | 14 +- .../clientscript/core/MinecraftAPI.java | 2 +- .../clientscript/definitions/PlayerDef.java | 3 +- .../essentialclient/feature/AFKRules.java | 3 +- .../feature/CustomClientCape.java | 2 +- .../feature/GameRuleNetworkHandler.java | 9 +- .../feature/HighlightLiquids.java | 10 +- .../chunkdebug/ChunkClientNetworkHandler.java | 11 +- .../feature/chunkdebug/ChunkDebugScreen.java | 49 ++-- .../feature/chunkdebug/ChunkGrid.java | 66 +++-- .../mixins/chunkDebug/InGameHudMixin.java | 5 +- .../ConfirmScreenMixin.java | 12 +- .../clientScript/ClientPlayerEntityMixin.java | 5 +- .../clientScript/WorldRendererMixin.java | 16 +- .../AbstractClientPlayerEntityMixin.java | 26 +- .../mixins/toggleTab/InGameHudMixin.java | 5 +- .../ClientPlayNetworkHandlerMixin.java | 4 +- .../essentialclient/utils/EssentialUtils.java | 34 ++- .../utils/clientscript/ClientScriptUtils.java | 2 +- .../utils/clientscript/ScreenRemapper.java | 1 - .../utils/inventory/InventoryUtils.java | 2 +- .../utils/render/RenderHelper.java | 227 +++++++----------- .../essentialclient/utils/render/Texts.java | 4 +- 24 files changed, 219 insertions(+), 295 deletions(-) diff --git a/build.gradle b/build.gradle index f2ebb5f1..091769b6 100644 --- a/build.gradle +++ b/build.gradle @@ -87,7 +87,7 @@ jar { publishMods { file = remapJar.archiveFile changelog = """ - - Updated to 1.20.6 + - Updated to 1.21 """ type = STABLE modLoaders.add("fabric") diff --git a/gradle.properties b/gradle.properties index 444a7d4c..361a6bc1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,16 +4,16 @@ systemProp.org.gradle.internal.http.socketTimeout=180000 # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx4G # Fabric Properties -minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.2 +minecraft_version=1.21 +yarn_mappings=1.21+build.2 loader_version=0.15.11 # Mod Properties -mod_version=1.5.1 +mod_version=1.5.2 maven_group=essential-client # Dependencies -carpet_version=1.4.141 -fabric_version=0.99.0+1.20.6 -modmenu_version=10.0.0-beta.1 +carpet_version=1.4.147 +fabric_version=0.100.3+1.21 +modmenu_version=11.0.0 arucas_version=d4a71bde0640e678a75795a156d9d38aad4c6f30 bytebuddy_version=1.14.11 -minecraft_dependency=1.20.x \ No newline at end of file +minecraft_dependency=1.21.x \ No newline at end of file diff --git a/src/main/java/me/senseiwells/essentialclient/clientscript/core/MinecraftAPI.java b/src/main/java/me/senseiwells/essentialclient/clientscript/core/MinecraftAPI.java index f47ffbbe..3b5fb03d 100644 --- a/src/main/java/me/senseiwells/essentialclient/clientscript/core/MinecraftAPI.java +++ b/src/main/java/me/senseiwells/essentialclient/clientscript/core/MinecraftAPI.java @@ -30,6 +30,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeEntry; import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKeys; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -152,6 +153,5 @@ public static void addMinecraftAPI(ArucasAPI.Builder builder) { builder.addConversion(ItemStackArgument.class, (s, i) -> EssentialUtils.throwAsUnchecked(() -> i.create(ItemStackDef.class, new ScriptItemStack(s.createStack(1, false))))); builder.addConversion(BlockStateArgument.class, (b, i) -> i.create(BlockDef.class, new ScriptBlockState(b.getBlockState(), null))); builder.addConversion(Identifier.class, (id, i) -> i.create(StringDef.class, id.toString())); - builder.addConversion(Enchantment.class, (e, i) -> i.convertValue(Registries.ENCHANTMENT.getId(e))); } } diff --git a/src/main/java/me/senseiwells/essentialclient/clientscript/definitions/PlayerDef.java b/src/main/java/me/senseiwells/essentialclient/clientscript/definitions/PlayerDef.java index 1570df14..081895d1 100644 --- a/src/main/java/me/senseiwells/essentialclient/clientscript/definitions/PlayerDef.java +++ b/src/main/java/me/senseiwells/essentialclient/clientscript/definitions/PlayerDef.java @@ -41,6 +41,7 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.network.DisconnectionInfo; import net.minecraft.network.packet.c2s.play.PickFromInventoryC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.network.packet.c2s.play.SpectatorTeleportC2SPacket; @@ -938,7 +939,7 @@ private Void clickRecipe2(Arguments arguments) { private Void logout(Arguments arguments) { String reason = arguments.skip().nextPrimitive(StringDef.class); ClientScriptUtils.ensureMainThread("logout", arguments.getInterpreter(), () -> { - EssentialUtils.getNetworkHandler().onDisconnected(Text.literal(reason)); + EssentialUtils.getNetworkHandler().onDisconnected(new DisconnectionInfo(Text.literal(reason))); }); return null; } diff --git a/src/main/java/me/senseiwells/essentialclient/feature/AFKRules.java b/src/main/java/me/senseiwells/essentialclient/feature/AFKRules.java index ebc0790d..1d67e0b7 100644 --- a/src/main/java/me/senseiwells/essentialclient/feature/AFKRules.java +++ b/src/main/java/me/senseiwells/essentialclient/feature/AFKRules.java @@ -6,6 +6,7 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.network.DisconnectionInfo; import net.minecraft.util.math.Vec3d; public class AFKRules { @@ -37,7 +38,7 @@ public class AFKRules { wasAfk = true; } if (logout >= 200 && ticks == logout) { - playerEntity.networkHandler.onDisconnected(Texts.AFK); + playerEntity.networkHandler.onDisconnected(new DisconnectionInfo(Texts.AFK)); } return; } diff --git a/src/main/java/me/senseiwells/essentialclient/feature/CustomClientCape.java b/src/main/java/me/senseiwells/essentialclient/feature/CustomClientCape.java index f2a24268..7c01bcb3 100644 --- a/src/main/java/me/senseiwells/essentialclient/feature/CustomClientCape.java +++ b/src/main/java/me/senseiwells/essentialclient/feature/CustomClientCape.java @@ -53,6 +53,6 @@ public static Identifier getCurrentCape() { } private static Identifier id(String name) { - return new Identifier("essentialclient", "textures/capes/" + name + ".png"); + return Identifier.of("essentialclient", "textures/capes/" + name + ".png"); } } diff --git a/src/main/java/me/senseiwells/essentialclient/feature/GameRuleNetworkHandler.java b/src/main/java/me/senseiwells/essentialclient/feature/GameRuleNetworkHandler.java index f7b0fced..19bfddad 100644 --- a/src/main/java/me/senseiwells/essentialclient/feature/GameRuleNetworkHandler.java +++ b/src/main/java/me/senseiwells/essentialclient/feature/GameRuleNetworkHandler.java @@ -17,6 +17,7 @@ import net.minecraft.network.PacketByteBuf; import net.minecraft.network.codec.PacketCodec; import net.minecraft.network.packet.CustomPayload; +import net.minecraft.util.Identifier; import net.minecraft.world.GameRules; import java.util.function.BiFunction; @@ -146,7 +147,7 @@ private void refreshScreen() { } private static class GameRuleHelloPayload extends HelloPayload { - public static final Id ID = CustomPayload.id("essential:game_rule_hello"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("essential:game_rule_hello")); public static final PacketCodec CODEC = PacketCodec.of( HelloPayload::write, GameRuleHelloPayload::new @@ -167,7 +168,7 @@ public Id getId() { } private record SetGameRulePayload(String name, String value) implements CustomPayload { - public static final Id ID = CustomPayload.id("essential:set_game_rule"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("essential:set_game_rule")); public static final PacketCodec CODEC = PacketCodec.of( (payload, buf) -> buf.writeString(payload.name).writeString(payload.value), (buf) -> new SetGameRulePayload(buf.readString(), buf.readString()) @@ -180,7 +181,7 @@ public Id getId() { } private record GameRulesChangedPayload(NbtCompound compound) implements CustomPayload { - public static final Id ID = CustomPayload.id("essential:game_rules_changed"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("essential:game_rules_changed")); public static final PacketCodec CODEC = PacketCodec.of( (payload, buf) -> buf.writeNbt(payload.compound), (buf) -> new GameRulesChangedPayload(buf.readNbt()) @@ -193,7 +194,7 @@ public Id getId() { } private record GameRulePermissionsPayload(boolean canUpdateGamerules) implements CustomPayload { - public static final Id ID = CustomPayload.id("essential:game_rule_permissions"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("essential:game_rule_permissions")); public static final PacketCodec CODEC = PacketCodec.of( (payload, buf) -> buf.writeBoolean(payload.canUpdateGamerules), (buf) -> new GameRulePermissionsPayload(buf.readBoolean()) diff --git a/src/main/java/me/senseiwells/essentialclient/feature/HighlightLiquids.java b/src/main/java/me/senseiwells/essentialclient/feature/HighlightLiquids.java index 1898ef61..4ee1fc39 100644 --- a/src/main/java/me/senseiwells/essentialclient/feature/HighlightLiquids.java +++ b/src/main/java/me/senseiwells/essentialclient/feature/HighlightLiquids.java @@ -47,10 +47,10 @@ public class HighlightLiquids implements SimpleSynchronousResourceReloadListener private static final int DEFAULT_WATER_COLOUR; static { - LAVA_FLOWING_SPRITE_ID = new Identifier("essentialclient", "block/lava_flow"); - LAVA_STILL_SPRITE_ID = new Identifier("essentialclient", "block/lava_still"); - WATER_FLOWING_SPRITE_ID = new Identifier("essentialclient", "block/water_flow"); - WATER_STILL_SPRITE_ID = new Identifier("essentialclient", "block/water_still"); + LAVA_FLOWING_SPRITE_ID = Identifier.of("essentialclient", "block/lava_flow"); + LAVA_STILL_SPRITE_ID = Identifier.of("essentialclient", "block/lava_still"); + WATER_FLOWING_SPRITE_ID = Identifier.of("essentialclient", "block/water_flow"); + WATER_STILL_SPRITE_ID = Identifier.of("essentialclient", "block/water_still"); DEFAULT_WATER_COLOUR = 0x3F76E4; } @@ -115,6 +115,6 @@ public int getFluidColor(@Nullable BlockRenderView view, @Nullable BlockPos pos, @Override public Identifier getFabricId() { - return new Identifier("lava_reload_listener"); + return Identifier.of("lava_reload_listener"); } } diff --git a/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkClientNetworkHandler.java b/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkClientNetworkHandler.java index 3175222d..512e844b 100644 --- a/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkClientNetworkHandler.java +++ b/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkClientNetworkHandler.java @@ -10,6 +10,7 @@ import net.minecraft.network.packet.CustomPayload; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; +import net.minecraft.util.Identifier; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; @@ -128,7 +129,7 @@ protected HelloPayload createHelloPayload(String brand, int version) { } private static class ChunkDebugHelloPayload extends HelloPayload { - public static final Id ID = CustomPayload.id("chunk_debug:hello"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:hello")); public static final PacketCodec CODEC = PacketCodec.of( ChunkDebugHelloPayload::write, ChunkDebugHelloPayload::new @@ -152,7 +153,7 @@ private record BatchedChunkInfoPayload( RegistryKey world, List infos ) implements CustomPayload { - public static final Id ID = CustomPayload.id("chunk_debug:batched_chunk_info"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:batched_chunk_info")); public static final PacketCodec CODEC = PacketCodec.of( BatchedChunkInfoPayload::write, BatchedChunkInfoPayload::read @@ -207,7 +208,7 @@ public static BatchedChunkInfoPayload read(PacketByteBuf buf) { } private record StopChunkInfoPayload() implements CustomPayload { - public static final Id ID = CustomPayload.id("chunk_debug:stop"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:stop")); public static final PacketCodec CODEC = PacketCodec.unit(new StopChunkInfoPayload()); @Override @@ -217,7 +218,7 @@ public Id getId() { } private record SetChunkDimensionPayload(RegistryKey dimension) implements CustomPayload { - public static final Id ID = CustomPayload.id("chunk_debug:set_dimension"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:set_dimension")); public static final PacketCodec CODEC = PacketCodec.of( SetChunkDimensionPayload::write, SetChunkDimensionPayload::new @@ -238,7 +239,7 @@ public Id getId() { } private record ReloadChunkDebugPayload() implements CustomPayload { - public static final Id ID = CustomPayload.id("chunk_debug:reload"); + public static final Id ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:reload")); public static final PacketCodec CODEC = PacketCodec.unit(new ReloadChunkDebugPayload()); @Override diff --git a/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkDebugScreen.java b/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkDebugScreen.java index 60e8b50b..51d1b5a1 100644 --- a/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkDebugScreen.java +++ b/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkDebugScreen.java @@ -117,9 +117,8 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { ChunkGrid.instance.render(0, HEADER_HEIGHT, this.width, this.height - HEADER_HEIGHT - FOOTER_HEIGHT, false); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); - this.drawHeaderAndFooterGradient(tessellator, bufferBuilder); - this.drawHeaderAndFooterTexture(tessellator, bufferBuilder); + this.drawHeaderAndFooterGradient(tessellator); + this.drawHeaderAndFooterTexture(tessellator); super.render(context, mouseX, mouseY, delta); if (ChunkGrid.instance.isPanning()) { @@ -148,49 +147,45 @@ public void renderBackground(DrawContext context, int mouseX, int mouseY, float } - private void drawHeaderAndFooterGradient(Tessellator tessellator, BufferBuilder bufferBuilder) { + private void drawHeaderAndFooterGradient(Tessellator tessellator) { RenderSystem.enableBlend(); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderHelper.startQuads(bufferBuilder, VertexFormats.POSITION_COLOR); + BufferBuilder bufferBuilder = RenderHelper.startQuads(tessellator, VertexFormats.POSITION_COLOR); // Header gradient - bufferBuilder.vertex(0, HEADER_HEIGHT, 0).color(0, 0, 0, 255).next(); - bufferBuilder.vertex(0, HEADER_HEIGHT + 4, 0).color(0, 0, 0, 0).next(); - bufferBuilder.vertex(this.width, HEADER_HEIGHT + 4, 0).color(0, 0, 0, 0).next(); - bufferBuilder.vertex(this.width, HEADER_HEIGHT, 0).color(0, 0, 0, 255).next(); + bufferBuilder.vertex(0, HEADER_HEIGHT, 0).color(0, 0, 0, 255); + bufferBuilder.vertex(0, HEADER_HEIGHT + 4, 0).color(0, 0, 0, 0); + bufferBuilder.vertex(this.width, HEADER_HEIGHT + 4, 0).color(0, 0, 0, 0); + bufferBuilder.vertex(this.width, HEADER_HEIGHT, 0).color(0, 0, 0, 255); // Footer gradient - bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT - 4, 0).color(0, 0, 0, 0).next(); - bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT, 0).color(0, 0, 0, 255).next(); - bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT, 0).color(0, 0, 0, 255).next(); - bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT - 4, 0).color(0, 0, 0, 0).next(); - - tessellator.draw(); + bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT - 4, 0).color(0, 0, 0, 0); + bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT, 0).color(0, 0, 0, 255); + bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT, 0).color(0, 0, 0, 255); + bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT - 4, 0).color(0, 0, 0, 0); } - private void drawHeaderAndFooterTexture(Tessellator tessellator, BufferBuilder bufferBuilder) { + private void drawHeaderAndFooterTexture(Tessellator tessellator) { RenderHelper.setPositionTextureColourShader(); // RenderHelper.bindTexture(OPTIONS_BACKGROUND_TEXTURE); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); - RenderHelper.startQuads(bufferBuilder, VertexFormats.POSITION_TEXTURE_COLOR); + BufferBuilder bufferBuilder = RenderHelper.startQuads(tessellator, VertexFormats.POSITION_TEXTURE_COLOR); // Header - bufferBuilder.vertex(0, 0, 0).texture(0, 0).color(64, 64, 64, 255).next(); - bufferBuilder.vertex(0, HEADER_HEIGHT, 0).texture(0, HEADER_HEIGHT / 32f).color(64, 64, 64, 255).next(); - bufferBuilder.vertex(this.width, HEADER_HEIGHT, 0).texture(this.width / 32f, HEADER_HEIGHT / 32f).color(64, 64, 64, 255).next(); - bufferBuilder.vertex(this.width, 0, 0).texture(this.width / 32f, 0).color(64, 64, 64, 255).next(); + bufferBuilder.vertex(0, 0, 0).texture(0, 0).color(64, 64, 64, 255); + bufferBuilder.vertex(0, HEADER_HEIGHT, 0).texture(0, HEADER_HEIGHT / 32f).color(64, 64, 64, 255); + bufferBuilder.vertex(this.width, HEADER_HEIGHT, 0).texture(this.width / 32f, HEADER_HEIGHT / 32f).color(64, 64, 64, 255); + bufferBuilder.vertex(this.width, 0, 0).texture(this.width / 32f, 0).color(64, 64, 64, 255); // Footer - bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT, 0).texture(0, (this.height - FOOTER_HEIGHT) / 32f).color(64, 64, 64, 255).next(); - bufferBuilder.vertex(0, this.height, 0).texture(0, this.height / 32f).color(64, 64, 64, 255).next(); - bufferBuilder.vertex(this.width, this.height, 0).texture(this.width / 32f, this.height / 32f).color(64, 64, 64, 255).next(); - bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT, 0).texture(this.width / 32f, (this.height - FOOTER_HEIGHT) / 32f).color(64, 64, 64, 255).next(); - - tessellator.draw(); + bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT, 0).texture(0, (this.height - FOOTER_HEIGHT) / 32f).color(64, 64, 64, 255); + bufferBuilder.vertex(0, this.height, 0).texture(0, this.height / 32f).color(64, 64, 64, 255); + bufferBuilder.vertex(this.width, this.height, 0).texture(this.width / 32f, this.height / 32f).color(64, 64, 64, 255); + bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT, 0).texture(this.width / 32f, (this.height - FOOTER_HEIGHT) / 32f).color(64, 64, 64, 255); } @Override diff --git a/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkGrid.java b/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkGrid.java index be84a120..74c81d08 100644 --- a/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkGrid.java +++ b/src/main/java/me/senseiwells/essentialclient/feature/chunkdebug/ChunkGrid.java @@ -83,7 +83,6 @@ public void render(int thisX, int thisY, int width, int height, boolean isMinima this.updateRowsAndColumns(); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); RenderSystem.enableDepthTest(); RenderSystem.enableBlend(); @@ -91,21 +90,21 @@ public void render(int thisX, int thisY, int width, int height, boolean isMinima RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderHelper.setPositionColourShader(); - RenderHelper.startQuads(bufferBuilder, VertexFormats.POSITION_COLOR); + BufferBuilder bufferBuilder = RenderHelper.startQuads(tessellator, VertexFormats.POSITION_COLOR); if (isMinimap && ClientRules.CHUNK_DEBUG_MINIMAP_BACKGROUND.getValue()) { int thatX = thisX + this.scale * (this.columns + 1); int thatY = thisY + this.scale * (this.rows + 1); - bufferBuilder.vertex(thisX - 5, thisY - 5, 0).color(53, 59, 72, 200).next(); - bufferBuilder.vertex(thisX - 5, thatY + 5, 0).color(53, 59, 72, 200).next(); - bufferBuilder.vertex(thatX + 5, thatY + 5, 0).color(53, 59, 72, 200).next(); - bufferBuilder.vertex(thatX + 5, thisY - 5, 0).color(53, 59, 72, 200).next(); + bufferBuilder.vertex(thisX - 5, thisY - 5, 0).color(53, 59, 72, 200); + bufferBuilder.vertex(thisX - 5, thatY + 5, 0).color(53, 59, 72, 200); + bufferBuilder.vertex(thatX + 5, thatY + 5, 0).color(53, 59, 72, 200); + bufferBuilder.vertex(thatX + 5, thisY - 5, 0).color(53, 59, 72, 200); - bufferBuilder.vertex(thisX, thisY, 0).color(45, 52, 54, 200).next(); - bufferBuilder.vertex(thisX, thatY, 0).color(45, 52, 54, 200).next(); - bufferBuilder.vertex(thatX, thatY, 0).color(45, 52, 54, 200).next(); - bufferBuilder.vertex(thatX, thisY, 0).color(45, 52, 54, 200).next(); + bufferBuilder.vertex(thisX, thisY, 0).color(45, 52, 54, 200); + bufferBuilder.vertex(thisX, thatY, 0).color(45, 52, 54, 200); + bufferBuilder.vertex(thatX, thatY, 0).color(45, 52, 54, 200); + bufferBuilder.vertex(thatX, thisY, 0).color(45, 52, 54, 200); } for (ChunkInfo info : EssentialClient.CHUNK_NET_HANDLER.getChunks(this.getDimension())) { @@ -121,7 +120,6 @@ public void render(int thisX, int thisY, int width, int height, boolean isMinima int cellY = thisY + z * this.scale; this.drawBox(bufferBuilder, cellX, cellY, x, z, info.getColour()); } - tessellator.draw(); ClientPlayerEntity player = this.client.player; if (player != null && this.isPlayerInDimension(player)) { @@ -132,7 +130,7 @@ public void render(int thisX, int thisY, int width, int height, boolean isMinima int cellX = thisX + x * this.scale; int cellY = thisY + z * this.scale; - this.drawCross(tessellator, bufferBuilder, cellX, cellY, thisX, thisY); + this.drawCross(tessellator, cellX, cellY, thisX, thisY); } } @@ -144,7 +142,7 @@ public void render(int thisX, int thisY, int width, int height, boolean isMinima int minimapSelectionZ = this.cornerPoint.getY() + selectionPoint.getY() - this.minimapCornerPoint.y; drawingPoint = new Point(minimapSelectionX, minimapSelectionZ); } - this.drawSelectionBox(tessellator, bufferBuilder, drawingPoint, thisX, thisY); + this.drawSelectionBox(tessellator, drawingPoint, thisX, thisY); this.updateSelectionInfo(); } else { this.selectionText = null; @@ -196,13 +194,13 @@ private void drawBox(BufferBuilder bufferBuilder, int cellX, int cellY, int x, i int green = (colour & 0xff00) >> 8; int blue = (colour & 0xff); - bufferBuilder.vertex(cellX, cellY, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX, cellY + this.scale, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX + this.scale, cellY + this.scale, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX + this.scale, cellY, 0).color(red, green, blue, 255).next(); + bufferBuilder.vertex(cellX, cellY, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX, cellY + this.scale, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX + this.scale, cellY + this.scale, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX + this.scale, cellY, 0).color(red, green, blue, 255); } - private void drawSelectionBox(Tessellator tessellator, BufferBuilder bufferBuilder, Point selectionPoint, int thisX, int thisY) { + private void drawSelectionBox(Tessellator tessellator, Point selectionPoint, int thisX, int thisY) { int red = 0xF7; int green = 0xF0; int blue = 0x06; @@ -218,19 +216,18 @@ private void drawSelectionBox(Tessellator tessellator, BufferBuilder bufferBuild return; } - RenderHelper.startDebugLines(bufferBuilder, VertexFormats.POSITION_COLOR); - bufferBuilder.vertex(cellX, cellY, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX, cellY + this.scale, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX, cellY + this.scale, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX + this.scale, cellY + this.scale, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX + this.scale, cellY + this.scale, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX + this.scale, cellY, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX + this.scale, cellY, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX, cellY, 0).color(red, green, blue, 255).next(); - tessellator.draw(); + BufferBuilder bufferBuilder = RenderHelper.startDebugLines(tessellator, VertexFormats.POSITION_COLOR); + bufferBuilder.vertex(cellX, cellY, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX, cellY + this.scale, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX, cellY + this.scale, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX + this.scale, cellY + this.scale, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX + this.scale, cellY + this.scale, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX + this.scale, cellY, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX + this.scale, cellY, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX, cellY, 0).color(red, green, blue, 255); } - private void drawCross(Tessellator tessellator, BufferBuilder bufferBuilder, int cellX, int cellY, int x, int y) { + private void drawCross(Tessellator tessellator, int cellX, int cellY, int x, int y) { int red = 0xF7; int green = 0xF0; int blue = 0x06; @@ -239,12 +236,11 @@ private void drawCross(Tessellator tessellator, BufferBuilder bufferBuilder, int return; } - RenderHelper.startDebugLines(bufferBuilder, VertexFormats.POSITION_COLOR); - bufferBuilder.vertex(cellX, cellY, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX + this.scale, cellY + this.scale, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX + this.scale, cellY, 0).color(red, green, blue, 255).next(); - bufferBuilder.vertex(cellX, cellY + this.scale, 0).color(red, green, blue, 255).next(); - tessellator.draw(); + BufferBuilder bufferBuilder = RenderHelper.startDebugLines(tessellator, VertexFormats.POSITION_COLOR); + bufferBuilder.vertex(cellX, cellY, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX + this.scale, cellY + this.scale, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX + this.scale, cellY, 0).color(red, green, blue, 255); + bufferBuilder.vertex(cellX, cellY + this.scale, 0).color(red, green, blue, 255); } public boolean onScroll(double mouseX, double mouseY, double amount) { diff --git a/src/main/java/me/senseiwells/essentialclient/mixins/chunkDebug/InGameHudMixin.java b/src/main/java/me/senseiwells/essentialclient/mixins/chunkDebug/InGameHudMixin.java index 6a286be6..6227667e 100644 --- a/src/main/java/me/senseiwells/essentialclient/mixins/chunkDebug/InGameHudMixin.java +++ b/src/main/java/me/senseiwells/essentialclient/mixins/chunkDebug/InGameHudMixin.java @@ -3,6 +3,7 @@ import me.senseiwells.essentialclient.feature.chunkdebug.ChunkGrid; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -16,9 +17,7 @@ public class InGameHudMixin { at = @At(value = "TAIL") ) private void afterCrossHairRender( - DrawContext context, - float tickDelta, - CallbackInfo ci + DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci ) { if (ChunkGrid.instance != null) { ChunkGrid.instance.renderMinimap(context.getScaledWindowWidth(), context.getScaledWindowWidth()); diff --git a/src/main/java/me/senseiwells/essentialclient/mixins/cleanConfirmScreen/ConfirmScreenMixin.java b/src/main/java/me/senseiwells/essentialclient/mixins/cleanConfirmScreen/ConfirmScreenMixin.java index d9c69e1b..09ef3e0a 100644 --- a/src/main/java/me/senseiwells/essentialclient/mixins/cleanConfirmScreen/ConfirmScreenMixin.java +++ b/src/main/java/me/senseiwells/essentialclient/mixins/cleanConfirmScreen/ConfirmScreenMixin.java @@ -11,12 +11,18 @@ @Mixin(ConfirmScreen.class) public class ConfirmScreenMixin { - @Redirect(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/MultilineText;create(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/StringVisitable;I)Lnet/minecraft/client/font/MultilineText;")) - private MultilineText onDisplayMessage(TextRenderer renderer, StringVisitable text, int width) { + @Redirect( + method = "init", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/MultilineText;create(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;I)Lnet/minecraft/client/font/MultilineText;" + ) + ) + private MultilineText onDisplayMessage(TextRenderer renderer, Text text, int maxWidth) { String message = text.getString(); if (message.length() > 120) { text = Text.literal(message.substring(0, 120) + "..."); } - return MultilineText.create(renderer, text, width); + return MultilineText.create(renderer, text, maxWidth); } } diff --git a/src/main/java/me/senseiwells/essentialclient/mixins/clientScript/ClientPlayerEntityMixin.java b/src/main/java/me/senseiwells/essentialclient/mixins/clientScript/ClientPlayerEntityMixin.java index 066d4c29..7b9e097d 100644 --- a/src/main/java/me/senseiwells/essentialclient/mixins/clientScript/ClientPlayerEntityMixin.java +++ b/src/main/java/me/senseiwells/essentialclient/mixins/clientScript/ClientPlayerEntityMixin.java @@ -4,6 +4,7 @@ import me.senseiwells.essentialclient.clientscript.events.MinecraftScriptEvents; import me.senseiwells.essentialclient.utils.EssentialUtils; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.component.type.FoodComponent; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -39,9 +40,9 @@ private void onCloseScreen(CallbackInfo ci) { } @Override - public ItemStack eatFood(World world, ItemStack stack) { + public ItemStack eatFood(World world, ItemStack stack, FoodComponent foodComponent) { MinecraftScriptEvents.ON_EAT.run(stack); - return super.eatFood(world, stack); + return super.eatFood(world, stack, foodComponent); } @Override diff --git a/src/main/java/me/senseiwells/essentialclient/mixins/clientScript/WorldRendererMixin.java b/src/main/java/me/senseiwells/essentialclient/mixins/clientScript/WorldRendererMixin.java index 5e985cf3..3913b7e0 100644 --- a/src/main/java/me/senseiwells/essentialclient/mixins/clientScript/WorldRendererMixin.java +++ b/src/main/java/me/senseiwells/essentialclient/mixins/clientScript/WorldRendererMixin.java @@ -2,10 +2,7 @@ import com.llamalad7.mixinextras.sugar.Local; import me.senseiwells.essentialclient.utils.render.RenderHelper; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.render.LightmapTextureManager; -import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; @@ -17,16 +14,7 @@ public class WorldRendererMixin { @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/BackgroundRenderer;clearFog()V", shift = At.Shift.BEFORE)) private void postRender( - float tickDelta, - long limitTime, - boolean renderBlockOutline, - Camera camera, - GameRenderer gameRenderer, - LightmapTextureManager lightmapTextureManager, - Matrix4f matrix4f, - Matrix4f matrix4f2, - CallbackInfo ci, - @Local MatrixStack matrices + RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci, @Local MatrixStack matrices ) { RenderHelper.renderAllShapes(matrices); // Rendering blocks needs to come after rendering diff --git a/src/main/java/me/senseiwells/essentialclient/mixins/soulBlocksEffectOnFov/AbstractClientPlayerEntityMixin.java b/src/main/java/me/senseiwells/essentialclient/mixins/soulBlocksEffectOnFov/AbstractClientPlayerEntityMixin.java index 725902fe..cf843d02 100644 --- a/src/main/java/me/senseiwells/essentialclient/mixins/soulBlocksEffectOnFov/AbstractClientPlayerEntityMixin.java +++ b/src/main/java/me/senseiwells/essentialclient/mixins/soulBlocksEffectOnFov/AbstractClientPlayerEntityMixin.java @@ -9,6 +9,8 @@ import net.minecraft.entity.attribute.EntityAttributeInstance; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.util.Identifier; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -21,7 +23,7 @@ @Mixin(AbstractClientPlayerEntity.class) public abstract class AbstractClientPlayerEntityMixin extends LivingEntity { @Unique - private final UUID SOUL_SPEED_BOOST_ID = UUID.fromString("87f46a96-686f-4796-b035-22e16ee9e038"); + private static final Identifier SOUL_SPEED_BOOST_ID = Identifier.ofVanilla("enchantment.soul_speed"); protected AbstractClientPlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); @@ -36,12 +38,13 @@ protected AbstractClientPlayerEntityMixin(EntityType ent ) public void injectedBefore(CallbackInfoReturnable cir) { EntityAttributeInstance genericSpeedAttribute = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED); - if (genericSpeedAttribute != null && genericSpeedAttribute.getModifier(this.SOUL_SPEED_BOOST_ID) != null) { - genericSpeedAttribute.removeModifier(this.SOUL_SPEED_BOOST_ID); + if (genericSpeedAttribute != null && genericSpeedAttribute.getModifier(SOUL_SPEED_BOOST_ID) != null) { + var enchants = this.getRegistryManager().getWrapperOrThrow(RegistryKeys.ENCHANTMENT); + var soulSpeed = enchants.getOrThrow(Enchantments.SOUL_SPEED); + genericSpeedAttribute.removeModifier(SOUL_SPEED_BOOST_ID); genericSpeedAttribute.addTemporaryModifier(new EntityAttributeModifier( - this.SOUL_SPEED_BOOST_ID, - "Soul speed boost", - 0.01 * ClientRules.SOUL_SPEED_FOV_MULTIPLIER.getValue() * (0.03F * (1.0F + EnchantmentHelper.getEquipmentLevel(Enchantments.SOUL_SPEED, this) * 0.35F)), + SOUL_SPEED_BOOST_ID, + 0.01 * ClientRules.SOUL_SPEED_FOV_MULTIPLIER.getValue() * (0.03F * (1.0F + EnchantmentHelper.getEquipmentLevel(soulSpeed, this) * 0.35F)), EntityAttributeModifier.Operation.ADD_VALUE )); } @@ -57,12 +60,13 @@ public void injectedBefore(CallbackInfoReturnable cir) { ) private void injectedAfter(CallbackInfoReturnable cir) { EntityAttributeInstance genericSpeedAttribute = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED); - if (genericSpeedAttribute != null && genericSpeedAttribute.getModifier(this.SOUL_SPEED_BOOST_ID) != null) { - genericSpeedAttribute.removeModifier(this.SOUL_SPEED_BOOST_ID); + if (genericSpeedAttribute != null && genericSpeedAttribute.getModifier(SOUL_SPEED_BOOST_ID) != null) { + var enchants = this.getRegistryManager().getWrapperOrThrow(RegistryKeys.ENCHANTMENT); + var soulSpeed = enchants.getOrThrow(Enchantments.SOUL_SPEED); + genericSpeedAttribute.removeModifier(SOUL_SPEED_BOOST_ID); genericSpeedAttribute.addTemporaryModifier(new EntityAttributeModifier( - this.SOUL_SPEED_BOOST_ID, - "Soul speed boost", - (0.03F * (1.0F + (float) EnchantmentHelper.getEquipmentLevel(Enchantments.SOUL_SPEED, this) * 0.35F)), + SOUL_SPEED_BOOST_ID, + (0.03F * (1.0F + (float) EnchantmentHelper.getEquipmentLevel(soulSpeed, this) * 0.35F)), EntityAttributeModifier.Operation.ADD_VALUE )); } diff --git a/src/main/java/me/senseiwells/essentialclient/mixins/toggleTab/InGameHudMixin.java b/src/main/java/me/senseiwells/essentialclient/mixins/toggleTab/InGameHudMixin.java index c3dac2e1..cb01615e 100644 --- a/src/main/java/me/senseiwells/essentialclient/mixins/toggleTab/InGameHudMixin.java +++ b/src/main/java/me/senseiwells/essentialclient/mixins/toggleTab/InGameHudMixin.java @@ -8,6 +8,7 @@ import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.ScoreboardDisplaySlot; import net.minecraft.scoreboard.ScoreboardObjective; @@ -62,9 +63,7 @@ private boolean shouldSetVisible(PlayerListHud instance, boolean shouldBeVisible ) ) private void onRenderTab( - DrawContext context, - float tickDelta, - CallbackInfo ci + DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci ) { if (this.client.world == null || this.client.player == null) { return; diff --git a/src/main/java/me/senseiwells/essentialclient/mixins/unlockAllRecipes/ClientPlayNetworkHandlerMixin.java b/src/main/java/me/senseiwells/essentialclient/mixins/unlockAllRecipes/ClientPlayNetworkHandlerMixin.java index e81d640e..dfdd5bf5 100644 --- a/src/main/java/me/senseiwells/essentialclient/mixins/unlockAllRecipes/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/me/senseiwells/essentialclient/mixins/unlockAllRecipes/ClientPlayNetworkHandlerMixin.java @@ -8,8 +8,8 @@ import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.recipebook.ClientRecipeBook; import net.minecraft.network.ClientConnection; +import net.minecraft.network.packet.s2c.play.ChangeUnlockedRecipesS2CPacket; import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket; -import net.minecraft.network.packet.s2c.play.UnlockRecipesS2CPacket; import net.minecraft.recipe.RecipeManager; import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Final; @@ -41,7 +41,7 @@ private void onSyncRecipes(SynchronizeRecipesS2CPacket packet, CallbackInfo ci) } @Inject(method = "onUnlockRecipes", at = @At("HEAD")) - private void onUnlock(UnlockRecipesS2CPacket packet, CallbackInfo ci) { + private void onUnlock(ChangeUnlockedRecipesS2CPacket packet, CallbackInfo ci) { switch (packet.getAction()) { case ADD, INIT -> { for (Identifier identifier : packet.getRecipeIdsToChange()) { diff --git a/src/main/java/me/senseiwells/essentialclient/utils/EssentialUtils.java b/src/main/java/me/senseiwells/essentialclient/utils/EssentialUtils.java index 720820f1..27017ac7 100644 --- a/src/main/java/me/senseiwells/essentialclient/utils/EssentialUtils.java +++ b/src/main/java/me/senseiwells/essentialclient/utils/EssentialUtils.java @@ -19,12 +19,7 @@ import net.minecraft.client.network.ClientPlayerInteractionManager; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.world.ClientWorld; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnLocation; -import net.minecraft.entity.SpawnRestriction; +import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectUtil; import net.minecraft.entity.effect.StatusEffects; @@ -40,11 +35,10 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.SpawnHelper; -import net.minecraft.world.WorldView; import java.io.IOException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Optional; @@ -56,8 +50,8 @@ public class EssentialUtils { private static final ModContainer ESSENTIAL_CONTAINER; private static final boolean DEV; - public static final URL WIKI_URL; - public static final URL SCRIPT_WIKI_URL; + public static final URI WIKI_URL; + public static final URI SCRIPT_WIKI_URL; static { ESSENTIAL_CLIENT_PATH = FabricLoader.getInstance().getConfigDir().resolve("EssentialClient"); @@ -70,10 +64,10 @@ public class EssentialUtils { ESSENTIAL_CONTAINER = optional.get(); try { - WIKI_URL = new URL("https://github.com/senseiwells/EssentialClient/wiki"); - SCRIPT_WIKI_URL = new URL("https://github.com/senseiwells/EssentialClient/wiki/ClientScript"); + WIKI_URL = new URI("https://github.com/senseiwells/EssentialClient/wiki"); + SCRIPT_WIKI_URL = new URI("https://github.com/senseiwells/EssentialClient/wiki/ClientScript"); Files.createDirectories(ESSENTIAL_CLIENT_PATH); - } catch (IOException e) { + } catch (IOException | URISyntaxException e) { throw new RuntimeException(e); } } @@ -223,10 +217,7 @@ public static void mineBlock(BlockPos pos, Supplier condition, Completa public static float getBlockBreakingSpeed(ItemStack itemStack, BlockState blockState, PlayerEntity player) { float multiplier = itemStack.getMiningSpeedMultiplier(blockState); if (multiplier > 1.0F) { - int efficiencyLevel = EnchantmentHelper.getLevel(Enchantments.EFFICIENCY, itemStack); - if (efficiencyLevel > 0) { - multiplier += efficiencyLevel * efficiencyLevel + 1.0F; - } + multiplier += (float) player.getAttributeValue(EntityAttributes.PLAYER_MINING_EFFICIENCY); } if (StatusEffectUtil.hasHaste(player)) { @@ -241,8 +232,11 @@ public static float getBlockBreakingSpeed(ItemStack itemStack, BlockState blockS default -> 8.1e-4F; }; } - if (player.isSubmergedIn(FluidTags.WATER) && !EnchantmentHelper.hasAquaAffinity(player)) { - multiplier /= 5.0F; + if (player.isSubmergedIn(FluidTags.WATER)) { + var attribute = player.getAttributeInstance(EntityAttributes.PLAYER_SUBMERGED_MINING_SPEED); + if (attribute != null) { + multiplier *= (float) attribute.getValue(); + } } if (!player.isOnGround()) { multiplier /= 5.0F; diff --git a/src/main/java/me/senseiwells/essentialclient/utils/clientscript/ClientScriptUtils.java b/src/main/java/me/senseiwells/essentialclient/utils/clientscript/ClientScriptUtils.java index 4bc34670..ab9301d0 100644 --- a/src/main/java/me/senseiwells/essentialclient/utils/clientscript/ClientScriptUtils.java +++ b/src/main/java/me/senseiwells/essentialclient/utils/clientscript/ClientScriptUtils.java @@ -221,7 +221,7 @@ public static HoverEvent stringToHoverEvent(String string, ClassInstance object) public static Identifier stringToIdentifier(String string) { try { - return new Identifier(string); + return Identifier.of(string); } catch (InvalidIdentifierException e) { throw new RuntimeError("Invalid id '%s'".formatted(string), e); } diff --git a/src/main/java/me/senseiwells/essentialclient/utils/clientscript/ScreenRemapper.java b/src/main/java/me/senseiwells/essentialclient/utils/clientscript/ScreenRemapper.java index d149dda6..6c0836eb 100644 --- a/src/main/java/me/senseiwells/essentialclient/utils/clientscript/ScreenRemapper.java +++ b/src/main/java/me/senseiwells/essentialclient/utils/clientscript/ScreenRemapper.java @@ -60,7 +60,6 @@ public class ScreenRemapper { map.put(MerchantScreen.class, "Merchant"); map.put(MinecartCommandBlockScreen.class, "MinecrartCommandBlock"); map.put(MouseOptionsScreen.class, "MouseOptions"); - map.put(SimpleOptionsScreen.class, "SimpleOptions"); map.put(NoticeScreen.class, "Notice"); map.put(OpenToLanScreen.class, "OpenToLan"); map.put(OptionsScreen.class, "Options"); diff --git a/src/main/java/me/senseiwells/essentialclient/utils/inventory/InventoryUtils.java b/src/main/java/me/senseiwells/essentialclient/utils/inventory/InventoryUtils.java index c2466028..1b1a67e4 100644 --- a/src/main/java/me/senseiwells/essentialclient/utils/inventory/InventoryUtils.java +++ b/src/main/java/me/senseiwells/essentialclient/utils/inventory/InventoryUtils.java @@ -338,7 +338,7 @@ public static boolean isGridEmpty(ScreenHandler screenHandler, int gridLength) { } public static int getCraftingSlotLength(ScreenHandler handler) { - if (handler instanceof AbstractRecipeScreenHandler recipeScreen) { + if (handler instanceof AbstractRecipeScreenHandler recipeScreen) { return recipeScreen.getCraftingHeight() * recipeScreen.getCraftingWidth(); } return 0; diff --git a/src/main/java/me/senseiwells/essentialclient/utils/render/RenderHelper.java b/src/main/java/me/senseiwells/essentialclient/utils/render/RenderHelper.java index ae529607..79c8120f 100644 --- a/src/main/java/me/senseiwells/essentialclient/utils/render/RenderHelper.java +++ b/src/main/java/me/senseiwells/essentialclient/utils/render/RenderHelper.java @@ -17,14 +17,9 @@ import net.minecraft.util.math.*; import net.minecraft.util.math.random.Random; import net.minecraft.world.LightType; -import org.joml.Matrix3f; import org.joml.Matrix4f; import org.joml.Vector3f; -import org.joml.Vector4f; -import org.lwjgl.system.MemoryStack; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; import java.util.List; import java.util.function.Consumer; @@ -76,42 +71,39 @@ public static void resetArucasRendering() { private static void renderBoxes(MatrixStack matrices) { Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera(); Vec3d cameraPos = camera.getPos(); if (ScriptBox.hasRegular()) { - drawBoxOutlines(tessellator, bufferBuilder, matrices, cameraPos, ScriptBox::forEachRegular); - drawBoxes(tessellator, bufferBuilder, matrices, cameraPos, ScriptBox::forEachRegular); + drawBoxOutlines(tessellator, matrices, cameraPos, ScriptBox::forEachRegular); + drawBoxes(tessellator, matrices, cameraPos, ScriptBox::forEachRegular); } if (ScriptBox.hasIgnoreDepth()) { RenderSystem.disableDepthTest(); - drawBoxOutlines(tessellator, bufferBuilder, matrices, cameraPos, ScriptBox::forEachIgnoreDepth); - drawBoxes(tessellator, bufferBuilder, matrices, cameraPos, ScriptBox::forEachIgnoreDepth); + drawBoxOutlines(tessellator, matrices, cameraPos, ScriptBox::forEachIgnoreDepth); + drawBoxes(tessellator, matrices, cameraPos, ScriptBox::forEachIgnoreDepth); RenderSystem.enableDepthTest(); } } - private static void drawBoxOutlines(Tessellator tessellator, BufferBuilder bufferBuilder, MatrixStack matrices, Vec3d camera, Consumer> forEach) { + private static void drawBoxOutlines(Tessellator tessellator, MatrixStack matrices, Vec3d camera, Consumer> forEach) { setLineShader(); - startLines(bufferBuilder); + BufferBuilder bufferBuilder = startLines(tessellator); forEach.accept(box -> { if (box.getOutlineWidth() >= 1) { RenderSystem.lineWidth(box.getOutlineWidth()); addBoxToBuffer(bufferBuilder, matrices, camera, box, true); } }); - tessellator.draw(); } - private static void drawBoxes(Tessellator tessellator, BufferBuilder bufferBuilder, MatrixStack matrices, Vec3d cameraPos, Consumer> forEach) { + private static void drawBoxes(Tessellator tessellator, MatrixStack matrices, Vec3d cameraPos, Consumer> forEach) { setPositionColourShader(); - startQuads(bufferBuilder, VertexFormats.POSITION_COLOR); + BufferBuilder bufferBuilder = startQuads(tessellator, VertexFormats.POSITION_COLOR); forEach.accept(box -> { addBoxToBuffer(bufferBuilder, matrices, cameraPos, box, false); }); - tessellator.draw(); } private static Vec3d getMinimumPos(Vec3d pos1, Vec3d pos2) { @@ -150,109 +142,106 @@ private static void addBoxVertices(BufferBuilder bufferBuilder, MatrixStack matr if (outline) { // idk man - bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F).next(); - bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F).next(); - bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F).next(); - bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F).next(); - bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F).next(); - bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, -1.0F, 0.0F, 0.0F).next(); - bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, -1.0F, 0.0F, 0.0F).next(); - bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F).next(); - bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F).next(); - bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0.0F, -1.0F, 0.0F).next(); - bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0.0F, -1.0F, 0.0F).next(); - bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, -1.0F).next(); - bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, -1.0F).next(); - bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F).next(); - bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F).next(); - bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F).next(); + bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F); + bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F); + bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F); + bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F); + bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F); + bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F); + bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F); + bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F); + bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, -1.0F, 0.0F, 0.0F); + bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, -1.0F, 0.0F, 0.0F); + bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F); + bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F); + bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0.0F, -1.0F, 0.0F); + bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0.0F, -1.0F, 0.0F); + bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F); + bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F); + bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, -1.0F); + bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, -1.0F); + bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F); + bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 1.0F, 0.0F, 0.0F); + bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F); + bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 1.0F, 0.0F); + bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F); + bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0.0F, 0.0F, 1.0F); return; } // West Face - bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); + bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); // East Face - bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); + bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); // North Face - bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); + bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); // South Face - bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); + bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); // Down Face - bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); + bufferBuilder.vertex(model, c0, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, c0, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, c0, c0, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); // Up Face - bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); + bufferBuilder.vertex(model, c0, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, c0, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, y1, z1).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + bufferBuilder.vertex(model, x1, y1, c0).color(red, green, blue, alpha).normal(entry, 0, 0, 0); } private static void renderSpheres(MatrixStack matrices) { Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera(); Vec3d cameraPos = camera.getPos(); if (ScriptSphere.hasRegular()) { - drawSpheresOutlines(tessellator, bufferBuilder, matrices, cameraPos, ScriptSphere::forEachRegular); - drawSpheres(tessellator, bufferBuilder, matrices, cameraPos, ScriptSphere::forEachRegular); + drawSpheresOutlines(tessellator, matrices, cameraPos, ScriptSphere::forEachRegular); + drawSpheres(tessellator, matrices, cameraPos, ScriptSphere::forEachRegular); } if (ScriptSphere.hasIgnoreDepth()) { RenderSystem.disableDepthTest(); - drawSpheresOutlines(tessellator, bufferBuilder, matrices, cameraPos, ScriptSphere::forEachIgnoreDepth); - drawSpheres(tessellator, bufferBuilder, matrices, cameraPos, ScriptSphere::forEachIgnoreDepth); + drawSpheresOutlines(tessellator, matrices, cameraPos, ScriptSphere::forEachIgnoreDepth); + drawSpheres(tessellator, matrices, cameraPos, ScriptSphere::forEachIgnoreDepth); RenderSystem.enableDepthTest(); } } - private static void drawSpheresOutlines(Tessellator tessellator, BufferBuilder bufferBuilder, MatrixStack matrices, Vec3d camera, Consumer> forEach) { + private static void drawSpheresOutlines(Tessellator tessellator, MatrixStack matrices, Vec3d camera, Consumer> forEach) { setLineShader(); - startLines(bufferBuilder); + BufferBuilder bufferBuilder = startLines(tessellator); forEach.accept(sphere -> { if (sphere.getOutlineWidth() >= 1) { RenderSystem.lineWidth(sphere.getOutlineWidth()); addSphereToBuffer(bufferBuilder, matrices, camera, sphere, true); } }); - tessellator.draw(); } - private static void drawSpheres(Tessellator tessellator, BufferBuilder bufferBuilder, MatrixStack matrices, Vec3d cameraPos, Consumer> forEach) { + private static void drawSpheres(Tessellator tessellator, MatrixStack matrices, Vec3d cameraPos, Consumer> forEach) { setPositionColourShader(); - startQuads(bufferBuilder, VertexFormats.POSITION_COLOR); + BufferBuilder bufferBuilder = startQuads(tessellator, VertexFormats.POSITION_COLOR); forEach.accept(sphere -> { addSphereToBuffer(bufferBuilder, matrices, cameraPos, sphere, false); }); - tessellator.draw(); } private static void addSphereToBuffer(BufferBuilder bufferBuilder, MatrixStack matrices, Vec3d cameraPos, ScriptSphere sphere, boolean outline) { @@ -292,7 +281,7 @@ private static void addSphereVertices(BufferBuilder builder, MatrixStack matrice float y = radius * MathHelper.cos(phi); Vector3f normalVector = new Vector3f(x, y, z); normalVector.normalize(); - builder.vertex(model, x, y, z).color(red, green, blue, alpha).normal(entry, normalVector.x, normalVector.y, normalVector.z).next(); + builder.vertex(model, x, y, z).color(red, green, blue, alpha).normal(entry, normalVector.x, normalVector.y, normalVector.z); } } for (int j = 0; j <= totalSteps; j++) { @@ -304,7 +293,7 @@ private static void addSphereVertices(BufferBuilder builder, MatrixStack matrice float y = radius * MathHelper.cos(phi); Vector3f normalVector = new Vector3f(x, y, z); normalVector.normalize(); - builder.vertex(model, x, y, z).color(red, green, blue, alpha).normal(entry, normalVector.x, normalVector.y, normalVector.z).next(); + builder.vertex(model, x, y, z).color(red, green, blue, alpha).normal(entry, normalVector.x, normalVector.y, normalVector.z); } } return; @@ -325,10 +314,10 @@ private static void addSphereVertices(BufferBuilder builder, MatrixStack matrice float y = radius * MathHelper.cos(phi); float xp = radius * MathHelper.sin(phi) * MathHelper.cos(thetaPrime); float zp = radius * MathHelper.sin(phi) * MathHelper.sin(thetaPrime); - builder.vertex(model, xb, yp, zb).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - builder.vertex(model, xbp, yp, zbp).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - builder.vertex(model, xp, y, zp).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); - builder.vertex(model, x, y, z).color(red, green, blue, alpha).normal(entry, 0, 0, 0).next(); + builder.vertex(model, xb, yp, zb).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + builder.vertex(model, xbp, yp, zbp).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + builder.vertex(model, xp, y, zp).color(red, green, blue, alpha).normal(entry, 0, 0, 0); + builder.vertex(model, x, y, z).color(red, green, blue, alpha).normal(entry, 0, 0, 0); xb = x; zb = z; xbp = xp; @@ -340,32 +329,30 @@ private static void addSphereVertices(BufferBuilder builder, MatrixStack matrice private static void renderLines(MatrixStack matrices) { Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera(); Vec3d cameraPos = camera.getPos(); if (ScriptLine.hasRegular()) { RenderSystem.enableDepthTest(); - drawLines(tessellator, bufferBuilder, matrices, cameraPos, ScriptLine::forEachRegular); + drawLines(tessellator, matrices, cameraPos, ScriptLine::forEachRegular); } if (ScriptLine.hasIgnoreDepth()) { RenderSystem.disableDepthTest(); - drawLines(tessellator, bufferBuilder, matrices, cameraPos, ScriptLine::forEachIgnoreDepth); + drawLines(tessellator, matrices, cameraPos, ScriptLine::forEachIgnoreDepth); RenderSystem.enableDepthTest(); } } - private static void drawLines(Tessellator tessellator, BufferBuilder builder, MatrixStack matrices, Vec3d cameraPos, Consumer> forEach) { + private static void drawLines(Tessellator tessellator, MatrixStack matrices, Vec3d cameraPos, Consumer> forEach) { setLineShader(); - startLines(builder); + BufferBuilder builder = startLines(tessellator); forEach.accept(line -> { if (line.getOutlineWidth() >= 1) { RenderSystem.lineWidth(line.getOutlineWidth()); addLineToBuffer(builder, matrices, cameraPos, line); } }); - tessellator.draw(); } private static void addLineToBuffer(BufferBuilder builder, MatrixStack matrices, Vec3d cameraPos, ScriptLine line) { @@ -396,8 +383,8 @@ private static void addLineVertices(BufferBuilder builder, MatrixStack matrices, MatrixStack.Entry entry = matrices.peek(); Matrix4f model = entry.getPositionMatrix(); - builder.vertex(model, pos1.x, pos1.y, pos1.z).color(red, green, blue, alpha).normal(entry, normalVec.x, normalVec.y, normalVec.z).next(); - builder.vertex(model, pos2.x, pos2.y, pos2.z).color(red, green, blue, alpha).normal(entry, normalVec.x, normalVec.y, normalVec.z).next(); + builder.vertex(model, pos1.x, pos1.y, pos1.z).color(red, green, blue, alpha).normal(entry, normalVec.x, normalVec.y, normalVec.z); + builder.vertex(model, pos2.x, pos2.y, pos2.z).color(red, green, blue, alpha).normal(entry, normalVec.x, normalVec.y, normalVec.z); } public static void renderBlocks(MatrixStack matrices) { @@ -515,68 +502,20 @@ private static void renderQuads(MatrixStack.Entry entry, VertexConsumer vertexCo g = MathHelper.clamp(green, 0.0f, 1.0F); b = MathHelper.clamp(blue, 0.0f, 1.0F); } - vertexConsumerQuad(vertexConsumer, entry, bakedQuad, r, g, b, a, light, overlay); + vertexConsumer.quad(entry, bakedQuad, r, g, b, a, light, overlay); } } - private static void vertexConsumerQuad(VertexConsumer consumer, MatrixStack.Entry matrixEntry, BakedQuad quad, float red, float green, float blue, float alpha, int light, int overlay) { - vertexConsumerQuad(consumer, matrixEntry, quad, new float[]{1.0f, 1.0f, 1.0f, 1.0f}, red, green, blue, alpha, new int[]{light, light, light, light}, overlay, false); - } - - private static void vertexConsumerQuad(VertexConsumer consumer, MatrixStack.Entry matrixEntry, BakedQuad quad, float[] brightnesses, float red, float green, float blue, float alpha, int[] lights, int overlay, @SuppressWarnings("SameParameterValue") boolean useQuadColorData) { - float[] fs = {brightnesses[0], brightnesses[1], brightnesses[2], brightnesses[3]}; - int[] is = {lights[0], lights[1], lights[2], lights[3]}; - int[] js = quad.getVertexData(); - Vec3i vec3i = quad.getFace().getVector(); - Matrix4f matrix4f = matrixEntry.getPositionMatrix(); - Vector3f vec3f = matrixEntry.getNormalMatrix().transform(new Vector3f(vec3i.getX(), vec3i.getY(), vec3i.getZ())); - int i = 8; - int j = js.length / i; - try (MemoryStack memoryStack = MemoryStack.stackPush()) { - ByteBuffer byteBuffer = memoryStack.malloc(VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL.getVertexSizeByte()); - IntBuffer intBuffer = byteBuffer.asIntBuffer(); - for (int k = 0; k < j; ++k) { - float q; - float p; - float o; - float n; - float m; - intBuffer.clear(); - intBuffer.put(js, k * 8, 8); - float f = byteBuffer.getFloat(0); - float g = byteBuffer.getFloat(4); - float h = byteBuffer.getFloat(8); - if (useQuadColorData) { - float l = (float) (byteBuffer.get(12) & 0xFF) / 255.0f; - m = (float) (byteBuffer.get(13) & 0xFF) / 255.0f; - n = (float) (byteBuffer.get(14) & 0xFF) / 255.0f; - o = l * fs[k] * red; - p = m * fs[k] * green; - q = n * fs[k] * blue; - } else { - o = fs[k] * red; - p = fs[k] * green; - q = fs[k] * blue; - } - int r = is[k]; - m = byteBuffer.getFloat(16); - n = byteBuffer.getFloat(20); - Vector4f vector4f = matrix4f.transform(new Vector4f(f, g, h, 1.0F)); - consumer.vertex(vector4f.x, vector4f.y, vector4f.z, o, p, q, alpha, m, n, overlay, r, vec3f.x, vec3f.y, vec3f.z); - } - } - } - - public static void startLines(BufferBuilder builder) { - builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES); + public static BufferBuilder startLines(Tessellator tessellator) { + return tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES); } - public static void startDebugLines(BufferBuilder builder, VertexFormat format) { - builder.begin(VertexFormat.DrawMode.DEBUG_LINES, format); + public static BufferBuilder startDebugLines(Tessellator tessellator, VertexFormat format) { + return tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, format); } - public static void startQuads(BufferBuilder builder, VertexFormat format) { - builder.begin(VertexFormat.DrawMode.QUADS, format); + public static BufferBuilder startQuads(Tessellator tessellator, VertexFormat format) { + return tessellator.begin(VertexFormat.DrawMode.QUADS, format); } public static void setLineShader() { diff --git a/src/main/java/me/senseiwells/essentialclient/utils/render/Texts.java b/src/main/java/me/senseiwells/essentialclient/utils/render/Texts.java index 330bc84c..bdae8993 100644 --- a/src/main/java/me/senseiwells/essentialclient/utils/render/Texts.java +++ b/src/main/java/me/senseiwells/essentialclient/utils/render/Texts.java @@ -150,8 +150,8 @@ public class Texts { public static final TextGenerator CURRENT_REGION = o -> translatable("essentialclient.region.currentRegion", o); public static final TextGenerator DISTANT_REGION = o -> translatable("essentialclient.region.distantRegion", o); - public static final Identifier JETBRAINS_MONO = new Identifier("essentialclient", "jetbrainsmono"); - public static final Identifier MINECRAFT_MONO = new Identifier("essentialclient", "monocraft"); + public static final Identifier JETBRAINS_MONO = Identifier.of("essentialclient", "jetbrainsmono"); + public static final Identifier MINECRAFT_MONO = Identifier.of("essentialclient", "monocraft"); public static String getTranslatableKey(Text text) { if (text.getContent() instanceof TranslatableTextContent translatableText) {