From a8075158baef50f53565bbcf94ae14fb631dccb4 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Thu, 30 Oct 2025 02:30:59 +1000 Subject: [PATCH] mojmap part 1 --- build.gradle | 2 +- gradle.properties | 1 - .../voxy/client/ClientImportManager.java | 33 +++-- .../client/ICheekyClientChunkManager.java | 4 +- .../me/cortex/voxy/client/VoxyClient.java | 7 +- .../voxy/client/VoxyClientInstance.java | 17 ++- .../me/cortex/voxy/client/VoxyCommands.java | 44 +++--- .../voxy/client/VoxyDebugScreenEntry.java | 31 ++-- .../client/config/VoxyConfigScreenPages.java | 57 ++++---- .../client/core/NormalRenderPipeline.java | 4 +- .../voxy/client/core/VoxyRenderSystem.java | 22 +-- .../core/model/ModelBakerySubsystem.java | 4 - .../voxy/client/core/model/ModelFactory.java | 132 +++++++++--------- .../voxy/client/core/model/ModelStore.java | 10 +- .../voxy/client/core/model/TextureUtils.java | 4 +- .../model/bakery/BakedBlockEntityModel.java | 65 +++------ .../model/bakery/BudgetBufferRenderer.java | 17 ++- .../core/model/bakery/ModelTextureBakery.java | 119 ++++++++-------- .../model/bakery/ReuseVertexConsumer.java | 23 +-- .../core/rendering/ChunkBoundRenderer.java | 5 +- .../voxy/client/core/rendering/Viewport.java | 8 +- .../rendering/hierachical/DebugRenderer.java | 8 +- .../section/MDICSectionRenderer.java | 4 +- .../core/rendering/util/LightMapHelper.java | 6 +- .../cortex/voxy/client/iris/VoxyUniforms.java | 8 +- .../flashback/MixinFlashbackRecorder.java | 4 +- .../voxy/client/mixin/iris/MixinIris.java | 1 - .../iris/MixinIrisRenderingPipeline.java | 4 +- .../client/mixin/iris/MixinWorldRenderer.java | 26 ++-- .../minecraft/MixinClientChunkManager.java | 16 +-- .../MixinClientCommonNetworkHandler.java | 12 +- .../MixinClientLoginNetworkHandler.java | 10 +- .../mixin/minecraft/MixinClientWorld.java | 58 ++++---- .../mixin/minecraft/MixinFogRenderer.java | 10 +- .../client/mixin/minecraft/MixinGlDebug.java | 6 +- .../mixin/minecraft/MixinMinecraftClient.java | 6 +- .../mixin/minecraft/MixinRenderSystem.java | 4 +- .../mixin/minecraft/MixinThreadExecutor.java | 11 +- .../client/mixin/minecraft/MixinWindow.java | 12 +- .../mixin/minecraft/MixinWorldRenderer.java | 23 ++- .../mixin/nvidium/MixinRenderPipeline.java | 4 +- .../sodium/MixinDefaultChunkRenderer.java | 4 +- .../sodium/MixinRenderSectionManager.java | 40 +++--- .../mixin/sodium/MixinSodiumOptionsGUI.java | 2 +- .../cortex/voxy/client/taskbar/Taskbar.java | 4 +- .../java/me/cortex/voxy/common/Logger.java | 12 +- .../inmemory/MemoryStorageBackend.java | 4 +- .../FragmentedStorageBackendAdaptor.java | 5 +- .../voxelization/WorldConversionFactory.java | 53 +++---- .../voxy/common/world/SaveLoadSystem2.java | 10 +- .../voxy/common/world/other/Mapper.java | 52 +++---- .../world/service/VoxelIngestService.java | 70 +++++----- .../voxy/commonImpl/WorldIdentifier.java | 34 ++--- .../voxy/commonImpl/importers/DHImporter.java | 50 +++---- .../commonImpl/importers/WorldImporter.java | 85 +++++------ .../mixin/chunky/MixinFabricWorld.java | 14 +- .../mixin/minecraft/MixinWorld.java | 24 ++-- src/main/resources/voxy.accesswidener | 49 +++---- 58 files changed, 661 insertions(+), 693 deletions(-) diff --git a/build.gradle b/build.gradle index 12729ae3..5ab53405 100644 --- a/build.gradle +++ b/build.gradle @@ -93,7 +93,7 @@ if (!isInGHA) { 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}" diff --git a/gradle.properties b/gradle.properties index ce2ed4f8..7530cea8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,6 @@ org.gradle.daemon = false # Fabric Properties # check these on https://modmuss50.me/fabric.html minecraft_version=1.21.10 -yarn_mappings=1.21.10+build.1 loader_version=0.17.2 loom_version=1.11-SNAPSHOT diff --git a/src/main/java/me/cortex/voxy/client/ClientImportManager.java b/src/main/java/me/cortex/voxy/client/ClientImportManager.java index 6aed8434..892506c1 100644 --- a/src/main/java/me/cortex/voxy/client/ClientImportManager.java +++ b/src/main/java/me/cortex/voxy/client/ClientImportManager.java @@ -3,25 +3,24 @@ package me.cortex.voxy.client; import me.cortex.voxy.common.Logger; import me.cortex.voxy.commonImpl.ImportManager; import me.cortex.voxy.commonImpl.importers.IDataImporter; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.hud.ClientBossBar; -import net.minecraft.entity.boss.BossBar; -import net.minecraft.text.Text; -import net.minecraft.util.math.MathHelper; - +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.LerpingBossEvent; +import net.minecraft.network.chat.Component; +import net.minecraft.util.Mth; +import net.minecraft.world.BossEvent; import java.util.UUID; public class ClientImportManager extends ImportManager { protected class ClientImportTask extends ImportTask { private final UUID bossbarUUID; - private final ClientBossBar bossBar; + private final LerpingBossEvent bossBar; protected ClientImportTask(IDataImporter importer) { super(importer); - this.bossbarUUID = MathHelper.randomUuid(); - this.bossBar = new ClientBossBar(this.bossbarUUID, Text.of("Voxy world importer"), 0.0f, BossBar.Color.GREEN, BossBar.Style.PROGRESS, false, false, false); - MinecraftClient.getInstance().execute(()->{ - MinecraftClient.getInstance().inGameHud.getBossBarHud().bossBars.put(bossBar.getUuid(), bossBar); + this.bossbarUUID = Mth.createInsecureUUID(); + this.bossBar = new LerpingBossEvent(this.bossbarUUID, Component.nullToEmpty("Voxy world importer"), 0.0f, BossEvent.BossBarColor.GREEN, BossEvent.BossBarOverlay.PROGRESS, false, false, false); + Minecraft.getInstance().execute(()->{ + Minecraft.getInstance().gui.getBossOverlay().events.put(bossBar.getId(), bossBar); }); } @@ -30,9 +29,9 @@ public class ClientImportManager extends ImportManager { if (!super.onUpdate(completed, outOf)) { return false; } - MinecraftClient.getInstance().execute(()->{ - this.bossBar.setPercent((float) (((double)completed) / ((double) Math.max(1, outOf)))); - this.bossBar.setName(Text.of("Voxy import: " + completed + "/" + outOf + " chunks")); + Minecraft.getInstance().execute(()->{ + this.bossBar.setProgress((float) (((double)completed) / ((double) Math.max(1, outOf)))); + this.bossBar.setName(Component.nullToEmpty("Voxy import: " + completed + "/" + outOf + " chunks")); }); return true; } @@ -40,12 +39,12 @@ public class ClientImportManager extends ImportManager { @Override protected void onCompleted(int total) { super.onCompleted(total); - MinecraftClient.getInstance().execute(()->{ - MinecraftClient.getInstance().inGameHud.getBossBarHud().bossBars.remove(this.bossbarUUID); + Minecraft.getInstance().execute(()->{ + Minecraft.getInstance().gui.getBossOverlay().events.remove(this.bossbarUUID); long delta = Math.max(System.currentTimeMillis() - this.startTime, 1); String msg = "Voxy world import finished in " + (delta/1000) + " seconds, averaging " + (int)(total/(delta/1000f)) + " chunks per second"; - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.literal(msg)); + Minecraft.getInstance().gui.getChat().addMessage(Component.literal(msg)); Logger.info(msg); }); } diff --git a/src/main/java/me/cortex/voxy/client/ICheekyClientChunkManager.java b/src/main/java/me/cortex/voxy/client/ICheekyClientChunkManager.java index 2fc7e88e..c53d0def 100644 --- a/src/main/java/me/cortex/voxy/client/ICheekyClientChunkManager.java +++ b/src/main/java/me/cortex/voxy/client/ICheekyClientChunkManager.java @@ -1,7 +1,7 @@ package me.cortex.voxy.client; -import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.world.level.chunk.LevelChunk; public interface ICheekyClientChunkManager { - WorldChunk voxy$cheekyGetChunk(int x, int z); + LevelChunk voxy$cheekyGetChunk(int x, int z); } diff --git a/src/main/java/me/cortex/voxy/client/VoxyClient.java b/src/main/java/me/cortex/voxy/client/VoxyClient.java index 5b157f19..04612c6e 100644 --- a/src/main/java/me/cortex/voxy/client/VoxyClient.java +++ b/src/main/java/me/cortex/voxy/client/VoxyClient.java @@ -8,9 +8,8 @@ import me.cortex.voxy.commonImpl.VoxyCommon; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.gui.hud.debug.DebugHudEntries; -import net.minecraft.util.Identifier; - +import net.minecraft.client.gui.components.debug.DebugScreenEntries; +import net.minecraft.resources.ResourceLocation; import java.util.HashSet; import java.util.function.Consumer; import java.util.function.Function; @@ -40,7 +39,7 @@ public class VoxyClient implements ClientModInitializer { @Override public void onInitializeClient() { - DebugHudEntries.register(Identifier.of("voxy","debug"), new VoxyDebugScreenEntry()); + DebugScreenEntries.register(ResourceLocation.fromNamespaceAndPath("voxy","debug"), new VoxyDebugScreenEntry()); ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> { if (VoxyCommon.isAvailable()) { dispatcher.register(VoxyCommands.register()); diff --git a/src/main/java/me/cortex/voxy/client/VoxyClientInstance.java b/src/main/java/me/cortex/voxy/client/VoxyClientInstance.java index fa8bd84c..c6b0c5a4 100644 --- a/src/main/java/me/cortex/voxy/client/VoxyClientInstance.java +++ b/src/main/java/me/cortex/voxy/client/VoxyClientInstance.java @@ -14,9 +14,8 @@ import me.cortex.voxy.common.config.storage.rocksdb.RocksDBStorageBackend; import me.cortex.voxy.commonImpl.ImportManager; import me.cortex.voxy.commonImpl.VoxyInstance; import me.cortex.voxy.commonImpl.WorldIdentifier; -import net.minecraft.client.MinecraftClient; -import net.minecraft.util.WorldSavePath; - +import net.minecraft.client.Minecraft; +import net.minecraft.world.level.storage.LevelResource; import java.nio.file.Files; import java.nio.file.Path; @@ -125,17 +124,17 @@ public class VoxyClientInstance extends VoxyInstance { } private static Path getBasePath() { - Path basePath = MinecraftClient.getInstance().runDirectory.toPath().resolve(".voxy").resolve("saves"); - var iserver = MinecraftClient.getInstance().getServer(); + Path basePath = Minecraft.getInstance().gameDirectory.toPath().resolve(".voxy").resolve("saves"); + var iserver = Minecraft.getInstance().getSingleplayerServer(); if (iserver != null) { - basePath = iserver.getSavePath(WorldSavePath.ROOT).resolve("voxy"); + basePath = iserver.getWorldPath(LevelResource.ROOT).resolve("voxy"); } else { - var netHandle = MinecraftClient.getInstance().interactionManager; + var netHandle = Minecraft.getInstance().gameMode; if (netHandle == null) { Logger.error("Network handle null"); basePath = basePath.resolve("UNKNOWN"); } else { - var info = netHandle.networkHandler.getServerInfo(); + var info = netHandle.connection.getServerData(); if (info == null) { Logger.error("Server info null"); basePath = basePath.resolve("UNKNOWN"); @@ -143,7 +142,7 @@ public class VoxyClientInstance extends VoxyInstance { if (info.isRealm()) { basePath = basePath.resolve("realms"); } else { - basePath = basePath.resolve(info.address.replace(":", "_")); + basePath = basePath.resolve(info.ip.replace(":", "_")); } } } diff --git a/src/main/java/me/cortex/voxy/client/VoxyCommands.java b/src/main/java/me/cortex/voxy/client/VoxyCommands.java index 9bd7da88..4bf4cd01 100644 --- a/src/main/java/me/cortex/voxy/client/VoxyCommands.java +++ b/src/main/java/me/cortex/voxy/client/VoxyCommands.java @@ -12,11 +12,9 @@ import me.cortex.voxy.commonImpl.importers.DHImporter; import me.cortex.voxy.commonImpl.importers.WorldImporter; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.client.MinecraftClient; -import net.minecraft.command.CommandSource; -import net.minecraft.text.PlainTextContent; -import net.minecraft.text.Text; - +import net.minecraft.client.Minecraft; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -63,10 +61,10 @@ public class VoxyCommands { private static int reloadInstance(CommandContext ctx) { var instance = (VoxyClientInstance)VoxyCommon.getInstance(); if (instance == null) { - ctx.getSource().sendError(Text.translatable("Voxy must be enabled in settings to use this")); + ctx.getSource().sendError(Component.translatable("Voxy must be enabled in settings to use this")); return 1; } - var wr = MinecraftClient.getInstance().worldRenderer; + var wr = Minecraft.getInstance().levelRenderer; if (wr!=null) { ((IGetVoxyRenderSystem)wr).shutdownRenderer(); } @@ -85,7 +83,7 @@ public class VoxyCommands { private static int importDistantHorizons(CommandContext ctx) { var instance = (VoxyClientInstance)VoxyCommon.getInstance(); if (instance == null) { - ctx.getSource().sendError(Text.translatable("Voxy must be enabled in settings to use this")); + ctx.getSource().sendError(Component.translatable("Voxy must be enabled in settings to use this")); return 1; } var dbFile = new File(ctx.getArgument("sqlDbPath", String.class)); @@ -100,10 +98,10 @@ public class VoxyCommands { } File dbFile_ = dbFile; - var engine = WorldIdentifier.ofEngine(MinecraftClient.getInstance().world); + var engine = WorldIdentifier.ofEngine(Minecraft.getInstance().level); if (engine==null)return 1; return instance.getImportManager().makeAndRunIfNone(engine, ()-> - new DHImporter(dbFile_, engine, MinecraftClient.getInstance().world, instance.getServiceManager(), instance.savingServiceRateLimiter))?0:1; + new DHImporter(dbFile_, engine, Minecraft.getInstance().level, instance.getServiceManager(), instance.savingServiceRateLimiter))?0:1; } private static boolean fileBasedImporter(File directory) { @@ -112,10 +110,10 @@ public class VoxyCommands { return false; } - var engine = WorldIdentifier.ofEngine(MinecraftClient.getInstance().world); + var engine = WorldIdentifier.ofEngine(Minecraft.getInstance().level); if (engine==null) return false; return instance.getImportManager().makeAndRunIfNone(engine, ()->{ - var importer = new WorldImporter(engine, MinecraftClient.getInstance().world, instance.getServiceManager(), instance.savingServiceRateLimiter); + var importer = new WorldImporter(engine, Minecraft.getInstance().level, instance.getServiceManager(), instance.savingServiceRateLimiter); importer.importRegionDirectoryAsync(directory); return importer; }); @@ -123,7 +121,7 @@ public class VoxyCommands { private static int importRaw(CommandContext ctx) { if (VoxyCommon.getInstance() == null) { - ctx.getSource().sendError(Text.translatable("Voxy must be enabled in settings to use this")); + ctx.getSource().sendError(Component.translatable("Voxy must be enabled in settings to use this")); return 1; } @@ -132,7 +130,7 @@ public class VoxyCommands { private static int importBobby(CommandContext ctx) { if (VoxyCommon.getInstance() == null) { - ctx.getSource().sendError(Text.translatable("Voxy must be enabled in settings to use this")); + ctx.getSource().sendError(Component.translatable("Voxy must be enabled in settings to use this")); return 1; } @@ -141,10 +139,10 @@ public class VoxyCommands { } private static CompletableFuture importWorldSuggester(CommandContext ctx, SuggestionsBuilder sb) { - return fileDirectorySuggester(MinecraftClient.getInstance().runDirectory.toPath().resolve("saves"), sb); + return fileDirectorySuggester(Minecraft.getInstance().gameDirectory.toPath().resolve("saves"), sb); } private static CompletableFuture importBobbySuggester(CommandContext ctx, SuggestionsBuilder sb) { - return fileDirectorySuggester(MinecraftClient.getInstance().runDirectory.toPath().resolve(".bobby"), sb); + return fileDirectorySuggester(Minecraft.getInstance().gameDirectory.toPath().resolve(".bobby"), sb); } private static CompletableFuture fileDirectorySuggester(Path dir, SuggestionsBuilder sb) { @@ -179,7 +177,7 @@ public class VoxyCommands { if (wn.equals(remaining)) { continue; } - if (CommandSource.shouldSuggest(remaining, wn) || CommandSource.shouldSuggest(remaining, '"'+wn)) { + if (SharedSuggestionProvider.matchesSubStr(remaining, wn) || SharedSuggestionProvider.matchesSubStr(remaining, '"'+wn)) { wn = str+wn + "/"; sb.suggest(StringArgumentType.escapeIfRequired(wn)); } @@ -191,7 +189,7 @@ public class VoxyCommands { private static int importWorld(CommandContext ctx) { if (VoxyCommon.getInstance() == null) { - ctx.getSource().sendError(Text.translatable("Voxy must be enabled in settings to use this")); + ctx.getSource().sendError(Component.translatable("Voxy must be enabled in settings to use this")); return 1; } @@ -216,15 +214,15 @@ public class VoxyCommands { var instance = (VoxyClientInstance)VoxyCommon.getInstance(); if (instance == null) { - ctx.getSource().sendError(Text.translatable("Voxy must be enabled in settings to use this")); + ctx.getSource().sendError(Component.translatable("Voxy must be enabled in settings to use this")); return 1; } String finalInnerDir = innerDir; - var engine = WorldIdentifier.ofEngine(MinecraftClient.getInstance().world); + var engine = WorldIdentifier.ofEngine(Minecraft.getInstance().level); if (engine != null) { return instance.getImportManager().makeAndRunIfNone(engine, () -> { - var importer = new WorldImporter(engine, MinecraftClient.getInstance().world, instance.getServiceManager(), instance.savingServiceRateLimiter); + var importer = new WorldImporter(engine, Minecraft.getInstance().level, instance.getServiceManager(), instance.savingServiceRateLimiter); importer.importZippedRegionDirectoryAsync(zip, finalInnerDir); return importer; }) ? 0 : 1; @@ -235,10 +233,10 @@ public class VoxyCommands { private static int cancelImport(CommandContext ctx) { var instance = (VoxyClientInstance)VoxyCommon.getInstance(); if (instance == null) { - ctx.getSource().sendError(Text.translatable("Voxy must be enabled in settings to use this")); + ctx.getSource().sendError(Component.translatable("Voxy must be enabled in settings to use this")); return 1; } - var world = WorldIdentifier.ofEngineNullable(MinecraftClient.getInstance().world); + var world = WorldIdentifier.ofEngineNullable(Minecraft.getInstance().level); if (world != null) { return instance.getImportManager().cancelImport(world)?0:1; } diff --git a/src/main/java/me/cortex/voxy/client/VoxyDebugScreenEntry.java b/src/main/java/me/cortex/voxy/client/VoxyDebugScreenEntry.java index 9cef5dd1..6e009a92 100644 --- a/src/main/java/me/cortex/voxy/client/VoxyDebugScreenEntry.java +++ b/src/main/java/me/cortex/voxy/client/VoxyDebugScreenEntry.java @@ -3,47 +3,46 @@ package me.cortex.voxy.client; import me.cortex.voxy.client.core.IGetVoxyRenderSystem; import me.cortex.voxy.client.core.VoxyRenderSystem; import me.cortex.voxy.commonImpl.VoxyCommon; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.hud.debug.DebugHudEntry; -import net.minecraft.client.gui.hud.debug.DebugHudLines; -import net.minecraft.util.Colors; -import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; -import net.minecraft.world.World; -import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.debug.DebugScreenDisplayer; +import net.minecraft.client.gui.components.debug.DebugScreenEntry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; -public class VoxyDebugScreenEntry implements DebugHudEntry { +public class VoxyDebugScreenEntry implements DebugScreenEntry { @Override - public void render(DebugHudLines lines, @Nullable World world, @Nullable WorldChunk clientChunk, @Nullable WorldChunk chunk) { + public void display(DebugScreenDisplayer lines, @Nullable Level world, @Nullable LevelChunk clientChunk, @Nullable LevelChunk chunk) { if (!VoxyCommon.isAvailable()) { - lines.addLine(Formatting.RED + "voxy-"+VoxyCommon.MOD_VERSION);//Voxy installed, not avalible + lines.addLine(ChatFormatting.RED + "voxy-"+VoxyCommon.MOD_VERSION);//Voxy installed, not avalible return; } var instance = VoxyCommon.getInstance(); if (instance == null) { - lines.addLine(Formatting.YELLOW + "voxy-" + VoxyCommon.MOD_VERSION);//Voxy avalible, no instance active + lines.addLine(ChatFormatting.YELLOW + "voxy-" + VoxyCommon.MOD_VERSION);//Voxy avalible, no instance active return; } VoxyRenderSystem vrs = null; - var wr = MinecraftClient.getInstance().worldRenderer; + var wr = Minecraft.getInstance().levelRenderer; if (wr != null) vrs = ((IGetVoxyRenderSystem) wr).getVoxyRenderSystem(); //Voxy instance active - lines.addLine((vrs==null?Formatting.DARK_GREEN:Formatting.GREEN)+"voxy-"+VoxyCommon.MOD_VERSION); + lines.addLine((vrs==null?ChatFormatting.DARK_GREEN:ChatFormatting.GREEN)+"voxy-"+VoxyCommon.MOD_VERSION); //lines.addLineToSection(); List instanceLines = new ArrayList<>(); instance.addDebug(instanceLines); - lines.addLinesToSection(Identifier.of("voxy", "instance_debug"), instanceLines); + lines.addToGroup(ResourceLocation.fromNamespaceAndPath("voxy", "instance_debug"), instanceLines); if (vrs != null) { List renderLines = new ArrayList<>(); vrs.addDebugInfo(renderLines); - lines.addLinesToSection(Identifier.of("voxy", "render_debug"), renderLines); + lines.addToGroup(ResourceLocation.fromNamespaceAndPath("voxy", "render_debug"), renderLines); } } diff --git a/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenPages.java b/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenPages.java index e51b65ca..7c69d0a0 100644 --- a/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenPages.java +++ b/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenPages.java @@ -11,9 +11,8 @@ import net.caffeinemc.mods.sodium.client.gui.options.*; import net.caffeinemc.mods.sodium.client.gui.options.control.SliderControl; import net.caffeinemc.mods.sodium.client.gui.options.control.TickBoxControl; import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; - +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; @@ -29,21 +28,21 @@ public abstract class VoxyConfigScreenPages { //General groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, storage) - .setName(Text.translatable("voxy.config.general.enabled")) - .setTooltip(Text.translatable("voxy.config.general.enabled.tooltip")) + .setName(Component.translatable("voxy.config.general.enabled")) + .setTooltip(Component.translatable("voxy.config.general.enabled.tooltip")) .setControl(TickBoxControl::new) .setBinding((s, v)->{ s.enabled = v; if (v) { if (VoxyClientInstance.isInGame) { VoxyCommon.createInstance(); - var vrsh = (IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer; + var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer; if (vrsh != null && s.enableRendering) { vrsh.createRenderer(); } } } else { - var vrsh = (IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer; + var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer; if (vrsh != null) { vrsh.shutdownRenderer(); } @@ -57,12 +56,12 @@ public abstract class VoxyConfigScreenPages { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(int.class, storage) - .setName(Text.translatable("voxy.config.general.serviceThreads")) - .setTooltip(Text.translatable("voxy.config.general.serviceThreads.tooltip")) + .setName(Component.translatable("voxy.config.general.serviceThreads")) + .setTooltip(Component.translatable("voxy.config.general.serviceThreads.tooltip")) .setControl(opt->new SliderControl(opt, 1, CpuLayout.CORES.length, //Just do core size as max //Runtime.getRuntime().availableProcessors(),//Note: this is threads not cores, the default value is half the core count, is fine as this should technically be the limit but CpuLayout.CORES.length is more realistic - 1, v->Text.literal(Integer.toString(v)))) + 1, v->Component.literal(Integer.toString(v)))) .setBinding((s, v)->{ s.serviceThreads = v; var instance = VoxyCommon.getInstance(); @@ -83,8 +82,8 @@ public abstract class VoxyConfigScreenPages { .setImpact(OptionImpact.HIGH) .build() ).add(OptionImpl.createBuilder(boolean.class, storage) - .setName(Text.translatable("voxy.config.general.ingest")) - .setTooltip(Text.translatable("voxy.config.general.ingest.tooltip")) + .setName(Component.translatable("voxy.config.general.ingest")) + .setTooltip(Component.translatable("voxy.config.general.ingest.tooltip")) .setControl(TickBoxControl::new) .setBinding((s, v) -> s.ingestEnabled = v, s -> s.ingestEnabled) .setImpact(OptionImpact.MEDIUM) @@ -94,12 +93,12 @@ public abstract class VoxyConfigScreenPages { groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, storage) - .setName(Text.translatable("voxy.config.general.rendering")) - .setTooltip(Text.translatable("voxy.config.general.rendering.tooltip")) + .setName(Component.translatable("voxy.config.general.rendering")) + .setTooltip(Component.translatable("voxy.config.general.rendering.tooltip")) .setControl(TickBoxControl::new) .setBinding((s, v)->{ s.enableRendering = v; - var vrsh = (IGetVoxyRenderSystem)MinecraftClient.getInstance().worldRenderer; + var vrsh = (IGetVoxyRenderSystem)Minecraft.getInstance().levelRenderer; if (vrsh != null) { if (v) { vrsh.createRenderer(); @@ -111,19 +110,19 @@ public abstract class VoxyConfigScreenPages { .setImpact(OptionImpact.HIGH) .build() ).add(OptionImpl.createBuilder(int.class, storage) - .setName(Text.translatable("voxy.config.general.subDivisionSize")) - .setTooltip(Text.translatable("voxy.config.general.subDivisionSize.tooltip")) - .setControl(opt->new SliderControl(opt, 0, SUBDIV_IN_MAX, 1, v->Text.literal(Integer.toString(Math.round(ln2subDiv(v)))))) + .setName(Component.translatable("voxy.config.general.subDivisionSize")) + .setTooltip(Component.translatable("voxy.config.general.subDivisionSize.tooltip")) + .setControl(opt->new SliderControl(opt, 0, SUBDIV_IN_MAX, 1, v->Component.literal(Integer.toString(Math.round(ln2subDiv(v)))))) .setBinding((s, v) -> s.subDivisionSize = ln2subDiv(v), s -> subDiv2ln(s.subDivisionSize)) .setImpact(OptionImpact.HIGH) .build() ).add(OptionImpl.createBuilder(int.class, storage) - .setName(Text.translatable("voxy.config.general.renderDistance")) - .setTooltip(Text.translatable("voxy.config.general.renderDistance.tooltip")) - .setControl(opt->new SliderControl(opt, 2, 64, 1, v->Text.literal(Integer.toString(v * 32))))//Every unit is equal to 32 vanilla chunks + .setName(Component.translatable("voxy.config.general.renderDistance")) + .setTooltip(Component.translatable("voxy.config.general.renderDistance.tooltip")) + .setControl(opt->new SliderControl(opt, 2, 64, 1, v->Component.literal(Integer.toString(v * 32))))//Every unit is equal to 32 vanilla chunks .setBinding((s, v)-> { s.sectionRenderDistance = v; - var vrsh = (IGetVoxyRenderSystem)MinecraftClient.getInstance().worldRenderer; + var vrsh = (IGetVoxyRenderSystem)Minecraft.getInstance().levelRenderer; if (vrsh != null) { var vrs = vrsh.getVoxyRenderSystem(); if (vrs != null) { @@ -134,29 +133,29 @@ public abstract class VoxyConfigScreenPages { .setImpact(OptionImpact.LOW) .build() ).add(OptionImpl.createBuilder(boolean.class, storage) - .setName(Text.translatable("voxy.config.general.environmental_fog")) - .setTooltip(Text.translatable("voxy.config.general.environmental_fog.tooltip")) + .setName(Component.translatable("voxy.config.general.environmental_fog")) + .setTooltip(Component.translatable("voxy.config.general.environmental_fog.tooltip")) .setControl(TickBoxControl::new) .setImpact(OptionImpact.VARIES) .setBinding((s, v)-> s.useEnvironmentalFog = v, s -> s.useEnvironmentalFog) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) .build() ).add(OptionImpl.createBuilder(boolean.class, storage) - .setName(Text.translatable("voxy.config.general.vanilla_fog")) - .setTooltip(Text.translatable("voxy.config.general.vanilla_fog.tooltip")) + .setName(Component.translatable("voxy.config.general.vanilla_fog")) + .setTooltip(Component.translatable("voxy.config.general.vanilla_fog.tooltip")) .setControl(TickBoxControl::new) .setBinding((s, v)-> s.renderVanillaFog = v, s -> s.renderVanillaFog) .build() ).add(OptionImpl.createBuilder(boolean.class, storage) - .setName(Text.translatable("voxy.config.general.render_statistics")) - .setTooltip(Text.translatable("voxy.config.general.render_statistics.tooltip")) + .setName(Component.translatable("voxy.config.general.render_statistics")) + .setTooltip(Component.translatable("voxy.config.general.render_statistics.tooltip")) .setControl(TickBoxControl::new) .setBinding((s, v)-> RenderStatistics.enabled = v, s -> RenderStatistics.enabled) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) .build() ).build() ); - return new OptionPage(Text.translatable("voxy.config.title"), ImmutableList.copyOf(groups)); + return new OptionPage(Component.translatable("voxy.config.title"), ImmutableList.copyOf(groups)); } private static final int SUBDIV_IN_MAX = 100; diff --git a/src/main/java/me/cortex/voxy/client/core/NormalRenderPipeline.java b/src/main/java/me/cortex/voxy/client/core/NormalRenderPipeline.java index fcad35f9..a586a18c 100644 --- a/src/main/java/me/cortex/voxy/client/core/NormalRenderPipeline.java +++ b/src/main/java/me/cortex/voxy/client/core/NormalRenderPipeline.java @@ -11,7 +11,7 @@ import me.cortex.voxy.client.core.rendering.hierachical.HierarchicalOcclusionTra import me.cortex.voxy.client.core.rendering.hierachical.NodeCleaner; import me.cortex.voxy.client.core.rendering.post.FullscreenBlit; import me.cortex.voxy.client.core.rendering.util.DepthFramebuffer; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.joml.Matrix4f; import org.lwjgl.system.MemoryStack; @@ -109,7 +109,7 @@ public class NormalRenderPipeline extends AbstractRenderPipeline { float start = viewport.fogParameters.environmentalStart(); float end = viewport.fogParameters.environmentalEnd(); float invEndFogDelta = 1f/(end-start); - float endDistance = MinecraftClient.getInstance().gameRenderer.getViewDistanceBlocks()*1.5f; + float endDistance = Minecraft.getInstance().gameRenderer.getRenderDistance()*1.5f; glUniform3f(4, endDistance, invEndFogDelta, Math.abs(start)*invEndFogDelta); glUniform3f(5, viewport.fogParameters.red(), viewport.fogParameters.green(), viewport.fogParameters.blue()); } diff --git a/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java b/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java index cd3617e1..f31bc2cf 100644 --- a/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java +++ b/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java @@ -33,7 +33,7 @@ import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.commonImpl.VoxyCommon; import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices; import net.caffeinemc.mods.sodium.client.util.FogParameters; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.joml.Matrix4f; import org.joml.Matrix4fc; import org.lwjgl.opengl.GL11; @@ -119,8 +119,8 @@ public class VoxyRenderSystem { this.viewportSelector = new ViewportSelector<>(sectionRenderer::createViewport); { - int minSec = MinecraftClient.getInstance().world.getBottomSectionCoord() >> 5; - int maxSec = (MinecraftClient.getInstance().world.getTopSectionCoord() - 1) >> 5; + int minSec = Minecraft.getInstance().level.getMinSectionY() >> 5; + int maxSec = (Minecraft.getInstance().level.getMaxSectionY() - 1) >> 5; //Do some very cheeky stuff for MiB if (VoxyCommon.IS_MINE_IN_ABYSS) {//TODO: make this somehow configurable @@ -341,12 +341,12 @@ public class VoxyRenderSystem { float INCREASE_PER_SECOND = 60; float DECREASE_PER_SECOND = 30; //Auto fps targeting - if (MinecraftClient.getInstance().getCurrentFps() < MIN_FPS) { - VoxyConfig.CONFIG.subDivisionSize = Math.min(VoxyConfig.CONFIG.subDivisionSize + INCREASE_PER_SECOND / Math.max(1f, MinecraftClient.getInstance().getCurrentFps()), 256); + if (Minecraft.getInstance().getFps() < MIN_FPS) { + VoxyConfig.CONFIG.subDivisionSize = Math.min(VoxyConfig.CONFIG.subDivisionSize + INCREASE_PER_SECOND / Math.max(1f, Minecraft.getInstance().getFps()), 256); } - if (MAX_FPS < MinecraftClient.getInstance().getCurrentFps() && canDecreaseSize) { - VoxyConfig.CONFIG.subDivisionSize = Math.max(VoxyConfig.CONFIG.subDivisionSize - DECREASE_PER_SECOND / Math.max(1f, MinecraftClient.getInstance().getCurrentFps()), 28); + if (MAX_FPS < Minecraft.getInstance().getFps() && canDecreaseSize) { + VoxyConfig.CONFIG.subDivisionSize = Math.max(VoxyConfig.CONFIG.subDivisionSize - DECREASE_PER_SECOND / Math.max(1f, Minecraft.getInstance().getFps()), 28); } } @@ -354,13 +354,13 @@ public class VoxyRenderSystem { //TODO: use the existing projection matrix use mulLocal by the inverse of the projection and then mulLocal our projection var projection = new Matrix4f(); - var client = MinecraftClient.getInstance(); + var client = Minecraft.getInstance(); var gameRenderer = client.gameRenderer;//tickCounter.getTickDelta(true); - float fov = gameRenderer.getFov(gameRenderer.getCamera(), client.getRenderTickCounter().getTickProgress(true), true); + float fov = gameRenderer.getFov(gameRenderer.getMainCamera(), client.getDeltaTracker().getGameTimeDeltaPartialTick(true), true); projection.setPerspective(fov * 0.01745329238474369f, - (float) client.getWindow().getFramebufferWidth() / (float)client.getWindow().getFramebufferHeight(), + (float) client.getWindow().getWidth() / (float)client.getWindow().getHeight(), near, far); return projection; } @@ -368,7 +368,7 @@ public class VoxyRenderSystem { //TODO: Make a reverse z buffer private static Matrix4f computeProjectionMat(Matrix4fc base) { return base.mulLocal( - makeProjectionMatrix(0.05f, MinecraftClient.getInstance().gameRenderer.getFarPlaneDistance()).invert(), + makeProjectionMatrix(0.05f, Minecraft.getInstance().gameRenderer.getDepthFar()).invert(), new Matrix4f() ).mulLocal(makeProjectionMatrix(16, 16*3000)); } diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java index 0400ad6b..d904ac58 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java @@ -4,10 +4,6 @@ package me.cortex.voxy.client.core.model; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.world.other.Mapper; -import net.minecraft.client.MinecraftClient; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.util.Identifier; - import java.util.List; import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.atomic.AtomicInteger; diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java b/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java index 23a0e85a..b96bb65d 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java @@ -13,29 +13,29 @@ import me.cortex.voxy.client.core.rendering.util.RawDownloadStream; import me.cortex.voxy.client.core.rendering.util.UploadStream; import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.util.MemoryBuffer; +import me.cortex.voxy.common.util.Pair; import me.cortex.voxy.common.world.other.Mapper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FluidBlock; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.render.BlockRenderLayer; -import net.minecraft.client.render.RenderLayers; -import net.minecraft.fluid.FluidState; -import net.minecraft.registry.Registries; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.util.Identifier; -import net.minecraft.util.Pair; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockRenderView; -import net.minecraft.world.LightType; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeKeys; -import net.minecraft.world.biome.ColorResolver; -import net.minecraft.world.chunk.light.LightingProvider; +import net.minecraft.client.Minecraft; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.chunk.ChunkSectionLayer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.ColorResolver; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.material.FluidState; import org.jetbrains.annotations.Nullable; import org.lwjgl.system.MemoryUtil; @@ -71,7 +71,7 @@ public class ModelFactory { } } - private final Biome DEFAULT_BIOME = MinecraftClient.getInstance().world.getRegistryManager().getOrThrow(RegistryKeys.BIOME).get(BiomeKeys.PLAINS); + private final Biome DEFAULT_BIOME = Minecraft.getInstance().level.registryAccess().lookupOrThrow(Registries.BIOME).getValue(Biomes.PLAINS); public final ModelTextureBakery bakery; @@ -188,10 +188,10 @@ public class ModelFactory { //Before we enqueue the baking of this blockstate, we must check if it has a fluid state associated with it // if it does, we must ensure that it is (effectivly) baked BEFORE we bake this blockstate - boolean isFluid = blockState.getBlock() instanceof FluidBlock; + boolean isFluid = blockState.getBlock() instanceof LiquidBlock; if ((!isFluid) && (!blockState.getFluidState().isEmpty())) { //Insert into the fluid LUT - var fluidState = blockState.getFluidState().getBlockState(); + var fluidState = blockState.getFluidState().createLegacyBlock(); int fluidStateId = this.mapper.getIdForBlockState(fluidState); @@ -247,8 +247,8 @@ public class ModelFactory { public void processAllThings() { var biomeEntry = this.biomeQueue.poll(); while (biomeEntry != null) { - var biomeRegistry = MinecraftClient.getInstance().world.getRegistryManager().getOrThrow(RegistryKeys.BIOME); - var res = this.addBiome0(biomeEntry.id, biomeRegistry.get(Identifier.of(biomeEntry.biome))); + var biomeRegistry = Minecraft.getInstance().level.registryAccess().lookupOrThrow(Registries.BIOME); + var res = this.addBiome0(biomeEntry.id, biomeRegistry.getValue(ResourceLocation.parse(biomeEntry.biome))); if (res != null) { this.uploadResults.add(res); } @@ -339,7 +339,7 @@ public class ModelFactory { //TODO: add thing for `blockState.hasEmissiveLighting()` and `blockState.getLuminance()` - boolean isFluid = blockState.getBlock() instanceof FluidBlock; + boolean isFluid = blockState.getBlock() instanceof LiquidBlock; int modelId = -1; @@ -347,7 +347,7 @@ public class ModelFactory { if ((!isFluid) && (!blockState.getFluidState().isEmpty())) { //Insert into the fluid LUT - var fluidState = blockState.getFluidState().getBlockState(); + var fluidState = blockState.getFluidState().createLegacyBlock(); int fluidStateId = this.mapper.getIdForBlockState(fluidState); @@ -385,19 +385,19 @@ public class ModelFactory { this.fluidStateLUT[modelId] = clientFluidStateId; } - BlockRenderLayer blockRenderLayer = null; - if (blockState.getBlock() instanceof FluidBlock) { - blockRenderLayer = RenderLayers.getFluidLayer(blockState.getFluidState()); + ChunkSectionLayer blockRenderLayer = null; + if (blockState.getBlock() instanceof LiquidBlock) { + blockRenderLayer = ItemBlockRenderTypes.getRenderLayer(blockState.getFluidState()); } else { if (blockState.getBlock() instanceof LeavesBlock) { - blockRenderLayer = BlockRenderLayer.SOLID; + blockRenderLayer = ChunkSectionLayer.SOLID; } else { - blockRenderLayer = RenderLayers.getBlockLayer(blockState); + blockRenderLayer = ItemBlockRenderTypes.getChunkRenderType(blockState); } } - int checkMode = blockRenderLayer==BlockRenderLayer.SOLID?TextureUtils.WRITE_CHECK_STENCIL:TextureUtils.WRITE_CHECK_ALPHA; + int checkMode = blockRenderLayer==ChunkSectionLayer.SOLID?TextureUtils.WRITE_CHECK_STENCIL:TextureUtils.WRITE_CHECK_ALPHA; var colourProvider = getColourProvider(blockState.getBlock()); @@ -441,7 +441,7 @@ public class ModelFactory { boolean allFalse = true; //Guestimation test for if the block culls itself for (var dir : Direction.values()) { - if (blockState.isSideInvisible(blockState, dir)) { + if (blockState.skipRendering(blockState, dir)) { allFalse = false; } else { allTrue = false; @@ -463,7 +463,7 @@ public class ModelFactory { //Each face gets 1 byte, with the top 2 bytes being for whatever long metadata = 0; metadata |= isBiomeColourDependent?1:0; - metadata |= blockRenderLayer == BlockRenderLayer.TRANSLUCENT?2:0; + metadata |= blockRenderLayer == ChunkSectionLayer.TRANSLUCENT?2:0; metadata |= needsDoubleSidedQuads?4:0; metadata |= ((!isFluid) && !blockState.getFluidState().isEmpty())?8:0;//Has a fluid state accosiacted with it and is not itself a fluid metadata |= isFluid?16:0;//Is a fluid @@ -499,7 +499,7 @@ public class ModelFactory { //TODO: add alot of config options for the following boolean occludesFace = true; - occludesFace &= blockRenderLayer != BlockRenderLayer.TRANSLUCENT;//If its translucent, it doesnt occlude + occludesFace &= blockRenderLayer != ChunkSectionLayer.TRANSLUCENT;//If its translucent, it doesnt occlude //TODO: make this an option, basicly if the face is really close, it occludes otherwise it doesnt occludesFace &= offset < 0.1;//If the face is rendered far away from the other face, then it doesnt occlude @@ -519,7 +519,7 @@ public class ModelFactory { metadata |= canBeOccluded?4:0; //Face uses its own lighting if its not flat against the adjacent block & isnt traslucent - metadata |= (offset > 0.01 || blockRenderLayer == BlockRenderLayer.TRANSLUCENT)?0b1000:0; + metadata |= (offset > 0.01 || blockRenderLayer == ChunkSectionLayer.TRANSLUCENT)?0b1000:0; @@ -542,11 +542,11 @@ public class ModelFactory { int area = (faceSize[1]-faceSize[0]+1) * (faceSize[3]-faceSize[2]+1); boolean needsAlphaDiscard = ((float)writeCount)/area<0.9;//If the amount of area covered by written pixels is less than a threashold, disable discard as its not needed - needsAlphaDiscard |= blockRenderLayer != BlockRenderLayer.SOLID; - needsAlphaDiscard &= blockRenderLayer != BlockRenderLayer.TRANSLUCENT;//Translucent doesnt have alpha discard + needsAlphaDiscard |= blockRenderLayer != ChunkSectionLayer.SOLID; + needsAlphaDiscard &= blockRenderLayer != ChunkSectionLayer.TRANSLUCENT;//Translucent doesnt have alpha discard faceModelData |= needsAlphaDiscard?1<<22:0; - faceModelData |= ((!faceCoversFullBlock)&&blockRenderLayer != BlockRenderLayer.TRANSLUCENT)?1<<23:0;//Alpha discard override, translucency doesnt have alpha discard + faceModelData |= ((!faceCoversFullBlock)&&blockRenderLayer != ChunkSectionLayer.TRANSLUCENT)?1<<23:0;//Alpha discard override, translucency doesnt have alpha discard //Bits 24,25 are tint metadata if (colourProvider!=null) {//We have a tint @@ -574,8 +574,8 @@ public class ModelFactory { int modelFlags = 0; modelFlags |= colourProvider != null?1:0; modelFlags |= isBiomeColourDependent?2:0;//Basicly whether to use the next int as a colour or as a base index/id into a colour buffer for biome dependent colours - modelFlags |= blockRenderLayer == BlockRenderLayer.TRANSLUCENT?4:0;//Is translucent - modelFlags |= blockRenderLayer == BlockRenderLayer.CUTOUT?0:8;//Dont use mipmaps (AND ALSO FKING SPECIFIES IF IT HAS AO, WHY??? GREAT QUESTION, TODO FIXE THIS) + modelFlags |= blockRenderLayer == ChunkSectionLayer.TRANSLUCENT?4:0;//Is translucent + modelFlags |= blockRenderLayer == ChunkSectionLayer.CUTOUT?0:8;//Dont use mipmaps (AND ALSO FKING SPECIFIES IF IT HAS AO, WHY??? GREAT QUESTION, TODO FIXE THIS) //modelFlags |= blockRenderLayer == RenderLayer.getSolid()?0:1;// should discard alpha MemoryUtil.memPutInt(uploadPtr, modelFlags); uploadPtr += 4; @@ -687,51 +687,51 @@ public class ModelFactory { int i = 0; long modelUpPtr = result.modelBiomeIndexPairs.address; for (var entry : this.modelsRequiringBiomeColours) { - var colourProvider = getColourProvider(entry.getRight().getBlock()); + var colourProvider = getColourProvider(entry.right().getBlock()); if (colourProvider == null) { throw new IllegalStateException(); } //Populate the list of biomes for the model state int biomeIndex = (i++) * this.biomes.size(); - MemoryUtil.memPutLong(modelUpPtr, Integer.toUnsignedLong(entry.getLeft())|(Integer.toUnsignedLong(biomeIndex)<<32));modelUpPtr+=8; + MemoryUtil.memPutLong(modelUpPtr, Integer.toUnsignedLong(entry.left())|(Integer.toUnsignedLong(biomeIndex)<<32));modelUpPtr+=8; long clrUploadPtr = result.biomeColourBuffer.address + biomeIndex * 4L; for (var biomeE : this.biomes) { if (biomeE == null) { continue;//If null, ignore } - MemoryUtil.memPutInt(clrUploadPtr, captureColourConstant(colourProvider, entry.getRight(), biomeE)|0xFF000000); clrUploadPtr += 4; + MemoryUtil.memPutInt(clrUploadPtr, captureColourConstant(colourProvider, entry.right(), biomeE)|0xFF000000); clrUploadPtr += 4; } } return result; } - private static BlockColorProvider getColourProvider(Block block) { - return MinecraftClient.getInstance().getBlockColors().providers.get(Registries.BLOCK.getRawId(block)); + private static BlockColor getColourProvider(Block block) { + return Minecraft.getInstance().getBlockColors().blockColors.byId(BuiltInRegistries.BLOCK.getId(block)); } //TODO: add a method to detect biome dependent colours (can do by detecting if getColor is ever called) // if it is, need to add it to a list and mark it as biome colour dependent or something then the shader // will either use the uint as an index or a direct colour multiplier - private static int captureColourConstant(BlockColorProvider colorProvider, BlockState state, Biome biome) { - return colorProvider.getColor(state, new BlockRenderView() { + private static int captureColourConstant(BlockColor colorProvider, BlockState state, Biome biome) { + return colorProvider.getColor(state, new BlockAndTintGetter() { @Override - public float getBrightness(Direction direction, boolean shaded) { + public float getShade(Direction direction, boolean shaded) { return 0; } @Override - public int getLightLevel(LightType type, BlockPos pos) { + public int getBrightness(LightLayer type, BlockPos pos) { return 0; } @Override - public LightingProvider getLightingProvider() { + public LevelLightEngine getLightEngine() { return null; } @Override - public int getColor(BlockPos pos, ColorResolver colorResolver) { + public int getBlockTint(BlockPos pos, ColorResolver colorResolver) { return colorResolver.getColor(biome, 0, 0); } @@ -757,32 +757,32 @@ public class ModelFactory { } @Override - public int getBottomY() { + public int getMinY() { return 0; } - }, BlockPos.ORIGIN, 0); + }, BlockPos.ZERO, 0); } - private static boolean isBiomeDependentColour(BlockColorProvider colorProvider, BlockState state) { + private static boolean isBiomeDependentColour(BlockColor colorProvider, BlockState state) { boolean[] biomeDependent = new boolean[1]; - colorProvider.getColor(state, new BlockRenderView() { + colorProvider.getColor(state, new BlockAndTintGetter() { @Override - public float getBrightness(Direction direction, boolean shaded) { + public float getShade(Direction direction, boolean shaded) { return 0; } @Override - public int getLightLevel(LightType type, BlockPos pos) { + public int getBrightness(LightLayer type, BlockPos pos) { return 0; } @Override - public LightingProvider getLightingProvider() { + public LevelLightEngine getLightEngine() { return null; } @Override - public int getColor(BlockPos pos, ColorResolver colorResolver) { + public int getBlockTint(BlockPos pos, ColorResolver colorResolver) { biomeDependent[0] = true; return 0; } @@ -809,17 +809,17 @@ public class ModelFactory { } @Override - public int getBottomY() { + public int getMinY() { return 0; } - }, BlockPos.ORIGIN, 0); + }, BlockPos.ZERO, 0); return biomeDependent[0]; } private static float[] computeModelDepth(ColourDepthTextureData[] textures, int checkMode) { float[] res = new float[6]; for (var dir : Direction.values()) { - var data = textures[dir.getIndex()]; + var data = textures[dir.get3DDataValue()]; float fd = TextureUtils.computeDepth(data, TextureUtils.DEPTH_MODE_AVG, checkMode);//Compute the min float depth, smaller means closer to the camera, range 0-1 //int depth = Math.round(fd * MODEL_TEXTURE_SIZE); //If fd is -1, it means that there was nothing rendered on that face and it should be discarded diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelStore.java b/src/main/java/me/cortex/voxy/client/core/model/ModelStore.java index 0d51f09e..9db7f23e 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelStore.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelStore.java @@ -2,9 +2,9 @@ package me.cortex.voxy.client.core.model; import me.cortex.voxy.client.core.gl.GlBuffer; import me.cortex.voxy.client.core.gl.GlTexture; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.util.Identifier; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.resources.ResourceLocation; import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11C.GL_NEAREST; @@ -31,8 +31,8 @@ public class ModelStore { //Limit the mips of the texture to match that of the terrain atlas - int mipLvl = ((SpriteAtlasTexture) MinecraftClient.getInstance().getTextureManager() - .getTexture(Identifier.of("minecraft", "textures/atlas/blocks.png"))) + int mipLvl = ((TextureAtlas) Minecraft.getInstance().getTextureManager() + .getTexture(ResourceLocation.fromNamespaceAndPath("minecraft", "textures/atlas/blocks.png"))) .mipLevel; glSamplerParameteri(this.blockSampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); diff --git a/src/main/java/me/cortex/voxy/client/core/model/TextureUtils.java b/src/main/java/me/cortex/voxy/client/core/model/TextureUtils.java index 35155f7e..64bcaabf 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/TextureUtils.java +++ b/src/main/java/me/cortex/voxy/client/core/model/TextureUtils.java @@ -1,7 +1,7 @@ package me.cortex.voxy.client.core.model; import net.caffeinemc.mods.sodium.client.util.color.ColorSRGB; -import net.minecraft.client.texture.MipmapHelper; +import net.minecraft.client.renderer.texture.MipmapGenerator; //Texturing utils to manipulate data from the model bakery public class TextureUtils { @@ -209,7 +209,7 @@ public class TextureUtils { public static int mipColours(int one, int two, int three, int four) { if (true) { - return MipmapHelper.blend(one, two, three, four, false); + return MipmapGenerator.alphaBlend(one, two, three, four, false); } else { return weightedAverageColor(weightedAverageColor(one, two), weightedAverageColor(three, four)); } diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/BakedBlockEntityModel.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/BakedBlockEntityModel.java index 95bd8458..7e9674d6 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/BakedBlockEntityModel.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/BakedBlockEntityModel.java @@ -1,32 +1,13 @@ package me.cortex.voxy.client.core.model.bakery; import me.cortex.voxy.common.Logger; -import net.minecraft.block.BlockEntityProvider; -import net.minecraft.block.BlockState; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.Minecraft; import net.minecraft.client.model.Model; -import net.minecraft.client.model.ModelPart; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.block.MovingBlockRenderState; -import net.minecraft.client.render.command.ModelCommandRenderer; -import net.minecraft.client.render.command.OrderedRenderCommandQueue; -import net.minecraft.client.render.command.OrderedRenderCommandQueueImpl; -import net.minecraft.client.render.command.RenderCommandQueue; -import net.minecraft.client.render.entity.state.EntityHitboxAndView; -import net.minecraft.client.render.entity.state.EntityRenderState; -import net.minecraft.client.render.item.ItemRenderState; -import net.minecraft.client.render.model.BakedQuad; -import net.minecraft.client.render.model.BlockStateModel; -import net.minecraft.client.render.state.CameraRenderState; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.item.ItemDisplayContext; -import net.minecraft.text.OrderedText; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.EntityBlock; +import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.joml.Quaternionf; @@ -37,7 +18,7 @@ import java.util.List; import java.util.Map; public class BakedBlockEntityModel { - private record LayerConsumer(RenderLayer layer, ReuseVertexConsumer consumer) {} + private record LayerConsumer(RenderType layer, ReuseVertexConsumer consumer) {} private final List layers; private BakedBlockEntityModel(List layers) { this.layers = layers; @@ -46,12 +27,12 @@ public class BakedBlockEntityModel { public void render(Matrix4f matrix, int texId) { for (var layer : this.layers) { if (layer.consumer.isEmpty()) continue; - if (layer.layer instanceof RenderLayer.MultiPhase mp) { - Identifier textureId = mp.phases.texture.getId().orElse(null); + if (layer.layer instanceof RenderType.CompositeRenderType mp) { + ResourceLocation textureId = mp.state.textureState.cutoutTexture().orElse(null); if (textureId == null) { Logger.error("ERROR: Empty texture id for layer: " + layer); } else { - texId = ((net.minecraft.client.texture.GlTexture)MinecraftClient.getInstance().getTextureManager().getTexture(textureId).getGlTexture()).getGlId(); + texId = ((com.mojang.blaze3d.opengl.GlTexture)Minecraft.getInstance().getTextureManager().getTexture(textureId).getTexture()).glId(); } } if (texId == 0) continue; @@ -64,15 +45,15 @@ public class BakedBlockEntityModel { this.layers.forEach(layer->layer.consumer.free()); } - private static int getMetaFromLayer(RenderLayer layer) { - boolean hasDiscard = layer == RenderLayer.getCutout() || - layer == RenderLayer.getCutoutMipped() || - layer == RenderLayer.getTripwire(); + private static int getMetaFromLayer(RenderType layer) { + boolean hasDiscard = layer == RenderType.cutout() || + layer == RenderType.cutoutMipped() || + layer == RenderType.tripwire(); - boolean isMipped = layer == RenderLayer.getCutoutMipped() || - layer == RenderLayer.getSolid() || - layer.isTranslucent() || - layer == RenderLayer.getTripwire(); + boolean isMipped = layer == RenderType.cutoutMipped() || + layer == RenderType.solid() || + layer.sortOnUpload() || + layer == RenderType.tripwire(); int meta = hasDiscard?1:0; meta |= isMipped?2:0; @@ -80,13 +61,13 @@ public class BakedBlockEntityModel { } public static BakedBlockEntityModel bake(BlockState state) { - Map map = new HashMap<>(); - var entity = ((BlockEntityProvider)state.getBlock()).createBlockEntity(BlockPos.ORIGIN, state); + Map map = new HashMap<>(); + var entity = ((EntityBlock)state.getBlock()).newBlockEntity(BlockPos.ZERO, state); if (entity == null) { return null; } - var renderer = MinecraftClient.getInstance().getBlockEntityRenderDispatcher().get(entity); - entity.setWorld(MinecraftClient.getInstance().world); + var renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(entity); + entity.setLevel(Minecraft.getInstance().level); if (renderer != null) { try { /* @@ -104,7 +85,7 @@ public class BakedBlockEntityModel { Logger.error("Unable to bake block entity: " + entity, e); } } - entity.markRemoved(); + entity.setRemoved(); if (map.isEmpty()) { return null; } diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/BudgetBufferRenderer.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/BudgetBufferRenderer.java index b27dc040..5615143a 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/BudgetBufferRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/BudgetBufferRenderer.java @@ -2,14 +2,13 @@ package me.cortex.voxy.client.core.model.bakery; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.textures.GpuTexture; +import com.mojang.blaze3d.vertex.MeshData; import com.mojang.blaze3d.vertex.VertexFormat; import me.cortex.voxy.client.core.gl.GlBuffer; import me.cortex.voxy.client.core.gl.GlVertexArray; import me.cortex.voxy.client.core.gl.shader.Shader; import me.cortex.voxy.client.core.gl.shader.ShaderType; import me.cortex.voxy.client.core.rendering.util.UploadStream; -import net.minecraft.client.gl.GlGpuBuffer; -import net.minecraft.client.render.BuiltBuffer; import org.joml.Matrix4f; import org.lwjgl.system.MemoryUtil; @@ -29,9 +28,9 @@ public class BudgetBufferRenderer { public static void init(){} private static final GlBuffer indexBuffer; static { - var i = RenderSystem.getSequentialBuffer(VertexFormat.DrawMode.QUADS); - int id = ((GlGpuBuffer) i.getIndexBuffer(4096*3*2)).id; - if (i.getIndexType() != VertexFormat.IndexType.SHORT) { + var i = RenderSystem.getSequentialBuffer(VertexFormat.Mode.QUADS); + int id = ((com.mojang.blaze3d.opengl.GlBuffer) i.getBuffer(4096*3*2)).handle; + if (i.type() != VertexFormat.IndexType.SHORT) { throw new IllegalStateException(); } indexBuffer = new GlBuffer(3*2*2*4096); @@ -47,18 +46,18 @@ public class BudgetBufferRenderer { private static GlBuffer immediateBuffer; private static int quadCount; - public static void drawFast(BuiltBuffer buffer, GpuTexture tex, Matrix4f matrix) { - if (buffer.getDrawParameters().mode() != VertexFormat.DrawMode.QUADS) { + public static void drawFast(MeshData buffer, GpuTexture tex, Matrix4f matrix) { + if (buffer.drawState().mode() != VertexFormat.Mode.QUADS) { throw new IllegalStateException("Fast only supports quads"); } - var buff = buffer.getBuffer(); + var buff = buffer.vertexBuffer(); int size = buff.remaining(); if (size%STRIDE != 0) throw new IllegalStateException(); size /= STRIDE; if (size%4 != 0) throw new IllegalStateException(); size /= 4; - setup(MemoryUtil.memAddress(buff), size, ((net.minecraft.client.texture.GlTexture)tex).getGlId()); + setup(MemoryUtil.memAddress(buff), size, ((com.mojang.blaze3d.opengl.GlTexture)tex).glId()); buffer.close(); render(matrix); diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java index dc2f6c2e..db7cf386 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java @@ -1,20 +1,23 @@ package me.cortex.voxy.client.core.model.bakery; -import net.minecraft.block.*; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.BlockRenderLayer; -import net.minecraft.client.render.RenderLayers; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.fluid.FluidState; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.LocalRandom; -import net.minecraft.world.BlockRenderView; -import net.minecraft.world.LightType; -import net.minecraft.world.biome.ColorResolver; -import net.minecraft.world.chunk.light.LightingProvider; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.chunk.ChunkSectionLayer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.ColorResolver; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.SingleThreadedRandomSource; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.material.FluidState; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.joml.Quaternionf; @@ -26,6 +29,8 @@ import static org.lwjgl.opengl.GL14C.glBlendFuncSeparate; import static org.lwjgl.opengl.GL30.*; import static org.lwjgl.opengl.GL45.glTextureBarrier; +import com.mojang.blaze3d.vertex.PoseStack; + public class ModelTextureBakery { //Note: the first bit of metadata is if alpha discard is enabled private static final Matrix4f[] VIEWS = new Matrix4f[6]; @@ -41,44 +46,44 @@ public class ModelTextureBakery { this.height = height; } - public static int getMetaFromLayer(BlockRenderLayer layer) { - boolean hasDiscard = layer == BlockRenderLayer.CUTOUT || - layer == BlockRenderLayer.CUTOUT_MIPPED || - layer == BlockRenderLayer.TRIPWIRE; + public static int getMetaFromLayer(ChunkSectionLayer layer) { + boolean hasDiscard = layer == ChunkSectionLayer.CUTOUT || + layer == ChunkSectionLayer.CUTOUT_MIPPED || + layer == ChunkSectionLayer.TRIPWIRE; - boolean isMipped = layer == BlockRenderLayer.CUTOUT_MIPPED || - layer == BlockRenderLayer.SOLID || - layer == BlockRenderLayer.TRANSLUCENT || - layer == BlockRenderLayer.TRIPWIRE; + boolean isMipped = layer == ChunkSectionLayer.CUTOUT_MIPPED || + layer == ChunkSectionLayer.SOLID || + layer == ChunkSectionLayer.TRANSLUCENT || + layer == ChunkSectionLayer.TRIPWIRE; int meta = hasDiscard?1:0; meta |= isMipped?2:0; return meta; } - private void bakeBlockModel(BlockState state, BlockRenderLayer layer) { - if (state.getRenderType() == BlockRenderType.INVISIBLE) { + private void bakeBlockModel(BlockState state, ChunkSectionLayer layer) { + if (state.getRenderShape() == RenderShape.INVISIBLE) { return;//Dont bake if invisible } - var model = MinecraftClient.getInstance() - .getBakedModelManager() - .getBlockModels() - .getModel(state); + var model = Minecraft.getInstance() + .getModelManager() + .getBlockModelShaper() + .getBlockModel(state); int meta = getMetaFromLayer(layer); - for (var part : model.getParts(new LocalRandom(42L))) { + for (var part : model.collectParts(new SingleThreadedRandomSource(42L))) { for (Direction direction : new Direction[]{Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, null}) { var quads = part.getQuads(direction); for (var quad : quads) { - this.vc.quad(quad, meta|(quad.hasTint()?4:0)); + this.vc.quad(quad, meta|(quad.isTinted()?4:0)); } } } } - private void bakeFluidState(BlockState state, BlockRenderLayer layer, int face) { + private void bakeFluidState(BlockState state, ChunkSectionLayer layer, int face) { { //TODO: somehow set the tint flag per quad or something? int metadata = getMetaFromLayer(layer); @@ -87,24 +92,24 @@ public class ModelTextureBakery { metadata |= 4;//Has tint this.vc.setDefaultMeta(metadata);//Set the meta while baking } - MinecraftClient.getInstance().getBlockRenderManager().renderFluid(BlockPos.ORIGIN, new BlockRenderView() { + Minecraft.getInstance().getBlockRenderer().renderLiquid(BlockPos.ZERO, new BlockAndTintGetter() { @Override - public float getBrightness(Direction direction, boolean shaded) { + public float getShade(Direction direction, boolean shaded) { return 0; } @Override - public LightingProvider getLightingProvider() { + public LevelLightEngine getLightEngine() { return null; } @Override - public int getLightLevel(LightType type, BlockPos pos) { + public int getBrightness(LightLayer type, BlockPos pos) { return 0; } @Override - public int getColor(BlockPos pos, ColorResolver colorResolver) { + public int getBlockTint(BlockPos pos, ColorResolver colorResolver) { return 0; } @@ -117,7 +122,7 @@ public class ModelTextureBakery { @Override public BlockState getBlockState(BlockPos pos) { if (shouldReturnAirForFluid(pos, face)) { - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } //Fixme: @@ -135,7 +140,7 @@ public class ModelTextureBakery { @Override public FluidState getFluidState(BlockPos pos) { if (shouldReturnAirForFluid(pos, face)) { - return Blocks.AIR.getDefaultState().getFluidState(); + return Blocks.AIR.defaultBlockState().getFluidState(); } return state.getFluidState(); @@ -147,7 +152,7 @@ public class ModelTextureBakery { } @Override - public int getBottomY() { + public int getMinY() { return 0; } }, this.vc, state, state.getFluidState()); @@ -155,7 +160,7 @@ public class ModelTextureBakery { } private static boolean shouldReturnAirForFluid(BlockPos pos, int face) { - var fv = Direction.byIndex(face).getVector(); + var fv = Direction.from3DDataValue(face).getUnitVec3i(); int dot = fv.getX()*pos.getX() + fv.getY()*pos.getY() + fv.getZ()*pos.getZ(); return dot >= 1; } @@ -169,15 +174,15 @@ public class ModelTextureBakery { public void renderToStream(BlockState state, int streamBuffer, int streamOffset) { this.capture.clear(); boolean isBlock = true; - BlockRenderLayer layer; - if (state.getBlock() instanceof FluidBlock) { - layer = RenderLayers.getFluidLayer(state.getFluidState()); + ChunkSectionLayer layer; + if (state.getBlock() instanceof LiquidBlock) { + layer = ItemBlockRenderTypes.getRenderLayer(state.getFluidState()); isBlock = false; } else { if (state.getBlock() instanceof LeavesBlock) { - layer = BlockRenderLayer.SOLID; + layer = ChunkSectionLayer.SOLID; } else { - layer = RenderLayers.getBlockLayer(state); + layer = ItemBlockRenderTypes.getChunkRenderType(state); } } @@ -195,7 +200,7 @@ public class ModelTextureBakery { glEnable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); - if (layer == BlockRenderLayer.TRANSLUCENT) { + if (layer == ChunkSectionLayer.TRANSLUCENT) { glEnable(GL_BLEND); glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); } else { @@ -212,8 +217,8 @@ public class ModelTextureBakery { //Bind the capture framebuffer glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id); - var tex = MinecraftClient.getInstance().getTextureManager().getTexture(Identifier.of("minecraft", "textures/atlas/blocks.png")).getGlTexture(); - blockTextureId = ((net.minecraft.client.texture.GlTexture)tex).getGlId(); + var tex = Minecraft.getInstance().getTextureManager().getTexture(ResourceLocation.fromNamespaceAndPath("minecraft", "textures/atlas/blocks.png")).getTexture(); + blockTextureId = ((com.mojang.blaze3d.opengl.GlTexture)tex).glId(); } //TODO: fastpath for blocks @@ -248,7 +253,7 @@ public class ModelTextureBakery { glBindVertexArray(0); } else {//Is fluid, slow path :( - if (!(state.getBlock() instanceof FluidBlock)) throw new IllegalStateException(); + if (!(state.getBlock() instanceof LiquidBlock)) throw new IllegalStateException(); var mat = new Matrix4f(); for (int i = 0; i < VIEWS.length; i++) { @@ -319,7 +324,7 @@ public class ModelTextureBakery { glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id); glClearDepth(1); glClear(GL_DEPTH_BUFFER_BIT); - if (layer == BlockRenderLayer.TRANSLUCENT) { + if (layer == ChunkSectionLayer.TRANSLUCENT) { //reset the blend func GL14.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); } @@ -341,14 +346,14 @@ public class ModelTextureBakery { } private static void addView(int i, float pitch, float yaw, float rotation, int flip) { - var stack = new MatrixStack(); + var stack = new PoseStack(); stack.translate(0.5f,0.5f,0.5f); - stack.multiply(makeQuatFromAxisExact(new Vector3f(0,0,1), rotation)); - stack.multiply(makeQuatFromAxisExact(new Vector3f(1,0,0), pitch)); - stack.multiply(makeQuatFromAxisExact(new Vector3f(0,1,0), yaw)); - stack.multiplyPositionMatrix(new Matrix4f().scale(1-2*(flip&1), 1-(flip&2), 1-((flip>>1)&2))); + stack.mulPose(makeQuatFromAxisExact(new Vector3f(0,0,1), rotation)); + stack.mulPose(makeQuatFromAxisExact(new Vector3f(1,0,0), pitch)); + stack.mulPose(makeQuatFromAxisExact(new Vector3f(0,1,0), yaw)); + stack.mulPose(new Matrix4f().scale(1-2*(flip&1), 1-(flip&2), 1-((flip>>1)&2))); stack.translate(-0.5f,-0.5f,-0.5f); - VIEWS[i] = new Matrix4f(stack.peek().getPositionMatrix()); + VIEWS[i] = new Matrix4f(stack.last().pose()); } private static Quaternionf makeQuatFromAxisExact(Vector3f vec, float angle) { diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/ReuseVertexConsumer.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/ReuseVertexConsumer.java index 192447f2..469aea39 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/ReuseVertexConsumer.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/ReuseVertexConsumer.java @@ -2,12 +2,13 @@ package me.cortex.voxy.client.core.model.bakery; import me.cortex.voxy.common.util.MemoryBuffer; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.render.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BakedQuad; import org.lwjgl.system.MemoryUtil; import static me.cortex.voxy.client.core.model.bakery.BudgetBufferRenderer.VERTEX_FORMAT_SIZE; +import com.mojang.blaze3d.vertex.VertexConsumer; + public final class ReuseVertexConsumer implements VertexConsumer { private MemoryBuffer buffer = new MemoryBuffer(8192); private long ptr; @@ -24,7 +25,7 @@ public final class ReuseVertexConsumer implements VertexConsumer { } @Override - public ReuseVertexConsumer vertex(float x, float y, float z) { + public ReuseVertexConsumer addVertex(float x, float y, float z) { this.ensureCanPut(); this.ptr += VERTEX_FORMAT_SIZE; this.count++; //Goto next vertex this.meta(this.defaultMeta); @@ -40,43 +41,43 @@ public final class ReuseVertexConsumer implements VertexConsumer { } @Override - public ReuseVertexConsumer color(int red, int green, int blue, int alpha) { + public ReuseVertexConsumer setColor(int red, int green, int blue, int alpha) { return this; } @Override - public ReuseVertexConsumer texture(float u, float v) { + public ReuseVertexConsumer setUv(float u, float v) { MemoryUtil.memPutFloat(this.ptr + 16, u); MemoryUtil.memPutFloat(this.ptr + 20, v); return this; } @Override - public ReuseVertexConsumer overlay(int u, int v) { + public ReuseVertexConsumer setUv1(int u, int v) { return this; } @Override - public ReuseVertexConsumer light(int u, int v) { + public ReuseVertexConsumer setUv2(int u, int v) { return this; } @Override - public ReuseVertexConsumer normal(float x, float y, float z) { + public ReuseVertexConsumer setNormal(float x, float y, float z) { return this; } public ReuseVertexConsumer quad(BakedQuad quad, int metadata) { this.ensureCanPut(); - int[] data = quad.vertexData(); + int[] data = quad.vertices(); for (int i = 0; i < 4; i++) { float x = Float.intBitsToFloat(data[i * 8]); float y = Float.intBitsToFloat(data[i * 8 + 1]); float z = Float.intBitsToFloat(data[i * 8 + 2]); - this.vertex(x,y,z); + this.addVertex(x,y,z); float u = Float.intBitsToFloat(data[i * 8 + 4]); float v = Float.intBitsToFloat(data[i * 8 + 5]); - this.texture(u,v); + this.setUv(u,v); this.meta(metadata); } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java index 6b420e5d..390dddf8 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java @@ -12,8 +12,7 @@ import me.cortex.voxy.client.core.gl.shader.ShaderType; import me.cortex.voxy.client.core.rendering.util.SharedIndexBuffer; import me.cortex.voxy.client.core.rendering.util.UploadStream; import me.cortex.voxy.common.Logger; -import net.minecraft.client.MinecraftClient; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.Minecraft; import org.joml.Matrix4f; import org.joml.Vector3f; import org.joml.Vector3i; @@ -91,7 +90,7 @@ public class ChunkBoundRenderer { long ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, 128); long matPtr = ptr; ptr += 4*4*4; - final float renderDistance = MinecraftClient.getInstance().options.getClampedViewDistance()*16;//In blocks + final float renderDistance = Minecraft.getInstance().options.getEffectiveRenderDistance()*16;//In blocks {//This is recomputed to be in chunk section space not worldsection int sx = (int)(viewport.cameraX); diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/Viewport.java b/src/main/java/me/cortex/voxy/client/core/rendering/Viewport.java index 35f1b4bf..53c95454 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/Viewport.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/Viewport.java @@ -4,7 +4,7 @@ import me.cortex.voxy.client.core.gl.GlBuffer; import me.cortex.voxy.client.core.rendering.util.DepthFramebuffer; import me.cortex.voxy.client.core.rendering.util.HiZBuffer; import net.caffeinemc.mods.sodium.client.util.FogParameters; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import org.joml.*; import java.lang.reflect.Field; @@ -101,9 +101,9 @@ public abstract class Viewport > { this.frustum.set(this.MVP, false); //Translation vectors - int sx = MathHelper.floor(this.cameraX)>>5; - int sy = MathHelper.floor(this.cameraY)>>5; - int sz = MathHelper.floor(this.cameraZ)>>5; + int sx = Mth.floor(this.cameraX)>>5; + int sy = Mth.floor(this.cameraY)>>5; + int sz = Mth.floor(this.cameraZ)>>5; this.section.set(sx, sy, sz); this.innerTranslation.set( diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/DebugRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/DebugRenderer.java index 73c2108c..6954b882 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/DebugRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/DebugRenderer.java @@ -7,7 +7,7 @@ import me.cortex.voxy.client.core.gl.shader.ShaderType; import me.cortex.voxy.client.core.rendering.Viewport; import me.cortex.voxy.client.core.rendering.util.SharedIndexBuffer; import me.cortex.voxy.client.core.rendering.util.UploadStream; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import org.joml.Matrix4f; import org.joml.Vector3f; import org.lwjgl.opengl.GL15; @@ -38,9 +38,9 @@ public class DebugRenderer { private void uploadUniform(Viewport viewport) { long ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, 1024); - int sx = MathHelper.floor(viewport.cameraX)>>5; - int sy = MathHelper.floor(viewport.cameraY)>>5; - int sz = MathHelper.floor(viewport.cameraZ)>>5; + int sx = Mth.floor(viewport.cameraX)>>5; + int sy = Mth.floor(viewport.cameraY)>>5; + int sz = Mth.floor(viewport.cameraZ)>>5; new Matrix4f(viewport.projection).mul(viewport.modelView).getToAddress(ptr); ptr += 4*4*4; diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICSectionRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICSectionRenderer.java index 0fceb342..f8226d2e 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICSectionRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICSectionRenderer.java @@ -17,7 +17,7 @@ import me.cortex.voxy.client.core.rendering.util.SharedIndexBuffer; import me.cortex.voxy.client.core.rendering.util.UploadStream; import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.world.WorldEngine; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.joml.Matrix4f; import org.lwjgl.system.MemoryUtil; @@ -104,7 +104,7 @@ public class MDICSectionRenderer extends AbstractSectionRenderer packet, Exception exception, CallbackInfo ci) { - if (packet instanceof GameJoinS2CPacket) { + if (packet instanceof ClientboundLoginPacket) { ci.cancel(); throw new LoadException("Force crashing due to exception during on game join", exception); } diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientLoginNetworkHandler.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientLoginNetworkHandler.java index 79a38319..58d803b4 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientLoginNetworkHandler.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientLoginNetworkHandler.java @@ -4,17 +4,17 @@ import me.cortex.voxy.client.VoxyClient; import me.cortex.voxy.client.VoxyClientInstance; import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.commonImpl.VoxyCommon; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.network.protocol.game.ClientboundLoginPacket; 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(ClientPlayNetworkHandler.class) +@Mixin(ClientPacketListener.class) public class MixinClientLoginNetworkHandler { - @Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;commonPlayerSpawnInfo()Lnet/minecraft/network/packet/s2c/play/CommonPlayerSpawnInfo;")) - private void voxy$init(GameJoinS2CPacket packet, CallbackInfo ci) { + @Inject(method = "handleLogin", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundLoginPacket;commonPlayerSpawnInfo()Lnet/minecraft/network/protocol/game/CommonPlayerSpawnInfo;")) + private void voxy$init(ClientboundLoginPacket packet, CallbackInfo ci) { if (VoxyCommon.isAvailable() && !VoxyClientInstance.isInGame) { VoxyClientInstance.isInGame = true; if (VoxyConfig.CONFIG.enabled) { diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientWorld.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientWorld.java index b3c446d3..86cb805d 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientWorld.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientWorld.java @@ -5,18 +5,18 @@ import me.cortex.voxy.client.core.IGetVoxyRenderSystem; import me.cortex.voxy.common.world.service.VoxelIngestService; import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.WorldIdentifier; -import net.minecraft.block.BlockState; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.client.world.ClientChunkManager; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkSectionPos; -import net.minecraft.world.LightType; -import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.client.multiplayer.ClientChunkCache; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.SectionPos; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.dimension.DimensionType; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -25,33 +25,33 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ClientWorld.class) +@Mixin(ClientLevel.class) public abstract class MixinClientWorld { @Unique private int bottomSectionY; - @Shadow @Final public WorldRenderer worldRenderer; + @Shadow @Final public LevelRenderer levelRenderer; - @Shadow public abstract ClientChunkManager getChunkManager(); + @Shadow public abstract ClientChunkCache getChunkSource(); @Inject(method = "", at = @At("TAIL")) private void voxy$getBottom( - ClientPlayNetworkHandler networkHandler, - ClientWorld.Properties properties, - RegistryKey registryRef, - RegistryEntry dimensionType, + ClientPacketListener networkHandler, + ClientLevel.ClientLevelData properties, + ResourceKey registryRef, + Holder dimensionType, int loadDistance, int simulationDistance, - WorldRenderer worldRenderer, + LevelRenderer worldRenderer, boolean debugWorld, long seed, int seaLevel, CallbackInfo cir) { - this.bottomSectionY = ((World)(Object)this).getBottomY()>>4; + this.bottomSectionY = ((Level)(Object)this).getMinY()>>4; } - @Inject(method = "scheduleBlockRerenderIfNeeded", at = @At("TAIL")) + @Inject(method = "setBlocksDirty", at = @At("TAIL")) private void voxy$injectIngestOnStateChange(BlockPos pos, BlockState old, BlockState updated, CallbackInfo cir) { if (old == updated) return; @@ -61,7 +61,7 @@ public abstract class MixinClientWorld { if (!VoxyConfig.CONFIG.ingestEnabled) return;//Only ingest if setting enabled - var self = (World)(Object)this; + var self = (Level)(Object)this; var wi = WorldIdentifier.of(self); if (wi == null) { return; @@ -71,15 +71,15 @@ public abstract class MixinClientWorld { int y = pos.getY()&15; int z = pos.getZ()&15; if (x == 0 || x==15 || y==0 || y==15 || z==0||z==15) {//Update if there is a statechange on the boarder - var csp = ChunkSectionPos.from(pos); + var csp = SectionPos.of(pos); - var section = self.getChunk(pos).getSection(csp.getSectionY()-this.bottomSectionY); - var lp = self.getLightingProvider(); + var section = self.getChunk(pos).getSection(csp.y()-this.bottomSectionY); + var lp = self.getLightEngine(); - var blp = lp.get(LightType.BLOCK).getLightSection(csp); - var slp = lp.get(LightType.SKY).getLightSection(csp); + var blp = lp.getLayerListener(LightLayer.BLOCK).getDataLayerData(csp); + var slp = lp.getLayerListener(LightLayer.SKY).getDataLayerData(csp); - VoxelIngestService.rawIngest(wi, section, csp.getSectionX(), csp.getSectionY(), csp.getSectionZ(), blp==null?null:blp.copy(), slp==null?null:slp.copy()); + VoxelIngestService.rawIngest(wi, section, csp.x(), csp.y(), csp.z(), blp==null?null:blp.copy(), slp==null?null:slp.copy()); } } } diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinFogRenderer.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinFogRenderer.java index 711daedc..3b0458af 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinFogRenderer.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinFogRenderer.java @@ -2,9 +2,9 @@ package me.cortex.voxy.client.mixin.minecraft; import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.client.core.IGetVoxyRenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.fog.FogData; -import net.minecraft.client.render.fog.FogRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.fog.FogData; +import net.minecraft.client.renderer.fog.FogRenderer; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -12,9 +12,9 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(FogRenderer.class) public class MixinFogRenderer { - @Redirect(method = "applyFog(Lnet/minecraft/client/render/Camera;IZLnet/minecraft/client/render/RenderTickCounter;FLnet/minecraft/client/world/ClientWorld;)Lorg/joml/Vector4f;", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/fog/FogData;renderDistanceEnd:F", opcode = Opcodes.PUTFIELD), require = 0) + @Redirect(method = "setupFog", at = @At(value = "FIELD", target ="Lnet/minecraft/client/renderer/fog/FogData;renderDistanceEnd:F", opcode = Opcodes.PUTFIELD), require = 0) private void voxy$modifyFog(FogData instance, float distance) { - var vrs = (IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer; + var vrs = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer; if (VoxyConfig.CONFIG.renderVanillaFog || vrs == null || vrs.getVoxyRenderSystem() == null) { instance.renderDistanceEnd = distance; diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinGlDebug.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinGlDebug.java index 45526b6d..ecaead6c 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinGlDebug.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinGlDebug.java @@ -2,7 +2,7 @@ package me.cortex.voxy.client.mixin.minecraft; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import net.minecraft.client.gl.GlDebug; +import com.mojang.blaze3d.opengl.GlDebug; import org.slf4j.Logger; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -13,9 +13,9 @@ import java.io.StringWriter; @Mixin(GlDebug.class) public class MixinGlDebug { - @WrapOperation(method = "onDebugMessage", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) + @WrapOperation(method = "printDebugLog", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) private void voxy$wrapDebug(Logger instance, String base, Object msgObj, Operation original) { - if (msgObj instanceof GlDebug.DebugMessage msg) { + if (msgObj instanceof GlDebug.LogEntry msg) { var throwable = new Throwable(msg.toString()); if (isCausedByVoxy(throwable.getStackTrace())) { original.call(instance, base+"\n"+getStackTraceAsString(throwable), throwable); diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinMinecraftClient.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinMinecraftClient.java index 16317f71..508c2935 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinMinecraftClient.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinMinecraftClient.java @@ -2,15 +2,15 @@ package me.cortex.voxy.client.mixin.minecraft; import me.cortex.voxy.client.VoxyClientInstance; import me.cortex.voxy.commonImpl.VoxyCommon; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; 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(MinecraftClient.class) +@Mixin(Minecraft.class) public class MixinMinecraftClient { - @Inject(method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;Z)V", at = @At("TAIL")) + @Inject(method = "disconnect", at = @At("TAIL")) private void voxy$injectWorldClose(CallbackInfo ci) { if (VoxyCommon.isAvailable() && VoxyClientInstance.isInGame) { VoxyCommon.shutdownInstance(); diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinRenderSystem.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinRenderSystem.java index 5daaa11f..8618a9a4 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinRenderSystem.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinRenderSystem.java @@ -4,7 +4,7 @@ package me.cortex.voxy.client.mixin.minecraft; import com.mojang.blaze3d.shaders.ShaderType; import com.mojang.blaze3d.systems.RenderSystem; import me.cortex.voxy.client.VoxyClient; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -17,7 +17,7 @@ import java.util.function.BiFunction; public class MixinRenderSystem { //We need to inject before iris to initalize our systems @Inject(method = "initRenderer", order = 900, remap = false, at = @At("RETURN")) - private static void voxy$injectInit(long windowHandle, int debugVerbosity, boolean sync, BiFunction shaderSourceGetter, boolean renderDebugLabels, CallbackInfo ci) { + private static void voxy$injectInit(long windowHandle, int debugVerbosity, boolean sync, BiFunction shaderSourceGetter, boolean renderDebugLabels, CallbackInfo ci) { VoxyClient.initVoxyClient(); } } diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinThreadExecutor.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinThreadExecutor.java index 0e920f2a..3ff53224 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinThreadExecutor.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinThreadExecutor.java @@ -1,17 +1,18 @@ package me.cortex.voxy.client.mixin.minecraft; import me.cortex.voxy.client.LoadException; -import net.minecraft.util.thread.ThreadExecutor; +import net.minecraft.util.thread.BlockableEventLoop; 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(ThreadExecutor.class) +@Mixin(BlockableEventLoop.class) public abstract class MixinThreadExecutor { - @Shadow public static boolean isMemoryError(Throwable exception){return false;}; - @Redirect(method = "executeTask", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/thread/ThreadExecutor;isMemoryError(Ljava/lang/Throwable;)Z")) + @Shadow public static boolean isNonRecoverable(Throwable throwable){return false;} + + @Redirect(method = "doRunTask", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/thread/BlockableEventLoop;isNonRecoverable(Ljava/lang/Throwable;)Z")) private boolean voxy$forceCrashOnError(Throwable exception) { if (exception instanceof LoadException le) { if (le.getCause() instanceof RuntimeException cause) { @@ -19,6 +20,6 @@ public abstract class MixinThreadExecutor { } throw le; } - return isMemoryError(exception); + return isNonRecoverable(exception); } } diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWindow.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWindow.java index ec898e26..1d92a6e3 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWindow.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWindow.java @@ -1,11 +1,11 @@ package me.cortex.voxy.client.mixin.minecraft; +import com.mojang.blaze3d.platform.DisplayData; +import com.mojang.blaze3d.platform.ScreenManager; +import com.mojang.blaze3d.platform.Window; +import com.mojang.blaze3d.platform.WindowEventHandler; import me.cortex.voxy.client.GPUSelectorWindows2; import me.cortex.voxy.common.util.ThreadUtils; -import net.minecraft.client.WindowEventHandler; -import net.minecraft.client.WindowSettings; -import net.minecraft.client.util.MonitorTracker; -import net.minecraft.client.util.Window; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -13,8 +13,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Window.class) public class MixinWindow { - @Inject(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;throwOnGlError()V")) - private void injectInitWindow(WindowEventHandler eventHandler, MonitorTracker monitorTracker, WindowSettings settings, String fullscreenVideoMode, String title, CallbackInfo ci) { + @Inject(method = "", at = @At(value = "INVOKE", target = "setBootErrorCallback")) + private void injectInitWindow(WindowEventHandler eventHandler, ScreenManager monitorTracker, DisplayData settings, String fullscreenVideoMode, String title, CallbackInfo ci) { //System.load("C:\\Program Files\\RenderDoc\\renderdoc.dll"); var prop = System.getProperty("voxy.forceGpuSelectionIndex", "NO"); if (!prop.equals("NO")) { diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java index 194f38e7..20e36e1c 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java @@ -9,9 +9,8 @@ import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.WorldIdentifier; -import net.minecraft.client.render.Frustum; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.LevelRenderer; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -20,9 +19,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(WorldRenderer.class) +@Mixin(LevelRenderer.class) public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem { - @Shadow private @Nullable ClientWorld world; + @Shadow private @Nullable ClientLevel level; @Unique private VoxyRenderSystem renderer; @Override @@ -30,17 +29,17 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem { return this.renderer; } - @Inject(method = "reload()V", at = @At("RETURN"), order = 900)//We want to inject before sodium + @Inject(method = "allChanged()V", at = @At("RETURN"), order = 900)//We want to inject before sodium private void reloadVoxyRenderer(CallbackInfo ci) { this.shutdownRenderer(); - if (this.world != null) { + if (this.level != null) { this.createRenderer(); } } - @Inject(method = "setWorld", at = @At("HEAD")) - private void voxy$captureSetWorld(ClientWorld world, CallbackInfo ci) { - if (this.world != world) { + @Inject(method = "setLevel", at = @At("HEAD")) + private void voxy$captureSetWorld(ClientLevel world, CallbackInfo ci) { + if (this.level != world) { this.shutdownRenderer(); } } @@ -65,7 +64,7 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem { Logger.info("Not creating renderer due to disabled"); return; } - if (this.world == null) { + if (this.level == null) { Logger.error("Not creating renderer due to null world"); return; } @@ -74,7 +73,7 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem { Logger.error("Not creating renderer due to null instance"); return; } - WorldEngine world = WorldIdentifier.ofEngine(this.world); + WorldEngine world = WorldIdentifier.ofEngine(this.level); if (world == null) { Logger.error("Null world selected"); return; diff --git a/src/main/java/me/cortex/voxy/client/mixin/nvidium/MixinRenderPipeline.java b/src/main/java/me/cortex/voxy/client/mixin/nvidium/MixinRenderPipeline.java index 50651885..1d2de3f7 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/nvidium/MixinRenderPipeline.java +++ b/src/main/java/me/cortex/voxy/client/mixin/nvidium/MixinRenderPipeline.java @@ -6,7 +6,7 @@ import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices; import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; import net.caffeinemc.mods.sodium.client.render.viewport.Viewport; import net.caffeinemc.mods.sodium.client.util.FogParameters; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinRenderPipeline { @Inject(method = "renderFrame", at = @At("RETURN")) private void voxy$injectRender(TerrainRenderPass pass, Viewport frustum, FogParameters fogParameters, ChunkRenderMatrices crm, double px, double py, double pz, CallbackInfo ci) { - var renderer = ((IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer).getVoxyRenderSystem(); + var renderer = ((IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer).getVoxyRenderSystem(); if (renderer != null) { renderer.renderOpaque(renderer.setupViewport(crm, fogParameters, px, py, pz)); } diff --git a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinDefaultChunkRenderer.java b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinDefaultChunkRenderer.java index cd285385..1f54da16 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinDefaultChunkRenderer.java +++ b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinDefaultChunkRenderer.java @@ -16,7 +16,7 @@ import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType; import net.caffeinemc.mods.sodium.client.render.viewport.CameraTransform; import net.caffeinemc.mods.sodium.client.util.FogParameters; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -48,7 +48,7 @@ public abstract class MixinDefaultChunkRenderer extends ShaderChunkRenderer { @Unique private void doRender(ChunkRenderMatrices matrices, TerrainRenderPass renderPass, CameraTransform camera, FogParameters fogParameters) { if (renderPass == DefaultTerrainRenderPasses.CUTOUT) { - var renderer = ((IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer).getVoxyRenderSystem(); + var renderer = ((IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer).getVoxyRenderSystem(); if (renderer != null) { Viewport viewport = null; if (IrisUtil.irisShaderPackEnabled()) { diff --git a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinRenderSectionManager.java b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinRenderSectionManager.java index 4a7f82d5..358963c2 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinRenderSectionManager.java +++ b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinRenderSectionManager.java @@ -15,11 +15,11 @@ import net.caffeinemc.mods.sodium.client.render.chunk.data.BuiltSectionInfo; import net.caffeinemc.mods.sodium.client.render.chunk.map.ChunkTrackerHolder; import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.SortBehavior; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.ChunkSectionPos; -import net.minecraft.world.LightType; -import net.minecraft.world.chunk.ChunkStatus; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.chunk.status.ChunkStatus; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -34,19 +34,19 @@ public class MixinRenderSectionManager { @Unique private static final boolean BOBBY_INSTALLED = FabricLoader.getInstance().isModLoaded("bobby"); - @Shadow @Final private ClientWorld level; + @Shadow @Final private ClientLevel level; @Shadow @Final private ChunkBuilder builder; @Inject(method = "", at = @At("TAIL")) - private void voxy$resetChunkTracker(ClientWorld level, int renderDistance, SortBehavior sortBehavior, CommandList commandList, CallbackInfo ci) { - if (level.worldRenderer != null) { - var system = ((IGetVoxyRenderSystem)(level.worldRenderer)).getVoxyRenderSystem(); + private void voxy$resetChunkTracker(ClientLevel level, int renderDistance, SortBehavior sortBehavior, CommandList commandList, CallbackInfo ci) { + if (level.levelRenderer != null) { + var system = ((IGetVoxyRenderSystem)(level.levelRenderer)).getVoxyRenderSystem(); if (system != null) { system.chunkBoundRenderer.reset(); } } - this.bottomSectionY = this.level.getBottomY()>>4; + this.bottomSectionY = this.level.getMinY()>>4; { //TODO: put in a better position @@ -61,7 +61,7 @@ public class MixinRenderSectionManager { private void injectIngest(int x, int z, CallbackInfo ci) { //TODO: Am not quite sure if this is right if (VoxyConfig.CONFIG.ingestEnabled && !BOBBY_INSTALLED) { - var cccm = (ICheekyClientChunkManager)this.level.getChunkManager(); + var cccm = (ICheekyClientChunkManager)this.level.getChunkSource(); if (cccm != null) { var chunk = cccm.voxy$cheekyGetChunk(x, z); if (chunk != null) { @@ -74,8 +74,8 @@ public class MixinRenderSectionManager { @Inject(method = "onChunkAdded", at = @At("HEAD")) private void voxy$ingestOnAdd(int x, int z, CallbackInfo ci) { - if (this.level.worldRenderer != null && VoxyConfig.CONFIG.ingestEnabled) { - var cccm = this.level.getChunkManager(); + if (this.level.levelRenderer != null && VoxyConfig.CONFIG.ingestEnabled) { + var cccm = this.level.getChunkSource(); if (cccm != null) { var chunk = cccm.getChunk(x, z, ChunkStatus.FULL, false); if (chunk != null) { @@ -115,7 +115,7 @@ public class MixinRenderSectionManager { if (flags == 0)//Only process things with stuff return true; - VoxyRenderSystem system = ((IGetVoxyRenderSystem)(this.level.worldRenderer)).getVoxyRenderSystem(); + VoxyRenderSystem system = ((IGetVoxyRenderSystem)(this.level.levelRenderer)).getVoxyRenderSystem(); if (system == null) { return true; } @@ -125,18 +125,18 @@ public class MixinRenderSectionManager { var tracker = ((AccessorChunkTracker)ChunkTrackerHolder.get(this.level)).getChunkStatus(); //in theory the cache value could be wrong but is so soso unlikely and at worst means we either duplicate ingest a chunk // which... could be bad ;-; or we dont ingest atall which is ok! - long key = ChunkPos.toLong(x, z); + long key = ChunkPos.asLong(x, z); if (key != this.cachedChunkPos) { this.cachedChunkPos = key; this.cachedChunkStatus = tracker.getOrDefault(key, 0); } if (this.cachedChunkStatus == 3) {//If this chunk still has surrounding chunks var section = this.level.getChunk(x,z).getSection(y-this.bottomSectionY); - var lp = this.level.getLightingProvider(); + var lp = this.level.getLightEngine(); - var csp = ChunkSectionPos.from(x,y,z); - var blp = lp.get(LightType.BLOCK).getLightSection(csp); - var slp = lp.get(LightType.SKY).getLightSection(csp); + var csp = SectionPos.of(x,y,z); + var blp = lp.getLayerListener(LightLayer.BLOCK).getDataLayerData(csp); + var slp = lp.getLayerListener(LightLayer.SKY).getDataLayerData(csp); //Note: we dont do this check and just blindly ingest, it shouldbe ok :tm: //if (blp != null || slp != null) @@ -150,7 +150,7 @@ public class MixinRenderSectionManager { x-=sector<<10; y+=16+(256-32-sector*30); } - long pos = ChunkSectionPos.asLong(x,y,z); + long pos = SectionPos.asLong(x,y,z); if (wasBuilt) {//Remove //TODO: on chunk remove do ingest if is surrounded by built chunks (or when the tracker says is ok) diff --git a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinSodiumOptionsGUI.java b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinSodiumOptionsGUI.java index 5a028549..d9070984 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinSodiumOptionsGUI.java +++ b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinSodiumOptionsGUI.java @@ -4,7 +4,7 @@ import me.cortex.voxy.client.config.VoxyConfigScreenPages; import me.cortex.voxy.commonImpl.VoxyCommon; import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI; import net.caffeinemc.mods.sodium.client.gui.options.OptionPage; -import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screens.Screen; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/src/main/java/me/cortex/voxy/client/taskbar/Taskbar.java b/src/main/java/me/cortex/voxy/client/taskbar/Taskbar.java index a3ffae55..9902eb6a 100644 --- a/src/main/java/me/cortex/voxy/client/taskbar/Taskbar.java +++ b/src/main/java/me/cortex/voxy/client/taskbar/Taskbar.java @@ -1,7 +1,7 @@ package me.cortex.voxy.client.taskbar; import me.cortex.voxy.common.Logger; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.apache.commons.lang3.SystemUtils; public abstract class Taskbar { @@ -37,7 +37,7 @@ public abstract class Taskbar { private static ITaskbar createInterface() { if (SystemUtils.IS_OS_WINDOWS) { try { - return new WindowsTaskbar(MinecraftClient.getInstance().getWindow().getHandle()); + return new WindowsTaskbar(Minecraft.getInstance().getWindow().handle()); } catch (Exception e) { Logger.error("Unable to create windows taskbar interface", e); return new NoopTaskbar(); diff --git a/src/main/java/me/cortex/voxy/common/Logger.java b/src/main/java/me/cortex/voxy/common/Logger.java index b15c3ff1..3b190f46 100644 --- a/src/main/java/me/cortex/voxy/common/Logger.java +++ b/src/main/java/me/cortex/voxy/common/Logger.java @@ -1,8 +1,8 @@ package me.cortex.voxy.common; import me.cortex.voxy.commonImpl.VoxyCommon; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; import org.slf4j.LoggerFactory; import java.util.Arrays; @@ -53,11 +53,11 @@ public class Logger { String error = (INSERT_CLASS?("["+callClsName()+"]: "):"") + Stream.of(args).map(Logger::objToString).collect(Collectors.joining(" ")); LOGGER.error(error, throwable); if (VoxyCommon.IS_IN_MINECRAFT && !VoxyCommon.IS_DEDICATED_SERVER) { - var instance = MinecraftClient.getInstance(); + var instance = Minecraft.getInstance(); if (instance != null) { - instance.executeSync(() -> { - var player = MinecraftClient.getInstance().player; - if (player != null) player.sendMessage(Text.literal(error), true); + instance.executeIfPossible(() -> { + var player = Minecraft.getInstance().player; + if (player != null) player.displayClientMessage(Component.literal(error), true); }); } } diff --git a/src/main/java/me/cortex/voxy/common/config/storage/inmemory/MemoryStorageBackend.java b/src/main/java/me/cortex/voxy/common/config/storage/inmemory/MemoryStorageBackend.java index 44846de8..c9b20ae3 100644 --- a/src/main/java/me/cortex/voxy/common/config/storage/inmemory/MemoryStorageBackend.java +++ b/src/main/java/me/cortex/voxy/common/config/storage/inmemory/MemoryStorageBackend.java @@ -9,7 +9,7 @@ import me.cortex.voxy.common.config.ConfigBuildCtx; import me.cortex.voxy.common.config.storage.StorageBackend; import me.cortex.voxy.common.config.storage.StorageConfig; import me.cortex.voxy.common.util.MemoryBuffer; -import net.minecraft.util.math.random.RandomSeed; +import net.minecraft.world.level.levelgen.RandomSupport; import org.apache.commons.lang3.stream.Streams; import org.lwjgl.system.MemoryUtil; @@ -26,7 +26,7 @@ public class MemoryStorageBackend extends StorageBackend { } private Long2ObjectMap getMap(long key) { - return this.maps[(int) (RandomSeed.mixStafford13(RandomSeed.mixStafford13(key)^key)&(this.maps.length-1))]; + return this.maps[(int) (RandomSupport.mixStafford13(RandomSupport.mixStafford13(key)^key)&(this.maps.length-1))]; } @Override diff --git a/src/main/java/me/cortex/voxy/common/config/storage/other/FragmentedStorageBackendAdaptor.java b/src/main/java/me/cortex/voxy/common/config/storage/other/FragmentedStorageBackendAdaptor.java index 98be4d3f..1d33b439 100644 --- a/src/main/java/me/cortex/voxy/common/config/storage/other/FragmentedStorageBackendAdaptor.java +++ b/src/main/java/me/cortex/voxy/common/config/storage/other/FragmentedStorageBackendAdaptor.java @@ -8,8 +8,7 @@ import me.cortex.voxy.common.config.ConfigBuildCtx; import me.cortex.voxy.common.config.storage.StorageBackend; import me.cortex.voxy.common.config.storage.StorageConfig; import me.cortex.voxy.common.util.MemoryBuffer; -import net.minecraft.util.math.random.RandomSeed; - +import net.minecraft.world.level.levelgen.RandomSupport; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; @@ -30,7 +29,7 @@ public class FragmentedStorageBackendAdaptor extends StorageBackend { } private int getSegmentId(long key) { - return (int) (RandomSeed.mixStafford13(RandomSeed.mixStafford13(key)^key)&(this.backends.length-1)); + return (int) (RandomSupport.mixStafford13(RandomSupport.mixStafford13(key)^key)&(this.backends.length-1)); } @Override diff --git a/src/main/java/me/cortex/voxy/common/voxelization/WorldConversionFactory.java b/src/main/java/me/cortex/voxy/common/voxelization/WorldConversionFactory.java index e75c2be4..39efb1a4 100644 --- a/src/main/java/me/cortex/voxy/common/voxelization/WorldConversionFactory.java +++ b/src/main/java/me/cortex/voxy/common/voxelization/WorldConversionFactory.java @@ -5,13 +5,18 @@ import me.cortex.voxy.common.world.other.Mapper; import me.cortex.voxy.common.world.other.Mipper; import net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.block.BlockState; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.collection.EmptyPaletteStorage; -import net.minecraft.util.collection.PackedIntegerArray; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.*; - +import net.minecraft.core.Holder; +import net.minecraft.util.SimpleBitStorage; +import net.minecraft.util.ZeroBitStorage; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.GlobalPalette; +import net.minecraft.world.level.chunk.HashMapPalette; +import net.minecraft.world.level.chunk.LinearPalette; +import net.minecraft.world.level.chunk.Palette; +import net.minecraft.world.level.chunk.PalettedContainer; +import net.minecraft.world.level.chunk.PalettedContainerRO; +import net.minecraft.world.level.chunk.SingleValuePalette; import java.util.WeakHashMap; public class WorldConversionFactory { @@ -40,7 +45,7 @@ public class WorldConversionFactory { for (int i = 0; i < vp.getSize(); i++) { BlockState state = null; int blockId = -1; - try { state = vp.get(i); } catch (Exception e) {} + try { state = vp.valueFor(i); } catch (Exception e) {} if (state != null) { blockId = blockCache.getOrDefault(state, -1); if (blockId == -1) { @@ -55,9 +60,9 @@ public class WorldConversionFactory { return false; } private static void setupLocalPalette(Palette vp, Reference2IntOpenHashMap blockCache, Mapper mapper, int[] pc) { - if (vp instanceof ArrayPalette) { + if (vp instanceof LinearPalette) { for (int i = 0; i < vp.getSize(); i++) { - var state = vp.get(i); + var state = vp.valueFor(i); int blockId = -1; if (state != null) { blockId = blockCache.getOrDefault(state, -1); @@ -68,14 +73,14 @@ public class WorldConversionFactory { } pc[i] = blockId; } - } else if (vp instanceof BiMapPalette pal) { + } else if (vp instanceof HashMapPalette pal) { //var map = pal.map; //TODO: heavily optimize this by reading the map directly for (int i = 0; i < vp.getSize(); i++) { BlockState state = null; int blockId = -1; - try { state = vp.get(i); } catch (Exception e) {} + try { state = vp.valueFor(i); } catch (Exception e) {} if (state != null) { blockId = blockCache.getOrDefault(state, -1); if (blockId == -1) { @@ -86,9 +91,9 @@ public class WorldConversionFactory { pc[i] = blockId; } - } else if (vp instanceof SingularPalette) { + } else if (vp instanceof SingleValuePalette) { int blockId = -1; - var state = vp.get(0); + var state = vp.valueFor(0); if (state != null) { blockId = blockCache.getOrDefault(state, -1); if (blockId == -1) { @@ -107,7 +112,7 @@ public class WorldConversionFactory { public static VoxelizedSection convert(VoxelizedSection section, Mapper stateMapper, PalettedContainer blockContainer, - ReadableContainer> biomeContainer, + PalettedContainerRO> biomeContainer, ILightingSupplier lightSupplier) { //Cheat by creating a local pallet then read the data directly @@ -121,9 +126,9 @@ public class WorldConversionFactory { var vp = blockContainer.data.palette; var pc = cache.getPaletteCache(vp.getSize()); - IdListPalette bps = null; + GlobalPalette bps = null; - if (blockContainer.data.palette instanceof IdListPalette _bps) { + if (blockContainer.data.palette instanceof GlobalPalette _bps) { bps = _bps; } else { setupLocalPalette(vp, blockCache, stateMapper, pc); @@ -142,12 +147,12 @@ public class WorldConversionFactory { int nonZeroCnt = 0; - if (blockContainer.data.storage instanceof PackedIntegerArray bStor) { - var bDat = bStor.getData(); - int iterPerLong = (64 / bStor.getElementBits()) - 1; + if (blockContainer.data.storage instanceof SimpleBitStorage bStor) { + var bDat = bStor.getRaw(); + int iterPerLong = (64 / bStor.getBits()) - 1; - int MSK = (1 << bStor.getElementBits()) - 1; - int eBits = bStor.getElementBits(); + int MSK = (1 << bStor.getBits()) - 1; + int eBits = bStor.getBits(); long sample = 0; int c = 0; @@ -161,7 +166,7 @@ public class WorldConversionFactory { if (bps == null) { bId = pc[(int) (sample & MSK)]; } else { - bId = stateMapper.getIdForBlockState(bps.get((int) (sample&MSK))); + bId = stateMapper.getIdForBlockState(bps.valueFor((int) (sample&MSK))); } sample >>>= eBits; @@ -170,7 +175,7 @@ public class WorldConversionFactory { data[i] = Mapper.composeMappingId(light, bId, biomes[Integer.compress(i,0b1100_1100_1100)]); } } else { - if (!(blockContainer.data.storage instanceof EmptyPaletteStorage)) { + if (!(blockContainer.data.storage instanceof ZeroBitStorage)) { throw new IllegalStateException(); } int bId = pc[0]; diff --git a/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem2.java b/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem2.java index 7e89e254..cf4c119e 100644 --- a/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem2.java +++ b/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem2.java @@ -5,7 +5,7 @@ import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.util.MemoryBuffer; import me.cortex.voxy.common.util.UnsafeUtil; import me.cortex.voxy.common.world.other.Mapper; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import org.lwjgl.system.MemoryUtil; import java.util.Arrays; @@ -170,7 +170,7 @@ public class SaveLoadSystem2 { //TODO: see if tight bitpacking is better or if bitpacking with pow2 pack size is better {//Store blocks - final int SIZE = MathHelper.smallestEncompassingPowerOfTwo(MathHelper.floorLog2(MathHelper.smallestEncompassingPowerOfTwo(blockMapping.size()))); + final int SIZE = Mth.smallestEncompassingPowerOfTwo(Mth.log2(Mth.smallestEncompassingPowerOfTwo(blockMapping.size()))); int rem = 32; int batch = 0; @@ -195,7 +195,7 @@ public class SaveLoadSystem2 { if (biomeMapping.size() == 1) { //If its only a single mapping, dont put anything } else { - final int SIZE = MathHelper.smallestEncompassingPowerOfTwo(MathHelper.floorLog2(MathHelper.smallestEncompassingPowerOfTwo(biomeMapping.size()))); + final int SIZE = Mth.smallestEncompassingPowerOfTwo(Mth.log2(Mth.smallestEncompassingPowerOfTwo(biomeMapping.size()))); int rem = 32; int batch = 0; @@ -295,7 +295,7 @@ public class SaveLoadSystem2 { short[] blocks = new short[32*32*32]; short[] biomes = new short[32*32*32]; {//Block - final int SIZE = MathHelper.smallestEncompassingPowerOfTwo(MathHelper.floorLog2(MathHelper.smallestEncompassingPowerOfTwo(blockMapSize))); + final int SIZE = Mth.smallestEncompassingPowerOfTwo(Mth.log2(Mth.smallestEncompassingPowerOfTwo(blockMapSize))); int rem = 32; int batch = MemoryUtil.memGetInt(ptr); ptr += 4; int msk = (1< biome) { + public long getBaseId(byte light, BlockState state, Holder biome) { if (state.isAir()) return Byte.toUnsignedLong(light) <<56;//Special case and fast return for air, dont care about the biome return composeMappingId(light, this.getIdForBlockState(state), this.getIdForBiome(biome)); } @@ -254,8 +254,8 @@ public class Mapper { return this.blockId2stateEntry.get(blockId).opacity; } - public int getIdForBiome(RegistryEntry biome) { - String biomeId = biome.getKey().get().getValue().toString(); + public int getIdForBiome(Holder biome) { + String biomeId = biome.unwrapKey().get().location().toString(); var entry = this.biome2biomeEntry.get(biomeId); if (entry == null) { entry = this.registerNewBiome(biomeId); @@ -354,13 +354,13 @@ public class Mapper { if (state.getBlock() instanceof LeavesBlock) { this.opacity = 15; } else { - this.opacity = state.getOpacity(); + this.opacity = state.getLightBlock(); } } public byte[] serialize() { try { - var serialized = new NbtCompound(); + var serialized = new CompoundTag(); serialized.putInt("id", this.id); serialized.put("block_state", BlockState.CODEC.encodeStart(NbtOps.INSTANCE, this.state).result().get()); var out = new ByteArrayOutputStream(); @@ -373,19 +373,19 @@ public class Mapper { public static StateEntry deserialize(int id, byte[] data, boolean[] forceResave) { try { - var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtSizeTracker.ofUnlimitedBytes()); - if (compound.getInt("id", -1) != id) { + var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtAccounter.unlimitedHeap()); + if (compound.getIntOr("id", -1) != id) { throw new IllegalStateException("Encoded id != expected id"); } var bsc = compound.getCompound("block_state").orElseThrow(); var state = BlockState.CODEC.parse(NbtOps.INSTANCE, bsc); if (state.isError()) { Logger.info("Could not decode blockstate, attempting fixes, error: "+ state.error().get().message()); - bsc = (NbtCompound) Schemas.getFixer().update(TypeReferences.BLOCK_STATE, new Dynamic<>(NbtOps.INSTANCE,bsc),0, SharedConstants.getGameVersion().dataVersion().id()).getValue(); + bsc = (CompoundTag) DataFixers.getDataFixer().update(References.BLOCK_STATE, new Dynamic<>(NbtOps.INSTANCE,bsc),0, SharedConstants.getCurrentVersion().dataVersion().version()).getValue(); state = BlockState.CODEC.parse(NbtOps.INSTANCE, bsc); if (state.isError()) { Logger.error("Could not decode blockstate setting to air. id:" + id + " error: " + state.error().get().message()); - return new StateEntry(id, Blocks.AIR.getDefaultState()); + return new StateEntry(id, Blocks.AIR.defaultBlockState()); } else { Logger.info("Fixed blockstate to: " + state.getOrThrow()); forceResave[0] |= true; @@ -411,7 +411,7 @@ public class Mapper { public byte[] serialize() { try { - var serialized = new NbtCompound(); + var serialized = new CompoundTag(); serialized.putInt("id", this.id); serialized.putString("biome_id", this.biome); var out = new ByteArrayOutputStream(); @@ -424,11 +424,11 @@ public class Mapper { public static BiomeEntry deserialize(int id, byte[] data) { try { - var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtSizeTracker.ofUnlimitedBytes()); - if (compound.getInt("id", -1) != id) { + var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtAccounter.unlimitedHeap()); + if (compound.getIntOr("id", -1) != id) { throw new IllegalStateException("Encoded id != expected id"); } - String biome = compound.getString("biome_id", null); + String biome = compound.getStringOr("biome_id", null); return new BiomeEntry(id, biome); } catch (IOException e) { throw new RuntimeException(e); diff --git a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java index 7b940069..c8759a18 100644 --- a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java +++ b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java @@ -10,12 +10,12 @@ import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldUpdater; import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.WorldIdentifier; -import net.minecraft.util.math.ChunkSectionPos; -import net.minecraft.world.LightType; -import net.minecraft.world.chunk.ChunkNibbleArray; -import net.minecraft.world.chunk.ChunkSection; -import net.minecraft.world.chunk.WorldChunk; -import net.minecraft.world.chunk.light.LightStorage; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.chunk.DataLayer; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.lighting.LayerLightSectionStorage; import org.jetbrains.annotations.NotNull; import java.util.concurrent.ConcurrentLinkedDeque; @@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentLinkedDeque; public class VoxelIngestService { private static final ThreadLocal SECTION_CACHE = ThreadLocal.withInitial(VoxelizedSection::createEmpty); private final Service service; - private record IngestSection(int cx, int cy, int cz, WorldEngine world, ChunkSection section, ChunkNibbleArray blockLight, ChunkNibbleArray skyLight){} + private record IngestSection(int cx, int cy, int cz, WorldEngine world, LevelChunkSection section, DataLayer blockLight, DataLayer skyLight){} private final ConcurrentLinkedDeque ingestQueue = new ConcurrentLinkedDeque<>(); public VoxelIngestService(ServiceManager pool) { @@ -37,14 +37,14 @@ public class VoxelIngestService { var section = task.section; var vs = SECTION_CACHE.get().setPosition(task.cx, task.cy, task.cz); - if (section.isEmpty() && task.blockLight==null && task.skyLight==null) {//If the chunk section has lighting data, propagate it + if (section.hasOnlyAir() && task.blockLight==null && task.skyLight==null) {//If the chunk section has lighting data, propagate it WorldUpdater.insertUpdate(task.world, vs.zero()); } else { VoxelizedSection csec = WorldConversionFactory.convert( SECTION_CACHE.get(), task.world.getMapper(), - section.getBlockStateContainer(), - section.getBiomeContainer(), + section.getStates(), + section.getBiomes(), getLightingSupplier(task) ); WorldConversionFactory.mipSection(csec, task.world.getMapper()); @@ -57,8 +57,8 @@ public class VoxelIngestService { ILightingSupplier supplier = (x,y,z) -> (byte) 0; var sla = task.skyLight; var bla = task.blockLight; - boolean sl = sla != null && !sla.isUninitialized(); - boolean bl = bla != null && !bla.isUninitialized(); + boolean sl = sla != null && !sla.isEmpty(); + boolean bl = bla != null && !bla.isEmpty(); if (sl || bl) { if (sl && bl) { supplier = (x,y,z)-> { @@ -83,11 +83,11 @@ public class VoxelIngestService { return supplier; } - private static boolean shouldIngestSection(ChunkSection section, int cx, int cy, int cz) { + private static boolean shouldIngestSection(LevelChunkSection section, int cx, int cy, int cz) { return true; } - public boolean enqueueIngest(WorldEngine engine, WorldChunk chunk) { + public boolean enqueueIngest(WorldEngine engine, LevelChunk chunk) { if (!this.service.isLive()) { return false; } @@ -97,26 +97,26 @@ public class VoxelIngestService { engine.markActive(); - var lightingProvider = chunk.getWorld().getLightingProvider(); + var lightingProvider = chunk.getLevel().getLightEngine(); boolean gotLighting = false; - int i = chunk.getBottomSectionCoord() - 1; + int i = chunk.getMinSectionY() - 1; boolean allEmpty = true; - for (var section : chunk.getSectionArray()) { + for (var section : chunk.getSections()) { i++; if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue; - allEmpty&=section.isEmpty(); + allEmpty&=section.hasOnlyAir(); //if (section.isEmpty()) continue; - var pos = ChunkSectionPos.from(chunk.getPos(), i); - if (lightingProvider.getStatus(LightType.SKY, pos) != LightStorage.Status.LIGHT_AND_DATA && lightingProvider.getStatus(LightType.BLOCK, pos) != LightStorage.Status.LIGHT_AND_DATA) + var pos = SectionPos.of(chunk.getPos(), i); + if (lightingProvider.getDebugSectionType(LightLayer.SKY, pos) != LayerLightSectionStorage.SectionType.LIGHT_AND_DATA && lightingProvider.getDebugSectionType(LightLayer.BLOCK, pos) != LayerLightSectionStorage.SectionType.LIGHT_AND_DATA) continue; gotLighting = true; } if (allEmpty&&!gotLighting) { //Special case all empty chunk columns, we need to clear it out - i = chunk.getBottomSectionCoord() - 1; - for (var section : chunk.getSectionArray()) { + i = chunk.getMinSectionY() - 1; + for (var section : chunk.getSections()) { i++; if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue; this.ingestQueue.add(new IngestSection(chunk.getPos().x, i, chunk.getPos().z, engine, section, null, null)); @@ -133,23 +133,23 @@ public class VoxelIngestService { return false; } - var blp = lightingProvider.get(LightType.BLOCK); - var slp = lightingProvider.get(LightType.SKY); + var blp = lightingProvider.getLayerListener(LightLayer.BLOCK); + var slp = lightingProvider.getLayerListener(LightLayer.SKY); - i = chunk.getBottomSectionCoord() - 1; - for (var section : chunk.getSectionArray()) { + i = chunk.getMinSectionY() - 1; + for (var section : chunk.getSections()) { i++; if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue; //if (section.isEmpty()) continue; - var pos = ChunkSectionPos.from(chunk.getPos(), i); + var pos = SectionPos.of(chunk.getPos(), i); - var bl = blp.getLightSection(pos); + var bl = blp.getDataLayerData(pos); if (bl != null) { bl = bl.copy(); } - var sl = slp.getLightSection(pos); + var sl = slp.getDataLayerData(pos); if (sl != null) { sl = sl.copy(); } @@ -179,7 +179,7 @@ public class VoxelIngestService { } //Utility method to ingest a chunk into the given WorldIdentifier or world - public static boolean tryIngestChunk(WorldIdentifier worldId, WorldChunk chunk) { + public static boolean tryIngestChunk(WorldIdentifier worldId, LevelChunk chunk) { if (worldId == null) return false; var instance = VoxyCommon.getInstance(); if (instance == null) return false; @@ -190,11 +190,11 @@ public class VoxelIngestService { } //Try to automatically ingest the chunk into the correct world - public static boolean tryAutoIngestChunk(WorldChunk chunk) { - return tryIngestChunk(WorldIdentifier.of(chunk.getWorld()), chunk); + public static boolean tryAutoIngestChunk(LevelChunk chunk) { + return tryIngestChunk(WorldIdentifier.of(chunk.getLevel()), chunk); } - private boolean rawIngest0(WorldEngine engine, ChunkSection section, int x, int y, int z, ChunkNibbleArray bl, ChunkNibbleArray sl) { + private boolean rawIngest0(WorldEngine engine, LevelChunkSection section, int x, int y, int z, DataLayer bl, DataLayer sl) { this.ingestQueue.add(new IngestSection(x, y, z, engine, section, bl, sl)); try { this.service.execute(); @@ -205,14 +205,14 @@ public class VoxelIngestService { } } - public static boolean rawIngest(WorldIdentifier id, ChunkSection section, int x, int y, int z, ChunkNibbleArray bl, ChunkNibbleArray sl) { + public static boolean rawIngest(WorldIdentifier id, LevelChunkSection section, int x, int y, int z, DataLayer bl, DataLayer sl) { if (id == null) return false; var engine = id.getOrCreateEngine(); if (engine == null) return false; return rawIngest(engine, section, x, y, z, bl, sl); } - public static boolean rawIngest(WorldEngine engine, ChunkSection section, int x, int y, int z, ChunkNibbleArray bl, ChunkNibbleArray sl) { + public static boolean rawIngest(WorldEngine engine, LevelChunkSection section, int x, int y, int z, DataLayer bl, DataLayer sl) { if (!shouldIngestSection(section, x, y, z)) return false; if (engine.instanceIn == null) return false; if (!engine.instanceIn.isIngestEnabled(null)) return false;//TODO: dont pass in null diff --git a/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java b/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java index 6640aaeb..a173773b 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java +++ b/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java @@ -1,11 +1,11 @@ package me.cortex.voxy.commonImpl; import me.cortex.voxy.common.world.WorldEngine; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.util.Identifier; -import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.dimension.DimensionType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,15 +14,15 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class WorldIdentifier { - private static final RegistryKey NULL_DIM_KEY = RegistryKey.of(RegistryKeys.DIMENSION_TYPE, Identifier.of("voxy:null_dimension_id")); + private static final ResourceKey NULL_DIM_KEY = ResourceKey.create(Registries.DIMENSION_TYPE, ResourceLocation.parse("voxy:null_dimension_id")); - public final RegistryKey key; + public final ResourceKey key; public final long biomeSeed; - public final RegistryKey dimension;//Maybe? + public final ResourceKey dimension;//Maybe? private final transient long hashCode; @Nullable transient WeakReference cachedEngineObject; - public WorldIdentifier(@NotNull RegistryKey key, long biomeSeed, @Nullable RegistryKey dimension) { + public WorldIdentifier(@NotNull ResourceKey key, long biomeSeed, @Nullable ResourceKey dimension) { if (key == null) { throw new IllegalStateException("Key cannot be null"); } @@ -50,10 +50,10 @@ public class WorldIdentifier { return false; } - private static boolean equal(RegistryKey a, RegistryKey b) { + private static boolean equal(ResourceKey a, ResourceKey b) { if (a == b) return true; if (a == null || b == null) return false; - return a.getRegistry().equals(b.getRegistry()) && a.getValue().equals(b.getValue()); + return a.registry().equals(b.registry()) && a.location().equals(b.location()); } //Quick access utility method to get or create a world object in the current instance @@ -79,7 +79,7 @@ public class WorldIdentifier { return instance.getNullable(this); } - public static WorldIdentifier of(World world) { + public static WorldIdentifier of(Level world) { //Gets or makes an identifier for world if (world == null) { return null; @@ -88,7 +88,7 @@ public class WorldIdentifier { } //Common utility function to get or create a world engine - public static WorldEngine ofEngine(World world) { + public static WorldEngine ofEngine(Level world) { var id = of(world); if (id == null) { return null; @@ -96,7 +96,7 @@ public class WorldIdentifier { return id.getOrCreateEngine(); } - public static WorldEngine ofEngineNullable(World world) { + public static WorldEngine ofEngineNullable(Level world) { var id = of(world); if (id == null) { return null; @@ -115,9 +115,9 @@ public class WorldIdentifier { return this.hashCode; } - private static long registryKeyHashCode(RegistryKey key) { - var A = key.getRegistry(); - var B = key.getValue(); + private static long registryKeyHashCode(ResourceKey key) { + var A = key.registry(); + var B = key.location(); int a = A==null?0:A.hashCode(); int b = B==null?0:B.hashCode(); return (Integer.toUnsignedLong(a)<<32)|Integer.toUnsignedLong(b); diff --git a/src/main/java/me/cortex/voxy/commonImpl/importers/DHImporter.java b/src/main/java/me/cortex/voxy/commonImpl/importers/DHImporter.java index ec135d21..53331cab 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/importers/DHImporter.java +++ b/src/main/java/me/cortex/voxy/commonImpl/importers/DHImporter.java @@ -9,16 +9,16 @@ import me.cortex.voxy.common.voxelization.WorldConversionFactory; import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldUpdater; import me.cortex.voxy.common.world.other.Mapper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.Identifier; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeKeys; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; import org.apache.commons.io.IOUtils; import org.tukaani.xz.BasicArrayCache; import org.tukaani.xz.ResettableArrayCache; @@ -44,10 +44,10 @@ public class DHImporter implements IDataImporter { private final Connection db; private final WorldEngine engine; private final Service service; - private final World world; + private final Level world; private final int bottomOfWorld; private final int worldHeightSections; - private final RegistryEntry.Reference defaultBiome; + private final Holder.Reference defaultBiome; private final Registry biomeRegistry; private final Registry blockRegistry; private Thread runner; @@ -68,14 +68,14 @@ public class DHImporter implements IDataImporter { } } - public DHImporter(File file, WorldEngine worldEngine, World mcWorld, ServiceManager servicePool, BooleanSupplier rateLimiter) { + public DHImporter(File file, WorldEngine worldEngine, Level mcWorld, ServiceManager servicePool, BooleanSupplier rateLimiter) { this.engine = worldEngine; this.world = mcWorld; - this.biomeRegistry = mcWorld.getRegistryManager().getOrThrow(RegistryKeys.BIOME); - this.defaultBiome = this.biomeRegistry.getOrThrow(BiomeKeys.PLAINS); - this.blockRegistry = mcWorld.getRegistryManager().getOrThrow(RegistryKeys.BLOCK); + this.biomeRegistry = mcWorld.registryAccess().lookupOrThrow(Registries.BIOME); + this.defaultBiome = this.biomeRegistry.getOrThrow(Biomes.PLAINS); + this.blockRegistry = mcWorld.registryAccess().lookupOrThrow(Registries.BLOCK); - this.bottomOfWorld = mcWorld.getBottomY(); + this.bottomOfWorld = mcWorld.getMinY(); int worldHeight = mcWorld.getHeight(); this.worldHeightSections = (worldHeight+15)/16; @@ -179,8 +179,8 @@ public class DHImporter implements IDataImporter { StringBuilder b = new StringBuilder(); for (var prop : props) { String val = "NULL"; - if (state.contains(prop)) { - val = state.get(prop).toString(); + if (state.hasProperty(prop)) { + val = state.getValue(prop).toString(); } b.append("{").append(prop.getName()).append(":").append(val).append("}"); } @@ -205,8 +205,8 @@ public class DHImporter implements IDataImporter { if (idx == -1) throw new IllegalStateException(); { - var biomeRes = Identifier.of(encEntry.substring(0, idx)); - var biome = this.biomeRegistry.getEntry(biomeRes).orElse(this.defaultBiome); + var biomeRes = ResourceLocation.parse(encEntry.substring(0, idx)); + var biome = this.biomeRegistry.get(biomeRes).orElse(this.defaultBiome); biomeId = this.engine.getMapper().getIdForBiome(biome); } { @@ -219,16 +219,16 @@ public class DHImporter implements IDataImporter { if (sIdx != -1) { bStateStr = encEntry.substring(sIdx + STATE_STRING_SEPARATOR.length()); } - var bId = Identifier.of(encEntry.substring(b, sIdx != -1 ? sIdx : encEntry.length())); - var maybeBlock = this.blockRegistry.getEntry(bId); + var bId = ResourceLocation.parse(encEntry.substring(b, sIdx != -1 ? sIdx : encEntry.length())); + var maybeBlock = this.blockRegistry.get(bId); Block block = Blocks.AIR; if (maybeBlock.isPresent()) { block = maybeBlock.get().value(); } - var state = block.getDefaultState(); + var state = block.defaultBlockState(); if (bStateStr != null && block != Blocks.AIR) { boolean found = false; - for (BlockState bState : block.getStateManager().getStates()) { + for (BlockState bState : block.getStateDefinition().getPossibleStates()) { if (getSerialBlockState(bState).equals(bStateStr)) { state = bState; found = true; diff --git a/src/main/java/me/cortex/voxy/commonImpl/importers/WorldImporter.java b/src/main/java/me/cortex/voxy/commonImpl/importers/WorldImporter.java index 847b79bc..1fbcc3e0 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/importers/WorldImporter.java +++ b/src/main/java/me/cortex/voxy/commonImpl/importers/WorldImporter.java @@ -11,18 +11,23 @@ import me.cortex.voxy.common.voxelization.VoxelizedSection; import me.cortex.voxy.common.voxelization.WorldConversionFactory; import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldUpdater; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.NbtCompound; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtOps; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeKeys; -import net.minecraft.world.chunk.*; -import net.minecraft.world.storage.ChunkCompressionFormat; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.DataLayer; +import net.minecraft.world.level.chunk.PalettedContainer; +import net.minecraft.world.level.chunk.PalettedContainerFactory; +import net.minecraft.world.level.chunk.PalettedContainerRO; +import net.minecraft.world.level.chunk.Strategy; +import net.minecraft.world.level.chunk.status.ChunkStatus; +import net.minecraft.world.level.chunk.storage.RegionFileVersion; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipFile; import org.lwjgl.system.MemoryUtil; @@ -45,8 +50,8 @@ import java.util.function.Predicate; public class WorldImporter implements IDataImporter { private final WorldEngine world; - private final ReadableContainer> defaultBiomeProvider; - private final Codec>> biomeCodec; + private final PalettedContainerRO> defaultBiomeProvider; + private final Codec>> biomeCodec; private final Codec> blockStateCodec; private final AtomicInteger estimatedTotalChunks = new AtomicInteger();//Slowly converges to the true value private final AtomicInteger totalChunks = new AtomicInteger(); @@ -57,65 +62,65 @@ public class WorldImporter implements IDataImporter { private volatile boolean isRunning; - public WorldImporter(WorldEngine worldEngine, World mcWorld, ServiceManager sm, BooleanSupplier runChecker) { + public WorldImporter(WorldEngine worldEngine, Level mcWorld, ServiceManager sm, BooleanSupplier runChecker) { this.world = worldEngine; this.service = sm.createService(()->new Pair<>(()->this.jobQueue.poll().run(), ()->{}), 3, "World importer", runChecker); - var biomeRegistry = mcWorld.getRegistryManager().getOrThrow(RegistryKeys.BIOME); - var defaultBiome = biomeRegistry.getOrThrow(BiomeKeys.PLAINS); - this.defaultBiomeProvider = new ReadableContainer<>() { + var biomeRegistry = mcWorld.registryAccess().lookupOrThrow(Registries.BIOME); + var defaultBiome = biomeRegistry.getOrThrow(Biomes.PLAINS); + this.defaultBiomeProvider = new PalettedContainerRO<>() { @Override - public RegistryEntry get(int x, int y, int z) { + public Holder get(int x, int y, int z) { return defaultBiome; } @Override - public void forEachValue(Consumer> action) { + public void getAll(Consumer> action) { } @Override - public void writePacket(PacketByteBuf buf) { + public void write(FriendlyByteBuf buf) { } @Override - public int getPacketSize() { + public int getSerializedSize() { return 0; } @Override - public int getElementBits() { + public int bitsPerEntry() { return 0; } @Override - public boolean hasAny(Predicate> predicate) { + public boolean maybeHas(Predicate> predicate) { return false; } @Override - public void count(PalettedContainer.Counter> counter) { + public void count(PalettedContainer.CountConsumer> counter) { } @Override - public PalettedContainer> copy() { + public PalettedContainer> copy() { return null; } @Override - public PalettedContainer> slice() { + public PalettedContainer> recreate() { return null; } @Override - public Serialized> serialize(PaletteProvider> provider) { + public PackedData> pack(Strategy> provider) { return null; } }; - var factory = PalettesFactory.fromRegistryManager(mcWorld.getRegistryManager()); + var factory = PalettedContainerFactory.create(mcWorld.registryAccess()); this.biomeCodec = factory.biomeContainerCodec(); this.blockStateCodec = factory.blockStatesContainerCodec(); } @@ -379,7 +384,7 @@ public class WorldImporter implements IDataImporter { if (decompressedData == null) { Logger.error("Error decompressing chunk data"); } else { - var nbt = NbtIo.readCompound(decompressedData); + var nbt = NbtIo.read(decompressedData); this.importChunkNBT(nbt, x, z); } } @@ -424,7 +429,7 @@ public class WorldImporter implements IDataImporter { } private DataInputStream decompress(byte flags, MemoryBuffer stream) throws IOException { - ChunkCompressionFormat chunkStreamVersion = ChunkCompressionFormat.get(flags); + RegionFileVersion chunkStreamVersion = RegionFileVersion.fromId(flags); if (chunkStreamVersion == null) { Logger.error("Chunk has invalid chunk stream version"); return null; @@ -433,7 +438,7 @@ public class WorldImporter implements IDataImporter { } } - private void importChunkNBT(NbtCompound chunk, int regionX, int regionZ) { + private void importChunkNBT(CompoundTag chunk, int regionX, int regionZ) { if (!chunk.contains("Status")) { //Its not real so decrement the chunk this.totalChunks.decrementAndGet(); @@ -441,22 +446,22 @@ public class WorldImporter implements IDataImporter { } //Dont process non full chunk sections - var status = ChunkStatus.byId(chunk.getString("Status", null)); + var status = ChunkStatus.byName(chunk.getStringOr("Status", null)); if (status != ChunkStatus.FULL && status != ChunkStatus.EMPTY) {//We also import empty since they are from data upgrade this.totalChunks.decrementAndGet(); return; } try { - int x = chunk.getInt("xPos", Integer.MIN_VALUE); - int z = chunk.getInt("zPos", Integer.MIN_VALUE); + int x = chunk.getIntOr("xPos", Integer.MIN_VALUE); + int z = chunk.getIntOr("zPos", Integer.MIN_VALUE); if (x>>5 != regionX || z>>5 != regionZ) { Logger.error("Chunk position is not located in correct region, expected: (" + regionX + ", " + regionZ+"), got: " + "(" + (x>>5) + ", " + (z>>5)+"), importing anyway"); } for (var sectionE : chunk.getList("sections").orElseThrow()) { - var section = (NbtCompound) sectionE; - int y = section.getInt("Y", Integer.MIN_VALUE); + var section = (CompoundTag) sectionE; + int y = section.getIntOr("Y", Integer.MIN_VALUE); this.importSectionNBT(x, y, z, section); } } catch (Exception e) { @@ -468,7 +473,7 @@ public class WorldImporter implements IDataImporter { private static final byte[] EMPTY = new byte[0]; private static final ThreadLocal SECTION_CACHE = ThreadLocal.withInitial(VoxelizedSection::createEmpty); - private void importSectionNBT(int x, int y, int z, NbtCompound section) { + private void importSectionNBT(int x, int y, int z, CompoundTag section) { if (section.getCompound("block_states").isEmpty()) { return; } @@ -476,16 +481,16 @@ public class WorldImporter implements IDataImporter { byte[] blockLightData = section.getByteArray("BlockLight").orElse(EMPTY); byte[] skyLightData = section.getByteArray("SkyLight").orElse(EMPTY); - ChunkNibbleArray blockLight; + DataLayer blockLight; if (blockLightData.length != 0) { - blockLight = new ChunkNibbleArray(blockLightData); + blockLight = new DataLayer(blockLightData); } else { blockLight = null; } - ChunkNibbleArray skyLight; + DataLayer skyLight; if (skyLightData.length != 0) { - skyLight = new ChunkNibbleArray(skyLightData); + skyLight = new DataLayer(skyLightData); } else { skyLight = null; } diff --git a/src/main/java/me/cortex/voxy/commonImpl/mixin/chunky/MixinFabricWorld.java b/src/main/java/me/cortex/voxy/commonImpl/mixin/chunky/MixinFabricWorld.java index 6fe7a5e9..fc5d9de4 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/mixin/chunky/MixinFabricWorld.java +++ b/src/main/java/me/cortex/voxy/commonImpl/mixin/chunky/MixinFabricWorld.java @@ -3,10 +3,10 @@ package me.cortex.voxy.commonImpl.mixin.chunky; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import me.cortex.voxy.common.world.service.VoxelIngestService; -import net.minecraft.server.world.OptionalChunk; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.server.level.ChunkResult; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; import org.popcraft.chunky.mixin.ServerChunkCacheMixin; import org.popcraft.chunky.platform.FabricWorld; import org.spongepowered.asm.mixin.Mixin; @@ -17,14 +17,14 @@ import java.util.concurrent.CompletableFuture; @Mixin(FabricWorld.class) public class MixinFabricWorld { @WrapOperation(method = "getChunkAtAsync", at = @At(value = "INVOKE", target = "Lorg/popcraft/chunky/mixin/ServerChunkCacheMixin;invokeGetChunkFutureMainThread(IILnet/minecraft/world/chunk/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture;")) - private CompletableFuture> captureGeneratedChunk(ServerChunkCacheMixin instance, int i, int j, ChunkStatus chunkStatus, boolean b, Operation>> original) { + private CompletableFuture> captureGeneratedChunk(ServerChunkCacheMixin instance, int i, int j, ChunkStatus chunkStatus, boolean b, Operation>> original) { var future = original.call(instance, i, j, chunkStatus, b); if (false) {//TODO: ADD SERVER CONFIG THING return future; } else { return future.thenApply(res -> { - res.ifPresent(chunk -> { - if (chunk instanceof WorldChunk worldChunk) { + res.ifSuccess(chunk -> { + if (chunk instanceof LevelChunk worldChunk) { VoxelIngestService.tryAutoIngestChunk(worldChunk); } }); diff --git a/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java b/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java index 67b4c628..42fc4c7f 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java +++ b/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java @@ -2,35 +2,35 @@ package me.cortex.voxy.commonImpl.mixin.minecraft; import me.cortex.voxy.commonImpl.IWorldGetIdentifier; import me.cortex.voxy.commonImpl.WorldIdentifier; -import net.minecraft.registry.DynamicRegistryManager; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.world.MutableWorldProperties; -import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.storage.WritableLevelData; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(World.class) +@Mixin(Level.class) public class MixinWorld implements IWorldGetIdentifier { @Unique private WorldIdentifier identifier; @Inject(method = "", at = @At("RETURN")) - private void voxy$injectIdentifier(MutableWorldProperties properties, - RegistryKey key, - DynamicRegistryManager registryManager, - RegistryEntry dimensionEntry, + private void voxy$injectIdentifier(WritableLevelData properties, + ResourceKey key, + RegistryAccess registryManager, + Holder dimensionEntry, boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates, CallbackInfo ci) { if (key != null) { - this.identifier = new WorldIdentifier(key, seed, dimensionEntry == null?null:dimensionEntry.getKey().orElse(null)); + this.identifier = new WorldIdentifier(key, seed, dimensionEntry == null?null:dimensionEntry.unwrapKey().orElse(null)); } else { this.identifier = null; } diff --git a/src/main/resources/voxy.accesswidener b/src/main/resources/voxy.accesswidener index 5d3d403a..a4cb8b1a 100644 --- a/src/main/resources/voxy.accesswidener +++ b/src/main/resources/voxy.accesswidener @@ -1,38 +1,25 @@ accessWidener v1 named -accessible class net/minecraft/client/render/RenderLayer$MultiPhase -accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters +accessible class net/minecraft/client/multiplayer/ClientChunkCache$Storage +accessible class com/mojang/blaze3d/opengl/GlDebug$LogEntry -accessible field net/minecraft/client/texture/SpriteContents image Lnet/minecraft/client/texture/NativeImage; -accessible field net/minecraft/client/render/Frustum frustumIntersection Lorg/joml/FrustumIntersection; -accessible field net/minecraft/client/color/block/BlockColors providers Lnet/minecraft/util/collection/IdList; -accessible field net/minecraft/client/world/ClientWorld worldRenderer Lnet/minecraft/client/render/WorldRenderer; -accessible field net/minecraft/world/biome/source/BiomeAccess seed J +accessible field net/minecraft/client/multiplayer/ClientLevel levelRenderer Lnet/minecraft/client/renderer/LevelRenderer; +accessible field com/mojang/blaze3d/opengl/GlBuffer handle I +accessible field net/minecraft/client/color/block/BlockColors blockColors Lnet/minecraft/core/IdMapper; +accessible field net/minecraft/client/renderer/texture/TextureAtlas mipLevel I +accessible field net/minecraft/client/gui/components/BossHealthOverlay events Ljava/util/Map; +accessible field net/minecraft/client/multiplayer/MultiPlayerGameMode connection Lnet/minecraft/client/multiplayer/ClientPacketListener; -accessible field net/minecraft/client/gui/hud/BossBarHud bossBars Ljava/util/Map; +accessible field net/minecraft/world/level/chunk/PalettedContainer data Lnet/minecraft/world/level/chunk/PalettedContainer$Data; +accessible field net/minecraft/world/level/chunk/PalettedContainer$Data palette Lnet/minecraft/world/level/chunk/Palette; +accessible field net/minecraft/world/level/chunk/PalettedContainer$Data storage Lnet/minecraft/util/BitStorage; -accessible field net/minecraft/client/render/RenderLayer$MultiPhaseParameters texture Lnet/minecraft/client/render/RenderPhase$TextureBase; -accessible field net/minecraft/client/render/RenderLayer$MultiPhase phases Lnet/minecraft/client/render/RenderLayer$MultiPhaseParameters; -accessible field net/minecraft/client/network/ClientPlayerInteractionManager networkHandler Lnet/minecraft/client/network/ClientPlayNetworkHandler; +accessible field net/minecraft/client/renderer/RenderType$CompositeRenderType state Lnet/minecraft/client/renderer/RenderType$CompositeState; +accessible field net/minecraft/client/renderer/RenderType$CompositeState textureState Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard; +accessible method net/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard cutoutTexture ()Ljava/util/Optional; -accessible method net/minecraft/client/render/GameRenderer getFov (Lnet/minecraft/client/render/Camera;FZ)F -accessible method net/minecraft/client/render/RenderPhase$TextureBase getId ()Ljava/util/Optional; +accessible method net/minecraft/client/renderer/texture/MipmapGenerator alphaBlend (IIIIZ)I +accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)F -accessible field net/minecraft/world/chunk/PalettedContainer data Lnet/minecraft/world/chunk/PalettedContainer$Data; -accessible field net/minecraft/world/chunk/PalettedContainer$Data storage Lnet/minecraft/util/collection/PaletteStorage; -accessible field net/minecraft/world/chunk/PalettedContainer$Data palette Lnet/minecraft/world/chunk/Palette; - -accessible field net/minecraft/client/gl/GlGpuBuffer id I - -accessible field net/minecraft/client/gl/GlCommandEncoder currentProgram Lnet/minecraft/client/gl/ShaderProgram; -accessible field net/minecraft/client/gl/GlCommandEncoder currentPipeline Lcom/mojang/blaze3d/pipeline/RenderPipeline; - -accessible class net/minecraft/client/gl/GlDebug$DebugMessage - -accessible class net/minecraft/client/world/ClientChunkManager$ClientChunkMap -accessible method net/minecraft/client/world/ClientChunkManager$ClientChunkMap getChunk (I)Lnet/minecraft/world/chunk/WorldChunk; -accessible method net/minecraft/client/world/ClientChunkManager$ClientChunkMap getIndex (II)I - -accessible field net/minecraft/client/texture/SpriteAtlasTexture mipLevel I - -accessible method net/minecraft/client/texture/MipmapHelper blend (IIIIZ)I \ No newline at end of file +accessible method net/minecraft/client/multiplayer/ClientChunkCache$Storage getChunk (I)Lnet/minecraft/world/level/chunk/LevelChunk; +accessible method net/minecraft/client/multiplayer/ClientChunkCache$Storage getIndex (II)I \ No newline at end of file