mojmap part 1

This commit is contained in:
mcrcortex
2025-10-30 02:30:59 +10:00
parent 36325a0946
commit a8075158ba
58 changed files with 661 additions and 693 deletions

View File

@@ -93,7 +93,7 @@ if (!isInGHA) {
dependencies { dependencies {
// To change the versions see the gradle.properties file // To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}" 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}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

View File

@@ -8,7 +8,6 @@ org.gradle.daemon = false
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.10 minecraft_version=1.21.10
yarn_mappings=1.21.10+build.1
loader_version=0.17.2 loader_version=0.17.2
loom_version=1.11-SNAPSHOT loom_version=1.11-SNAPSHOT

View File

@@ -3,25 +3,24 @@ package me.cortex.voxy.client;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import me.cortex.voxy.commonImpl.ImportManager; import me.cortex.voxy.commonImpl.ImportManager;
import me.cortex.voxy.commonImpl.importers.IDataImporter; import me.cortex.voxy.commonImpl.importers.IDataImporter;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.hud.ClientBossBar; import net.minecraft.client.gui.components.LerpingBossEvent;
import net.minecraft.entity.boss.BossBar; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text; import net.minecraft.util.Mth;
import net.minecraft.util.math.MathHelper; import net.minecraft.world.BossEvent;
import java.util.UUID; import java.util.UUID;
public class ClientImportManager extends ImportManager { public class ClientImportManager extends ImportManager {
protected class ClientImportTask extends ImportTask { protected class ClientImportTask extends ImportTask {
private final UUID bossbarUUID; private final UUID bossbarUUID;
private final ClientBossBar bossBar; private final LerpingBossEvent bossBar;
protected ClientImportTask(IDataImporter importer) { protected ClientImportTask(IDataImporter importer) {
super(importer); super(importer);
this.bossbarUUID = MathHelper.randomUuid(); this.bossbarUUID = Mth.createInsecureUUID();
this.bossBar = new ClientBossBar(this.bossbarUUID, Text.of("Voxy world importer"), 0.0f, BossBar.Color.GREEN, BossBar.Style.PROGRESS, false, false, false); this.bossBar = new LerpingBossEvent(this.bossbarUUID, Component.nullToEmpty("Voxy world importer"), 0.0f, BossEvent.BossBarColor.GREEN, BossEvent.BossBarOverlay.PROGRESS, false, false, false);
MinecraftClient.getInstance().execute(()->{ Minecraft.getInstance().execute(()->{
MinecraftClient.getInstance().inGameHud.getBossBarHud().bossBars.put(bossBar.getUuid(), bossBar); Minecraft.getInstance().gui.getBossOverlay().events.put(bossBar.getId(), bossBar);
}); });
} }
@@ -30,9 +29,9 @@ public class ClientImportManager extends ImportManager {
if (!super.onUpdate(completed, outOf)) { if (!super.onUpdate(completed, outOf)) {
return false; return false;
} }
MinecraftClient.getInstance().execute(()->{ Minecraft.getInstance().execute(()->{
this.bossBar.setPercent((float) (((double)completed) / ((double) Math.max(1, outOf)))); this.bossBar.setProgress((float) (((double)completed) / ((double) Math.max(1, outOf))));
this.bossBar.setName(Text.of("Voxy import: " + completed + "/" + outOf + " chunks")); this.bossBar.setName(Component.nullToEmpty("Voxy import: " + completed + "/" + outOf + " chunks"));
}); });
return true; return true;
} }
@@ -40,12 +39,12 @@ public class ClientImportManager extends ImportManager {
@Override @Override
protected void onCompleted(int total) { protected void onCompleted(int total) {
super.onCompleted(total); super.onCompleted(total);
MinecraftClient.getInstance().execute(()->{ Minecraft.getInstance().execute(()->{
MinecraftClient.getInstance().inGameHud.getBossBarHud().bossBars.remove(this.bossbarUUID); Minecraft.getInstance().gui.getBossOverlay().events.remove(this.bossbarUUID);
long delta = Math.max(System.currentTimeMillis() - this.startTime, 1); 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"; 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); Logger.info(msg);
}); });
} }

View File

@@ -1,7 +1,7 @@
package me.cortex.voxy.client; package me.cortex.voxy.client;
import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.level.chunk.LevelChunk;
public interface ICheekyClientChunkManager { public interface ICheekyClientChunkManager {
WorldChunk voxy$cheekyGetChunk(int x, int z); LevelChunk voxy$cheekyGetChunk(int x, int z);
} }

View File

@@ -8,9 +8,8 @@ import me.cortex.voxy.commonImpl.VoxyCommon;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.hud.debug.DebugHudEntries; import net.minecraft.client.gui.components.debug.DebugScreenEntries;
import net.minecraft.util.Identifier; import net.minecraft.resources.ResourceLocation;
import java.util.HashSet; import java.util.HashSet;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
@@ -40,7 +39,7 @@ public class VoxyClient implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
DebugHudEntries.register(Identifier.of("voxy","debug"), new VoxyDebugScreenEntry()); DebugScreenEntries.register(ResourceLocation.fromNamespaceAndPath("voxy","debug"), new VoxyDebugScreenEntry());
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> { ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
if (VoxyCommon.isAvailable()) { if (VoxyCommon.isAvailable()) {
dispatcher.register(VoxyCommands.register()); dispatcher.register(VoxyCommands.register());

View File

@@ -14,9 +14,8 @@ import me.cortex.voxy.common.config.storage.rocksdb.RocksDBStorageBackend;
import me.cortex.voxy.commonImpl.ImportManager; import me.cortex.voxy.commonImpl.ImportManager;
import me.cortex.voxy.commonImpl.VoxyInstance; import me.cortex.voxy.commonImpl.VoxyInstance;
import me.cortex.voxy.commonImpl.WorldIdentifier; import me.cortex.voxy.commonImpl.WorldIdentifier;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.util.WorldSavePath; import net.minecraft.world.level.storage.LevelResource;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@@ -125,17 +124,17 @@ public class VoxyClientInstance extends VoxyInstance {
} }
private static Path getBasePath() { private static Path getBasePath() {
Path basePath = MinecraftClient.getInstance().runDirectory.toPath().resolve(".voxy").resolve("saves"); Path basePath = Minecraft.getInstance().gameDirectory.toPath().resolve(".voxy").resolve("saves");
var iserver = MinecraftClient.getInstance().getServer(); var iserver = Minecraft.getInstance().getSingleplayerServer();
if (iserver != null) { if (iserver != null) {
basePath = iserver.getSavePath(WorldSavePath.ROOT).resolve("voxy"); basePath = iserver.getWorldPath(LevelResource.ROOT).resolve("voxy");
} else { } else {
var netHandle = MinecraftClient.getInstance().interactionManager; var netHandle = Minecraft.getInstance().gameMode;
if (netHandle == null) { if (netHandle == null) {
Logger.error("Network handle null"); Logger.error("Network handle null");
basePath = basePath.resolve("UNKNOWN"); basePath = basePath.resolve("UNKNOWN");
} else { } else {
var info = netHandle.networkHandler.getServerInfo(); var info = netHandle.connection.getServerData();
if (info == null) { if (info == null) {
Logger.error("Server info null"); Logger.error("Server info null");
basePath = basePath.resolve("UNKNOWN"); basePath = basePath.resolve("UNKNOWN");
@@ -143,7 +142,7 @@ public class VoxyClientInstance extends VoxyInstance {
if (info.isRealm()) { if (info.isRealm()) {
basePath = basePath.resolve("realms"); basePath = basePath.resolve("realms");
} else { } else {
basePath = basePath.resolve(info.address.replace(":", "_")); basePath = basePath.resolve(info.ip.replace(":", "_"));
} }
} }
} }

View File

@@ -12,11 +12,9 @@ import me.cortex.voxy.commonImpl.importers.DHImporter;
import me.cortex.voxy.commonImpl.importers.WorldImporter; import me.cortex.voxy.commonImpl.importers.WorldImporter;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.text.PlainTextContent; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -63,10 +61,10 @@ public class VoxyCommands {
private static int reloadInstance(CommandContext<FabricClientCommandSource> ctx) { private static int reloadInstance(CommandContext<FabricClientCommandSource> ctx) {
var instance = (VoxyClientInstance)VoxyCommon.getInstance(); var instance = (VoxyClientInstance)VoxyCommon.getInstance();
if (instance == null) { 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; return 1;
} }
var wr = MinecraftClient.getInstance().worldRenderer; var wr = Minecraft.getInstance().levelRenderer;
if (wr!=null) { if (wr!=null) {
((IGetVoxyRenderSystem)wr).shutdownRenderer(); ((IGetVoxyRenderSystem)wr).shutdownRenderer();
} }
@@ -85,7 +83,7 @@ public class VoxyCommands {
private static int importDistantHorizons(CommandContext<FabricClientCommandSource> ctx) { private static int importDistantHorizons(CommandContext<FabricClientCommandSource> ctx) {
var instance = (VoxyClientInstance)VoxyCommon.getInstance(); var instance = (VoxyClientInstance)VoxyCommon.getInstance();
if (instance == null) { 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; return 1;
} }
var dbFile = new File(ctx.getArgument("sqlDbPath", String.class)); var dbFile = new File(ctx.getArgument("sqlDbPath", String.class));
@@ -100,10 +98,10 @@ public class VoxyCommands {
} }
File dbFile_ = dbFile; File dbFile_ = dbFile;
var engine = WorldIdentifier.ofEngine(MinecraftClient.getInstance().world); var engine = WorldIdentifier.ofEngine(Minecraft.getInstance().level);
if (engine==null)return 1; if (engine==null)return 1;
return instance.getImportManager().makeAndRunIfNone(engine, ()-> 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) { private static boolean fileBasedImporter(File directory) {
@@ -112,10 +110,10 @@ public class VoxyCommands {
return false; return false;
} }
var engine = WorldIdentifier.ofEngine(MinecraftClient.getInstance().world); var engine = WorldIdentifier.ofEngine(Minecraft.getInstance().level);
if (engine==null) return false; if (engine==null) return false;
return instance.getImportManager().makeAndRunIfNone(engine, ()->{ 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); importer.importRegionDirectoryAsync(directory);
return importer; return importer;
}); });
@@ -123,7 +121,7 @@ public class VoxyCommands {
private static int importRaw(CommandContext<FabricClientCommandSource> ctx) { private static int importRaw(CommandContext<FabricClientCommandSource> ctx) {
if (VoxyCommon.getInstance() == null) { 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; return 1;
} }
@@ -132,7 +130,7 @@ public class VoxyCommands {
private static int importBobby(CommandContext<FabricClientCommandSource> ctx) { private static int importBobby(CommandContext<FabricClientCommandSource> ctx) {
if (VoxyCommon.getInstance() == null) { 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; return 1;
} }
@@ -141,10 +139,10 @@ public class VoxyCommands {
} }
private static CompletableFuture<Suggestions> importWorldSuggester(CommandContext<FabricClientCommandSource> ctx, SuggestionsBuilder sb) { private static CompletableFuture<Suggestions> importWorldSuggester(CommandContext<FabricClientCommandSource> ctx, SuggestionsBuilder sb) {
return fileDirectorySuggester(MinecraftClient.getInstance().runDirectory.toPath().resolve("saves"), sb); return fileDirectorySuggester(Minecraft.getInstance().gameDirectory.toPath().resolve("saves"), sb);
} }
private static CompletableFuture<Suggestions> importBobbySuggester(CommandContext<FabricClientCommandSource> ctx, SuggestionsBuilder sb) { private static CompletableFuture<Suggestions> importBobbySuggester(CommandContext<FabricClientCommandSource> ctx, SuggestionsBuilder sb) {
return fileDirectorySuggester(MinecraftClient.getInstance().runDirectory.toPath().resolve(".bobby"), sb); return fileDirectorySuggester(Minecraft.getInstance().gameDirectory.toPath().resolve(".bobby"), sb);
} }
private static CompletableFuture<Suggestions> fileDirectorySuggester(Path dir, SuggestionsBuilder sb) { private static CompletableFuture<Suggestions> fileDirectorySuggester(Path dir, SuggestionsBuilder sb) {
@@ -179,7 +177,7 @@ public class VoxyCommands {
if (wn.equals(remaining)) { if (wn.equals(remaining)) {
continue; continue;
} }
if (CommandSource.shouldSuggest(remaining, wn) || CommandSource.shouldSuggest(remaining, '"'+wn)) { if (SharedSuggestionProvider.matchesSubStr(remaining, wn) || SharedSuggestionProvider.matchesSubStr(remaining, '"'+wn)) {
wn = str+wn + "/"; wn = str+wn + "/";
sb.suggest(StringArgumentType.escapeIfRequired(wn)); sb.suggest(StringArgumentType.escapeIfRequired(wn));
} }
@@ -191,7 +189,7 @@ public class VoxyCommands {
private static int importWorld(CommandContext<FabricClientCommandSource> ctx) { private static int importWorld(CommandContext<FabricClientCommandSource> ctx) {
if (VoxyCommon.getInstance() == null) { 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; return 1;
} }
@@ -216,15 +214,15 @@ public class VoxyCommands {
var instance = (VoxyClientInstance)VoxyCommon.getInstance(); var instance = (VoxyClientInstance)VoxyCommon.getInstance();
if (instance == null) { 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; return 1;
} }
String finalInnerDir = innerDir; String finalInnerDir = innerDir;
var engine = WorldIdentifier.ofEngine(MinecraftClient.getInstance().world); var engine = WorldIdentifier.ofEngine(Minecraft.getInstance().level);
if (engine != null) { if (engine != null) {
return instance.getImportManager().makeAndRunIfNone(engine, () -> { 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); importer.importZippedRegionDirectoryAsync(zip, finalInnerDir);
return importer; return importer;
}) ? 0 : 1; }) ? 0 : 1;
@@ -235,10 +233,10 @@ public class VoxyCommands {
private static int cancelImport(CommandContext<FabricClientCommandSource> ctx) { private static int cancelImport(CommandContext<FabricClientCommandSource> ctx) {
var instance = (VoxyClientInstance)VoxyCommon.getInstance(); var instance = (VoxyClientInstance)VoxyCommon.getInstance();
if (instance == null) { 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; return 1;
} }
var world = WorldIdentifier.ofEngineNullable(MinecraftClient.getInstance().world); var world = WorldIdentifier.ofEngineNullable(Minecraft.getInstance().level);
if (world != null) { if (world != null) {
return instance.getImportManager().cancelImport(world)?0:1; return instance.getImportManager().cancelImport(world)?0:1;
} }

View File

@@ -3,47 +3,46 @@ package me.cortex.voxy.client;
import me.cortex.voxy.client.core.IGetVoxyRenderSystem; import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
import me.cortex.voxy.client.core.VoxyRenderSystem; import me.cortex.voxy.client.core.VoxyRenderSystem;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import net.minecraft.client.MinecraftClient; import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.hud.debug.DebugHudEntry; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.hud.debug.DebugHudLines; import net.minecraft.client.gui.components.debug.DebugScreenDisplayer;
import net.minecraft.util.Colors; import net.minecraft.client.gui.components.debug.DebugScreenEntry;
import net.minecraft.util.Formatting; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Identifier; import net.minecraft.world.level.Level;
import net.minecraft.world.World; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.chunk.WorldChunk;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class VoxyDebugScreenEntry implements DebugHudEntry { public class VoxyDebugScreenEntry implements DebugScreenEntry {
@Override @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()) { 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; return;
} }
var instance = VoxyCommon.getInstance(); var instance = VoxyCommon.getInstance();
if (instance == null) { 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; return;
} }
VoxyRenderSystem vrs = null; VoxyRenderSystem vrs = null;
var wr = MinecraftClient.getInstance().worldRenderer; var wr = Minecraft.getInstance().levelRenderer;
if (wr != null) vrs = ((IGetVoxyRenderSystem) wr).getVoxyRenderSystem(); if (wr != null) vrs = ((IGetVoxyRenderSystem) wr).getVoxyRenderSystem();
//Voxy instance active //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(); //lines.addLineToSection();
List<String> instanceLines = new ArrayList<>(); List<String> instanceLines = new ArrayList<>();
instance.addDebug(instanceLines); instance.addDebug(instanceLines);
lines.addLinesToSection(Identifier.of("voxy", "instance_debug"), instanceLines); lines.addToGroup(ResourceLocation.fromNamespaceAndPath("voxy", "instance_debug"), instanceLines);
if (vrs != null) { if (vrs != null) {
List<String> renderLines = new ArrayList<>(); List<String> renderLines = new ArrayList<>();
vrs.addDebugInfo(renderLines); vrs.addDebugInfo(renderLines);
lines.addLinesToSection(Identifier.of("voxy", "render_debug"), renderLines); lines.addToGroup(ResourceLocation.fromNamespaceAndPath("voxy", "render_debug"), renderLines);
} }
} }

View File

@@ -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.SliderControl;
import net.caffeinemc.mods.sodium.client.gui.options.control.TickBoxControl; import net.caffeinemc.mods.sodium.client.gui.options.control.TickBoxControl;
import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -29,21 +28,21 @@ public abstract class VoxyConfigScreenPages {
//General //General
groups.add(OptionGroup.createBuilder() groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, storage) .add(OptionImpl.createBuilder(boolean.class, storage)
.setName(Text.translatable("voxy.config.general.enabled")) .setName(Component.translatable("voxy.config.general.enabled"))
.setTooltip(Text.translatable("voxy.config.general.enabled.tooltip")) .setTooltip(Component.translatable("voxy.config.general.enabled.tooltip"))
.setControl(TickBoxControl::new) .setControl(TickBoxControl::new)
.setBinding((s, v)->{ .setBinding((s, v)->{
s.enabled = v; s.enabled = v;
if (v) { if (v) {
if (VoxyClientInstance.isInGame) { if (VoxyClientInstance.isInGame) {
VoxyCommon.createInstance(); VoxyCommon.createInstance();
var vrsh = (IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer; var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer;
if (vrsh != null && s.enableRendering) { if (vrsh != null && s.enableRendering) {
vrsh.createRenderer(); vrsh.createRenderer();
} }
} }
} else { } else {
var vrsh = (IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer; var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer;
if (vrsh != null) { if (vrsh != null) {
vrsh.shutdownRenderer(); vrsh.shutdownRenderer();
} }
@@ -57,12 +56,12 @@ public abstract class VoxyConfigScreenPages {
groups.add(OptionGroup.createBuilder() groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(int.class, storage) .add(OptionImpl.createBuilder(int.class, storage)
.setName(Text.translatable("voxy.config.general.serviceThreads")) .setName(Component.translatable("voxy.config.general.serviceThreads"))
.setTooltip(Text.translatable("voxy.config.general.serviceThreads.tooltip")) .setTooltip(Component.translatable("voxy.config.general.serviceThreads.tooltip"))
.setControl(opt->new SliderControl(opt, 1, .setControl(opt->new SliderControl(opt, 1,
CpuLayout.CORES.length, //Just do core size as max 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 //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)->{ .setBinding((s, v)->{
s.serviceThreads = v; s.serviceThreads = v;
var instance = VoxyCommon.getInstance(); var instance = VoxyCommon.getInstance();
@@ -83,8 +82,8 @@ public abstract class VoxyConfigScreenPages {
.setImpact(OptionImpact.HIGH) .setImpact(OptionImpact.HIGH)
.build() .build()
).add(OptionImpl.createBuilder(boolean.class, storage) ).add(OptionImpl.createBuilder(boolean.class, storage)
.setName(Text.translatable("voxy.config.general.ingest")) .setName(Component.translatable("voxy.config.general.ingest"))
.setTooltip(Text.translatable("voxy.config.general.ingest.tooltip")) .setTooltip(Component.translatable("voxy.config.general.ingest.tooltip"))
.setControl(TickBoxControl::new) .setControl(TickBoxControl::new)
.setBinding((s, v) -> s.ingestEnabled = v, s -> s.ingestEnabled) .setBinding((s, v) -> s.ingestEnabled = v, s -> s.ingestEnabled)
.setImpact(OptionImpact.MEDIUM) .setImpact(OptionImpact.MEDIUM)
@@ -94,12 +93,12 @@ public abstract class VoxyConfigScreenPages {
groups.add(OptionGroup.createBuilder() groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, storage) .add(OptionImpl.createBuilder(boolean.class, storage)
.setName(Text.translatable("voxy.config.general.rendering")) .setName(Component.translatable("voxy.config.general.rendering"))
.setTooltip(Text.translatable("voxy.config.general.rendering.tooltip")) .setTooltip(Component.translatable("voxy.config.general.rendering.tooltip"))
.setControl(TickBoxControl::new) .setControl(TickBoxControl::new)
.setBinding((s, v)->{ .setBinding((s, v)->{
s.enableRendering = v; s.enableRendering = v;
var vrsh = (IGetVoxyRenderSystem)MinecraftClient.getInstance().worldRenderer; var vrsh = (IGetVoxyRenderSystem)Minecraft.getInstance().levelRenderer;
if (vrsh != null) { if (vrsh != null) {
if (v) { if (v) {
vrsh.createRenderer(); vrsh.createRenderer();
@@ -111,19 +110,19 @@ public abstract class VoxyConfigScreenPages {
.setImpact(OptionImpact.HIGH) .setImpact(OptionImpact.HIGH)
.build() .build()
).add(OptionImpl.createBuilder(int.class, storage) ).add(OptionImpl.createBuilder(int.class, storage)
.setName(Text.translatable("voxy.config.general.subDivisionSize")) .setName(Component.translatable("voxy.config.general.subDivisionSize"))
.setTooltip(Text.translatable("voxy.config.general.subDivisionSize.tooltip")) .setTooltip(Component.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)))))) .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)) .setBinding((s, v) -> s.subDivisionSize = ln2subDiv(v), s -> subDiv2ln(s.subDivisionSize))
.setImpact(OptionImpact.HIGH) .setImpact(OptionImpact.HIGH)
.build() .build()
).add(OptionImpl.createBuilder(int.class, storage) ).add(OptionImpl.createBuilder(int.class, storage)
.setName(Text.translatable("voxy.config.general.renderDistance")) .setName(Component.translatable("voxy.config.general.renderDistance"))
.setTooltip(Text.translatable("voxy.config.general.renderDistance.tooltip")) .setTooltip(Component.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 .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)-> { .setBinding((s, v)-> {
s.sectionRenderDistance = v; s.sectionRenderDistance = v;
var vrsh = (IGetVoxyRenderSystem)MinecraftClient.getInstance().worldRenderer; var vrsh = (IGetVoxyRenderSystem)Minecraft.getInstance().levelRenderer;
if (vrsh != null) { if (vrsh != null) {
var vrs = vrsh.getVoxyRenderSystem(); var vrs = vrsh.getVoxyRenderSystem();
if (vrs != null) { if (vrs != null) {
@@ -134,29 +133,29 @@ public abstract class VoxyConfigScreenPages {
.setImpact(OptionImpact.LOW) .setImpact(OptionImpact.LOW)
.build() .build()
).add(OptionImpl.createBuilder(boolean.class, storage) ).add(OptionImpl.createBuilder(boolean.class, storage)
.setName(Text.translatable("voxy.config.general.environmental_fog")) .setName(Component.translatable("voxy.config.general.environmental_fog"))
.setTooltip(Text.translatable("voxy.config.general.environmental_fog.tooltip")) .setTooltip(Component.translatable("voxy.config.general.environmental_fog.tooltip"))
.setControl(TickBoxControl::new) .setControl(TickBoxControl::new)
.setImpact(OptionImpact.VARIES) .setImpact(OptionImpact.VARIES)
.setBinding((s, v)-> s.useEnvironmentalFog = v, s -> s.useEnvironmentalFog) .setBinding((s, v)-> s.useEnvironmentalFog = v, s -> s.useEnvironmentalFog)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
.build() .build()
).add(OptionImpl.createBuilder(boolean.class, storage) ).add(OptionImpl.createBuilder(boolean.class, storage)
.setName(Text.translatable("voxy.config.general.vanilla_fog")) .setName(Component.translatable("voxy.config.general.vanilla_fog"))
.setTooltip(Text.translatable("voxy.config.general.vanilla_fog.tooltip")) .setTooltip(Component.translatable("voxy.config.general.vanilla_fog.tooltip"))
.setControl(TickBoxControl::new) .setControl(TickBoxControl::new)
.setBinding((s, v)-> s.renderVanillaFog = v, s -> s.renderVanillaFog) .setBinding((s, v)-> s.renderVanillaFog = v, s -> s.renderVanillaFog)
.build() .build()
).add(OptionImpl.createBuilder(boolean.class, storage) ).add(OptionImpl.createBuilder(boolean.class, storage)
.setName(Text.translatable("voxy.config.general.render_statistics")) .setName(Component.translatable("voxy.config.general.render_statistics"))
.setTooltip(Text.translatable("voxy.config.general.render_statistics.tooltip")) .setTooltip(Component.translatable("voxy.config.general.render_statistics.tooltip"))
.setControl(TickBoxControl::new) .setControl(TickBoxControl::new)
.setBinding((s, v)-> RenderStatistics.enabled = v, s -> RenderStatistics.enabled) .setBinding((s, v)-> RenderStatistics.enabled = v, s -> RenderStatistics.enabled)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
.build() .build()
).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; private static final int SUBDIV_IN_MAX = 100;

View File

@@ -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.hierachical.NodeCleaner;
import me.cortex.voxy.client.core.rendering.post.FullscreenBlit; import me.cortex.voxy.client.core.rendering.post.FullscreenBlit;
import me.cortex.voxy.client.core.rendering.util.DepthFramebuffer; 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.joml.Matrix4f;
import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryStack;
@@ -109,7 +109,7 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
float start = viewport.fogParameters.environmentalStart(); float start = viewport.fogParameters.environmentalStart();
float end = viewport.fogParameters.environmentalEnd(); float end = viewport.fogParameters.environmentalEnd();
float invEndFogDelta = 1f/(end-start); 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(4, endDistance, invEndFogDelta, Math.abs(start)*invEndFogDelta);
glUniform3f(5, viewport.fogParameters.red(), viewport.fogParameters.green(), viewport.fogParameters.blue()); glUniform3f(5, viewport.fogParameters.red(), viewport.fogParameters.green(), viewport.fogParameters.blue());
} }

View File

@@ -33,7 +33,7 @@ import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices; import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices;
import net.caffeinemc.mods.sodium.client.util.FogParameters; 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.Matrix4f;
import org.joml.Matrix4fc; import org.joml.Matrix4fc;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -119,8 +119,8 @@ public class VoxyRenderSystem {
this.viewportSelector = new ViewportSelector<>(sectionRenderer::createViewport); this.viewportSelector = new ViewportSelector<>(sectionRenderer::createViewport);
{ {
int minSec = MinecraftClient.getInstance().world.getBottomSectionCoord() >> 5; int minSec = Minecraft.getInstance().level.getMinSectionY() >> 5;
int maxSec = (MinecraftClient.getInstance().world.getTopSectionCoord() - 1) >> 5; int maxSec = (Minecraft.getInstance().level.getMaxSectionY() - 1) >> 5;
//Do some very cheeky stuff for MiB //Do some very cheeky stuff for MiB
if (VoxyCommon.IS_MINE_IN_ABYSS) {//TODO: make this somehow configurable if (VoxyCommon.IS_MINE_IN_ABYSS) {//TODO: make this somehow configurable
@@ -341,12 +341,12 @@ public class VoxyRenderSystem {
float INCREASE_PER_SECOND = 60; float INCREASE_PER_SECOND = 60;
float DECREASE_PER_SECOND = 30; float DECREASE_PER_SECOND = 30;
//Auto fps targeting //Auto fps targeting
if (MinecraftClient.getInstance().getCurrentFps() < MIN_FPS) { if (Minecraft.getInstance().getFps() < MIN_FPS) {
VoxyConfig.CONFIG.subDivisionSize = Math.min(VoxyConfig.CONFIG.subDivisionSize + INCREASE_PER_SECOND / Math.max(1f, MinecraftClient.getInstance().getCurrentFps()), 256); 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) { if (MAX_FPS < Minecraft.getInstance().getFps() && canDecreaseSize) {
VoxyConfig.CONFIG.subDivisionSize = Math.max(VoxyConfig.CONFIG.subDivisionSize - DECREASE_PER_SECOND / Math.max(1f, MinecraftClient.getInstance().getCurrentFps()), 28); 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 //TODO: use the existing projection matrix use mulLocal by the inverse of the projection and then mulLocal our projection
var projection = new Matrix4f(); var projection = new Matrix4f();
var client = MinecraftClient.getInstance(); var client = Minecraft.getInstance();
var gameRenderer = client.gameRenderer;//tickCounter.getTickDelta(true); 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, projection.setPerspective(fov * 0.01745329238474369f,
(float) client.getWindow().getFramebufferWidth() / (float)client.getWindow().getFramebufferHeight(), (float) client.getWindow().getWidth() / (float)client.getWindow().getHeight(),
near, far); near, far);
return projection; return projection;
} }
@@ -368,7 +368,7 @@ public class VoxyRenderSystem {
//TODO: Make a reverse z buffer //TODO: Make a reverse z buffer
private static Matrix4f computeProjectionMat(Matrix4fc base) { private static Matrix4f computeProjectionMat(Matrix4fc base) {
return base.mulLocal( return base.mulLocal(
makeProjectionMatrix(0.05f, MinecraftClient.getInstance().gameRenderer.getFarPlaneDistance()).invert(), makeProjectionMatrix(0.05f, Minecraft.getInstance().gameRenderer.getDepthFar()).invert(),
new Matrix4f() new Matrix4f()
).mulLocal(makeProjectionMatrix(16, 16*3000)); ).mulLocal(makeProjectionMatrix(16, 16*3000));
} }

View File

@@ -4,10 +4,6 @@ package me.cortex.voxy.client.core.model;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.world.other.Mapper; 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.List;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;

View File

@@ -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.client.core.rendering.util.UploadStream;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.util.MemoryBuffer; import me.cortex.voxy.common.util.MemoryBuffer;
import me.cortex.voxy.common.util.Pair;
import me.cortex.voxy.common.world.other.Mapper; import me.cortex.voxy.common.world.other.Mapper;
import net.minecraft.block.Block; import net.minecraft.client.Minecraft;
import net.minecraft.block.BlockState; import net.minecraft.client.color.block.BlockColor;
import net.minecraft.block.FluidBlock; import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.block.LeavesBlock; import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.core.BlockPos;
import net.minecraft.client.MinecraftClient; import net.minecraft.core.Direction;
import net.minecraft.client.color.block.BlockColorProvider; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.client.render.BlockRenderLayer; import net.minecraft.core.registries.Registries;
import net.minecraft.client.render.RenderLayers; import net.minecraft.resources.ResourceLocation;
import net.minecraft.fluid.FluidState; import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.registry.Registries; import net.minecraft.world.level.ColorResolver;
import net.minecraft.registry.RegistryKeys; import net.minecraft.world.level.LightLayer;
import net.minecraft.util.Identifier; import net.minecraft.world.level.biome.Biome;
import net.minecraft.util.Pair; import net.minecraft.world.level.biome.Biomes;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.Block;
import net.minecraft.util.math.Direction; import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.BlockRenderView; import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.LightType; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.biome.Biome; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.level.lighting.LevelLightEngine;
import net.minecraft.world.biome.ColorResolver; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.chunk.light.LightingProvider;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.lwjgl.system.MemoryUtil; 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; 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 //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 // 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())) { if ((!isFluid) && (!blockState.getFluidState().isEmpty())) {
//Insert into the fluid LUT //Insert into the fluid LUT
var fluidState = blockState.getFluidState().getBlockState(); var fluidState = blockState.getFluidState().createLegacyBlock();
int fluidStateId = this.mapper.getIdForBlockState(fluidState); int fluidStateId = this.mapper.getIdForBlockState(fluidState);
@@ -247,8 +247,8 @@ public class ModelFactory {
public void processAllThings() { public void processAllThings() {
var biomeEntry = this.biomeQueue.poll(); var biomeEntry = this.biomeQueue.poll();
while (biomeEntry != null) { while (biomeEntry != null) {
var biomeRegistry = MinecraftClient.getInstance().world.getRegistryManager().getOrThrow(RegistryKeys.BIOME); var biomeRegistry = Minecraft.getInstance().level.registryAccess().lookupOrThrow(Registries.BIOME);
var res = this.addBiome0(biomeEntry.id, biomeRegistry.get(Identifier.of(biomeEntry.biome))); var res = this.addBiome0(biomeEntry.id, biomeRegistry.getValue(ResourceLocation.parse(biomeEntry.biome)));
if (res != null) { if (res != null) {
this.uploadResults.add(res); this.uploadResults.add(res);
} }
@@ -339,7 +339,7 @@ public class ModelFactory {
//TODO: add thing for `blockState.hasEmissiveLighting()` and `blockState.getLuminance()` //TODO: add thing for `blockState.hasEmissiveLighting()` and `blockState.getLuminance()`
boolean isFluid = blockState.getBlock() instanceof FluidBlock; boolean isFluid = blockState.getBlock() instanceof LiquidBlock;
int modelId = -1; int modelId = -1;
@@ -347,7 +347,7 @@ public class ModelFactory {
if ((!isFluid) && (!blockState.getFluidState().isEmpty())) { if ((!isFluid) && (!blockState.getFluidState().isEmpty())) {
//Insert into the fluid LUT //Insert into the fluid LUT
var fluidState = blockState.getFluidState().getBlockState(); var fluidState = blockState.getFluidState().createLegacyBlock();
int fluidStateId = this.mapper.getIdForBlockState(fluidState); int fluidStateId = this.mapper.getIdForBlockState(fluidState);
@@ -385,19 +385,19 @@ public class ModelFactory {
this.fluidStateLUT[modelId] = clientFluidStateId; this.fluidStateLUT[modelId] = clientFluidStateId;
} }
BlockRenderLayer blockRenderLayer = null; ChunkSectionLayer blockRenderLayer = null;
if (blockState.getBlock() instanceof FluidBlock) { if (blockState.getBlock() instanceof LiquidBlock) {
blockRenderLayer = RenderLayers.getFluidLayer(blockState.getFluidState()); blockRenderLayer = ItemBlockRenderTypes.getRenderLayer(blockState.getFluidState());
} else { } else {
if (blockState.getBlock() instanceof LeavesBlock) { if (blockState.getBlock() instanceof LeavesBlock) {
blockRenderLayer = BlockRenderLayer.SOLID; blockRenderLayer = ChunkSectionLayer.SOLID;
} else { } 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()); var colourProvider = getColourProvider(blockState.getBlock());
@@ -441,7 +441,7 @@ public class ModelFactory {
boolean allFalse = true; boolean allFalse = true;
//Guestimation test for if the block culls itself //Guestimation test for if the block culls itself
for (var dir : Direction.values()) { for (var dir : Direction.values()) {
if (blockState.isSideInvisible(blockState, dir)) { if (blockState.skipRendering(blockState, dir)) {
allFalse = false; allFalse = false;
} else { } else {
allTrue = false; allTrue = false;
@@ -463,7 +463,7 @@ public class ModelFactory {
//Each face gets 1 byte, with the top 2 bytes being for whatever //Each face gets 1 byte, with the top 2 bytes being for whatever
long metadata = 0; long metadata = 0;
metadata |= isBiomeColourDependent?1:0; metadata |= isBiomeColourDependent?1:0;
metadata |= blockRenderLayer == BlockRenderLayer.TRANSLUCENT?2:0; metadata |= blockRenderLayer == ChunkSectionLayer.TRANSLUCENT?2:0;
metadata |= needsDoubleSidedQuads?4: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) && !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 metadata |= isFluid?16:0;//Is a fluid
@@ -499,7 +499,7 @@ public class ModelFactory {
//TODO: add alot of config options for the following //TODO: add alot of config options for the following
boolean occludesFace = true; 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 //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 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; metadata |= canBeOccluded?4:0;
//Face uses its own lighting if its not flat against the adjacent block & isnt traslucent //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); 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 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 != ChunkSectionLayer.SOLID;
needsAlphaDiscard &= blockRenderLayer != BlockRenderLayer.TRANSLUCENT;//Translucent doesnt have alpha discard needsAlphaDiscard &= blockRenderLayer != ChunkSectionLayer.TRANSLUCENT;//Translucent doesnt have alpha discard
faceModelData |= needsAlphaDiscard?1<<22:0; 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 //Bits 24,25 are tint metadata
if (colourProvider!=null) {//We have a tint if (colourProvider!=null) {//We have a tint
@@ -574,8 +574,8 @@ public class ModelFactory {
int modelFlags = 0; int modelFlags = 0;
modelFlags |= colourProvider != null?1: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 |= 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 == ChunkSectionLayer.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.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 //modelFlags |= blockRenderLayer == RenderLayer.getSolid()?0:1;// should discard alpha
MemoryUtil.memPutInt(uploadPtr, modelFlags); uploadPtr += 4; MemoryUtil.memPutInt(uploadPtr, modelFlags); uploadPtr += 4;
@@ -687,51 +687,51 @@ public class ModelFactory {
int i = 0; int i = 0;
long modelUpPtr = result.modelBiomeIndexPairs.address; long modelUpPtr = result.modelBiomeIndexPairs.address;
for (var entry : this.modelsRequiringBiomeColours) { for (var entry : this.modelsRequiringBiomeColours) {
var colourProvider = getColourProvider(entry.getRight().getBlock()); var colourProvider = getColourProvider(entry.right().getBlock());
if (colourProvider == null) { if (colourProvider == null) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
//Populate the list of biomes for the model state //Populate the list of biomes for the model state
int biomeIndex = (i++) * this.biomes.size(); 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; long clrUploadPtr = result.biomeColourBuffer.address + biomeIndex * 4L;
for (var biomeE : this.biomes) { for (var biomeE : this.biomes) {
if (biomeE == null) { if (biomeE == null) {
continue;//If null, ignore 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; return result;
} }
private static BlockColorProvider getColourProvider(Block block) { private static BlockColor getColourProvider(Block block) {
return MinecraftClient.getInstance().getBlockColors().providers.get(Registries.BLOCK.getRawId(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) //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 // 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 // will either use the uint as an index or a direct colour multiplier
private static int captureColourConstant(BlockColorProvider colorProvider, BlockState state, Biome biome) { private static int captureColourConstant(BlockColor colorProvider, BlockState state, Biome biome) {
return colorProvider.getColor(state, new BlockRenderView() { return colorProvider.getColor(state, new BlockAndTintGetter() {
@Override @Override
public float getBrightness(Direction direction, boolean shaded) { public float getShade(Direction direction, boolean shaded) {
return 0; return 0;
} }
@Override @Override
public int getLightLevel(LightType type, BlockPos pos) { public int getBrightness(LightLayer type, BlockPos pos) {
return 0; return 0;
} }
@Override @Override
public LightingProvider getLightingProvider() { public LevelLightEngine getLightEngine() {
return null; return null;
} }
@Override @Override
public int getColor(BlockPos pos, ColorResolver colorResolver) { public int getBlockTint(BlockPos pos, ColorResolver colorResolver) {
return colorResolver.getColor(biome, 0, 0); return colorResolver.getColor(biome, 0, 0);
} }
@@ -757,32 +757,32 @@ public class ModelFactory {
} }
@Override @Override
public int getBottomY() { public int getMinY() {
return 0; 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]; boolean[] biomeDependent = new boolean[1];
colorProvider.getColor(state, new BlockRenderView() { colorProvider.getColor(state, new BlockAndTintGetter() {
@Override @Override
public float getBrightness(Direction direction, boolean shaded) { public float getShade(Direction direction, boolean shaded) {
return 0; return 0;
} }
@Override @Override
public int getLightLevel(LightType type, BlockPos pos) { public int getBrightness(LightLayer type, BlockPos pos) {
return 0; return 0;
} }
@Override @Override
public LightingProvider getLightingProvider() { public LevelLightEngine getLightEngine() {
return null; return null;
} }
@Override @Override
public int getColor(BlockPos pos, ColorResolver colorResolver) { public int getBlockTint(BlockPos pos, ColorResolver colorResolver) {
biomeDependent[0] = true; biomeDependent[0] = true;
return 0; return 0;
} }
@@ -809,17 +809,17 @@ public class ModelFactory {
} }
@Override @Override
public int getBottomY() { public int getMinY() {
return 0; return 0;
} }
}, BlockPos.ORIGIN, 0); }, BlockPos.ZERO, 0);
return biomeDependent[0]; return biomeDependent[0];
} }
private static float[] computeModelDepth(ColourDepthTextureData[] textures, int checkMode) { private static float[] computeModelDepth(ColourDepthTextureData[] textures, int checkMode) {
float[] res = new float[6]; float[] res = new float[6];
for (var dir : Direction.values()) { 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 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); //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 //If fd is -1, it means that there was nothing rendered on that face and it should be discarded

View File

@@ -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.GlBuffer;
import me.cortex.voxy.client.core.gl.GlTexture; import me.cortex.voxy.client.core.gl.GlTexture;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.util.Identifier; import net.minecraft.resources.ResourceLocation;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11C.GL_NEAREST; 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 //Limit the mips of the texture to match that of the terrain atlas
int mipLvl = ((SpriteAtlasTexture) MinecraftClient.getInstance().getTextureManager() int mipLvl = ((TextureAtlas) Minecraft.getInstance().getTextureManager()
.getTexture(Identifier.of("minecraft", "textures/atlas/blocks.png"))) .getTexture(ResourceLocation.fromNamespaceAndPath("minecraft", "textures/atlas/blocks.png")))
.mipLevel; .mipLevel;
glSamplerParameteri(this.blockSampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); glSamplerParameteri(this.blockSampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);

View File

@@ -1,7 +1,7 @@
package me.cortex.voxy.client.core.model; package me.cortex.voxy.client.core.model;
import net.caffeinemc.mods.sodium.client.util.color.ColorSRGB; 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 //Texturing utils to manipulate data from the model bakery
public class TextureUtils { public class TextureUtils {
@@ -209,7 +209,7 @@ public class TextureUtils {
public static int mipColours(int one, int two, int three, int four) { public static int mipColours(int one, int two, int three, int four) {
if (true) { if (true) {
return MipmapHelper.blend(one, two, three, four, false); return MipmapGenerator.alphaBlend(one, two, three, four, false);
} else { } else {
return weightedAverageColor(weightedAverageColor(one, two), weightedAverageColor(three, four)); return weightedAverageColor(weightedAverageColor(one, two), weightedAverageColor(three, four));
} }

View File

@@ -1,32 +1,13 @@
package me.cortex.voxy.client.core.model.bakery; package me.cortex.voxy.client.core.model.bakery;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import net.minecraft.block.BlockEntityProvider; import net.minecraft.client.Minecraft;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.model.Model; import net.minecraft.client.model.Model;
import net.minecraft.client.model.ModelPart; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.RenderLayer; import net.minecraft.core.BlockPos;
import net.minecraft.client.render.block.MovingBlockRenderState; import net.minecraft.resources.ResourceLocation;
import net.minecraft.client.render.command.ModelCommandRenderer; import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.client.render.command.OrderedRenderCommandQueue; import net.minecraft.world.level.block.state.BlockState;
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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Quaternionf; import org.joml.Quaternionf;
@@ -37,7 +18,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class BakedBlockEntityModel { public class BakedBlockEntityModel {
private record LayerConsumer(RenderLayer layer, ReuseVertexConsumer consumer) {} private record LayerConsumer(RenderType layer, ReuseVertexConsumer consumer) {}
private final List<LayerConsumer> layers; private final List<LayerConsumer> layers;
private BakedBlockEntityModel(List<LayerConsumer> layers) { private BakedBlockEntityModel(List<LayerConsumer> layers) {
this.layers = layers; this.layers = layers;
@@ -46,12 +27,12 @@ public class BakedBlockEntityModel {
public void render(Matrix4f matrix, int texId) { public void render(Matrix4f matrix, int texId) {
for (var layer : this.layers) { for (var layer : this.layers) {
if (layer.consumer.isEmpty()) continue; if (layer.consumer.isEmpty()) continue;
if (layer.layer instanceof RenderLayer.MultiPhase mp) { if (layer.layer instanceof RenderType.CompositeRenderType mp) {
Identifier textureId = mp.phases.texture.getId().orElse(null); ResourceLocation textureId = mp.state.textureState.cutoutTexture().orElse(null);
if (textureId == null) { if (textureId == null) {
Logger.error("ERROR: Empty texture id for layer: " + layer); Logger.error("ERROR: Empty texture id for layer: " + layer);
} else { } 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; if (texId == 0) continue;
@@ -64,15 +45,15 @@ public class BakedBlockEntityModel {
this.layers.forEach(layer->layer.consumer.free()); this.layers.forEach(layer->layer.consumer.free());
} }
private static int getMetaFromLayer(RenderLayer layer) { private static int getMetaFromLayer(RenderType layer) {
boolean hasDiscard = layer == RenderLayer.getCutout() || boolean hasDiscard = layer == RenderType.cutout() ||
layer == RenderLayer.getCutoutMipped() || layer == RenderType.cutoutMipped() ||
layer == RenderLayer.getTripwire(); layer == RenderType.tripwire();
boolean isMipped = layer == RenderLayer.getCutoutMipped() || boolean isMipped = layer == RenderType.cutoutMipped() ||
layer == RenderLayer.getSolid() || layer == RenderType.solid() ||
layer.isTranslucent() || layer.sortOnUpload() ||
layer == RenderLayer.getTripwire(); layer == RenderType.tripwire();
int meta = hasDiscard?1:0; int meta = hasDiscard?1:0;
meta |= isMipped?2:0; meta |= isMipped?2:0;
@@ -80,13 +61,13 @@ public class BakedBlockEntityModel {
} }
public static BakedBlockEntityModel bake(BlockState state) { public static BakedBlockEntityModel bake(BlockState state) {
Map<RenderLayer, LayerConsumer> map = new HashMap<>(); Map<RenderType, LayerConsumer> map = new HashMap<>();
var entity = ((BlockEntityProvider)state.getBlock()).createBlockEntity(BlockPos.ORIGIN, state); var entity = ((EntityBlock)state.getBlock()).newBlockEntity(BlockPos.ZERO, state);
if (entity == null) { if (entity == null) {
return null; return null;
} }
var renderer = MinecraftClient.getInstance().getBlockEntityRenderDispatcher().get(entity); var renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(entity);
entity.setWorld(MinecraftClient.getInstance().world); entity.setLevel(Minecraft.getInstance().level);
if (renderer != null) { if (renderer != null) {
try { try {
/* /*
@@ -104,7 +85,7 @@ public class BakedBlockEntityModel {
Logger.error("Unable to bake block entity: " + entity, e); Logger.error("Unable to bake block entity: " + entity, e);
} }
} }
entity.markRemoved(); entity.setRemoved();
if (map.isEmpty()) { if (map.isEmpty()) {
return null; return null;
} }

View File

@@ -2,14 +2,13 @@ package me.cortex.voxy.client.core.model.bakery;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.textures.GpuTexture; import com.mojang.blaze3d.textures.GpuTexture;
import com.mojang.blaze3d.vertex.MeshData;
import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.blaze3d.vertex.VertexFormat;
import me.cortex.voxy.client.core.gl.GlBuffer; import me.cortex.voxy.client.core.gl.GlBuffer;
import me.cortex.voxy.client.core.gl.GlVertexArray; 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.Shader;
import me.cortex.voxy.client.core.gl.shader.ShaderType; import me.cortex.voxy.client.core.gl.shader.ShaderType;
import me.cortex.voxy.client.core.rendering.util.UploadStream; 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.joml.Matrix4f;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
@@ -29,9 +28,9 @@ public class BudgetBufferRenderer {
public static void init(){} public static void init(){}
private static final GlBuffer indexBuffer; private static final GlBuffer indexBuffer;
static { static {
var i = RenderSystem.getSequentialBuffer(VertexFormat.DrawMode.QUADS); var i = RenderSystem.getSequentialBuffer(VertexFormat.Mode.QUADS);
int id = ((GlGpuBuffer) i.getIndexBuffer(4096*3*2)).id; int id = ((com.mojang.blaze3d.opengl.GlBuffer) i.getBuffer(4096*3*2)).handle;
if (i.getIndexType() != VertexFormat.IndexType.SHORT) { if (i.type() != VertexFormat.IndexType.SHORT) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
indexBuffer = new GlBuffer(3*2*2*4096); indexBuffer = new GlBuffer(3*2*2*4096);
@@ -47,18 +46,18 @@ public class BudgetBufferRenderer {
private static GlBuffer immediateBuffer; private static GlBuffer immediateBuffer;
private static int quadCount; private static int quadCount;
public static void drawFast(BuiltBuffer buffer, GpuTexture tex, Matrix4f matrix) { public static void drawFast(MeshData buffer, GpuTexture tex, Matrix4f matrix) {
if (buffer.getDrawParameters().mode() != VertexFormat.DrawMode.QUADS) { if (buffer.drawState().mode() != VertexFormat.Mode.QUADS) {
throw new IllegalStateException("Fast only supports quads"); throw new IllegalStateException("Fast only supports quads");
} }
var buff = buffer.getBuffer(); var buff = buffer.vertexBuffer();
int size = buff.remaining(); int size = buff.remaining();
if (size%STRIDE != 0) throw new IllegalStateException(); if (size%STRIDE != 0) throw new IllegalStateException();
size /= STRIDE; size /= STRIDE;
if (size%4 != 0) throw new IllegalStateException(); if (size%4 != 0) throw new IllegalStateException();
size /= 4; 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(); buffer.close();
render(matrix); render(matrix);

View File

@@ -1,20 +1,23 @@
package me.cortex.voxy.client.core.model.bakery; package me.cortex.voxy.client.core.model.bakery;
import net.minecraft.block.*; import net.minecraft.client.Minecraft;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
import net.minecraft.client.render.BlockRenderLayer; import net.minecraft.core.BlockPos;
import net.minecraft.client.render.RenderLayers; import net.minecraft.core.Direction;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.resources.ResourceLocation;
import net.minecraft.fluid.FluidState; import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.util.Identifier; import net.minecraft.world.level.ColorResolver;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.LightLayer;
import net.minecraft.util.math.Direction; import net.minecraft.world.level.block.Blocks;
import net.minecraft.util.math.random.LocalRandom; import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.BlockRenderView; import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.LightType; import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.biome.ColorResolver; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.chunk.light.LightingProvider; 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.jetbrains.annotations.Nullable;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Quaternionf; 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.GL30.*;
import static org.lwjgl.opengl.GL45.glTextureBarrier; import static org.lwjgl.opengl.GL45.glTextureBarrier;
import com.mojang.blaze3d.vertex.PoseStack;
public class ModelTextureBakery { public class ModelTextureBakery {
//Note: the first bit of metadata is if alpha discard is enabled //Note: the first bit of metadata is if alpha discard is enabled
private static final Matrix4f[] VIEWS = new Matrix4f[6]; private static final Matrix4f[] VIEWS = new Matrix4f[6];
@@ -41,44 +46,44 @@ public class ModelTextureBakery {
this.height = height; this.height = height;
} }
public static int getMetaFromLayer(BlockRenderLayer layer) { public static int getMetaFromLayer(ChunkSectionLayer layer) {
boolean hasDiscard = layer == BlockRenderLayer.CUTOUT || boolean hasDiscard = layer == ChunkSectionLayer.CUTOUT ||
layer == BlockRenderLayer.CUTOUT_MIPPED || layer == ChunkSectionLayer.CUTOUT_MIPPED ||
layer == BlockRenderLayer.TRIPWIRE; layer == ChunkSectionLayer.TRIPWIRE;
boolean isMipped = layer == BlockRenderLayer.CUTOUT_MIPPED || boolean isMipped = layer == ChunkSectionLayer.CUTOUT_MIPPED ||
layer == BlockRenderLayer.SOLID || layer == ChunkSectionLayer.SOLID ||
layer == BlockRenderLayer.TRANSLUCENT || layer == ChunkSectionLayer.TRANSLUCENT ||
layer == BlockRenderLayer.TRIPWIRE; layer == ChunkSectionLayer.TRIPWIRE;
int meta = hasDiscard?1:0; int meta = hasDiscard?1:0;
meta |= isMipped?2:0; meta |= isMipped?2:0;
return meta; return meta;
} }
private void bakeBlockModel(BlockState state, BlockRenderLayer layer) { private void bakeBlockModel(BlockState state, ChunkSectionLayer layer) {
if (state.getRenderType() == BlockRenderType.INVISIBLE) { if (state.getRenderShape() == RenderShape.INVISIBLE) {
return;//Dont bake if invisible return;//Dont bake if invisible
} }
var model = MinecraftClient.getInstance() var model = Minecraft.getInstance()
.getBakedModelManager() .getModelManager()
.getBlockModels() .getBlockModelShaper()
.getModel(state); .getBlockModel(state);
int meta = getMetaFromLayer(layer); 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}) { for (Direction direction : new Direction[]{Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, null}) {
var quads = part.getQuads(direction); var quads = part.getQuads(direction);
for (var quad : quads) { 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? //TODO: somehow set the tint flag per quad or something?
int metadata = getMetaFromLayer(layer); int metadata = getMetaFromLayer(layer);
@@ -87,24 +92,24 @@ public class ModelTextureBakery {
metadata |= 4;//Has tint metadata |= 4;//Has tint
this.vc.setDefaultMeta(metadata);//Set the meta while baking 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 @Override
public float getBrightness(Direction direction, boolean shaded) { public float getShade(Direction direction, boolean shaded) {
return 0; return 0;
} }
@Override @Override
public LightingProvider getLightingProvider() { public LevelLightEngine getLightEngine() {
return null; return null;
} }
@Override @Override
public int getLightLevel(LightType type, BlockPos pos) { public int getBrightness(LightLayer type, BlockPos pos) {
return 0; return 0;
} }
@Override @Override
public int getColor(BlockPos pos, ColorResolver colorResolver) { public int getBlockTint(BlockPos pos, ColorResolver colorResolver) {
return 0; return 0;
} }
@@ -117,7 +122,7 @@ public class ModelTextureBakery {
@Override @Override
public BlockState getBlockState(BlockPos pos) { public BlockState getBlockState(BlockPos pos) {
if (shouldReturnAirForFluid(pos, face)) { if (shouldReturnAirForFluid(pos, face)) {
return Blocks.AIR.getDefaultState(); return Blocks.AIR.defaultBlockState();
} }
//Fixme: //Fixme:
@@ -135,7 +140,7 @@ public class ModelTextureBakery {
@Override @Override
public FluidState getFluidState(BlockPos pos) { public FluidState getFluidState(BlockPos pos) {
if (shouldReturnAirForFluid(pos, face)) { if (shouldReturnAirForFluid(pos, face)) {
return Blocks.AIR.getDefaultState().getFluidState(); return Blocks.AIR.defaultBlockState().getFluidState();
} }
return state.getFluidState(); return state.getFluidState();
@@ -147,7 +152,7 @@ public class ModelTextureBakery {
} }
@Override @Override
public int getBottomY() { public int getMinY() {
return 0; return 0;
} }
}, this.vc, state, state.getFluidState()); }, this.vc, state, state.getFluidState());
@@ -155,7 +160,7 @@ public class ModelTextureBakery {
} }
private static boolean shouldReturnAirForFluid(BlockPos pos, int face) { 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(); int dot = fv.getX()*pos.getX() + fv.getY()*pos.getY() + fv.getZ()*pos.getZ();
return dot >= 1; return dot >= 1;
} }
@@ -169,15 +174,15 @@ public class ModelTextureBakery {
public void renderToStream(BlockState state, int streamBuffer, int streamOffset) { public void renderToStream(BlockState state, int streamBuffer, int streamOffset) {
this.capture.clear(); this.capture.clear();
boolean isBlock = true; boolean isBlock = true;
BlockRenderLayer layer; ChunkSectionLayer layer;
if (state.getBlock() instanceof FluidBlock) { if (state.getBlock() instanceof LiquidBlock) {
layer = RenderLayers.getFluidLayer(state.getFluidState()); layer = ItemBlockRenderTypes.getRenderLayer(state.getFluidState());
isBlock = false; isBlock = false;
} else { } else {
if (state.getBlock() instanceof LeavesBlock) { if (state.getBlock() instanceof LeavesBlock) {
layer = BlockRenderLayer.SOLID; layer = ChunkSectionLayer.SOLID;
} else { } else {
layer = RenderLayers.getBlockLayer(state); layer = ItemBlockRenderTypes.getChunkRenderType(state);
} }
} }
@@ -195,7 +200,7 @@ public class ModelTextureBakery {
glEnable(GL_STENCIL_TEST); glEnable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
if (layer == BlockRenderLayer.TRANSLUCENT) { if (layer == ChunkSectionLayer.TRANSLUCENT) {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
} else { } else {
@@ -212,8 +217,8 @@ public class ModelTextureBakery {
//Bind the capture framebuffer //Bind the capture framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id); glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id);
var tex = MinecraftClient.getInstance().getTextureManager().getTexture(Identifier.of("minecraft", "textures/atlas/blocks.png")).getGlTexture(); var tex = Minecraft.getInstance().getTextureManager().getTexture(ResourceLocation.fromNamespaceAndPath("minecraft", "textures/atlas/blocks.png")).getTexture();
blockTextureId = ((net.minecraft.client.texture.GlTexture)tex).getGlId(); blockTextureId = ((com.mojang.blaze3d.opengl.GlTexture)tex).glId();
} }
//TODO: fastpath for blocks //TODO: fastpath for blocks
@@ -248,7 +253,7 @@ public class ModelTextureBakery {
glBindVertexArray(0); glBindVertexArray(0);
} else {//Is fluid, slow path :( } 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(); var mat = new Matrix4f();
for (int i = 0; i < VIEWS.length; i++) { for (int i = 0; i < VIEWS.length; i++) {
@@ -319,7 +324,7 @@ public class ModelTextureBakery {
glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id); glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id);
glClearDepth(1); glClearDepth(1);
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
if (layer == BlockRenderLayer.TRANSLUCENT) { if (layer == ChunkSectionLayer.TRANSLUCENT) {
//reset the blend func //reset the blend func
GL14.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 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) { 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.translate(0.5f,0.5f,0.5f);
stack.multiply(makeQuatFromAxisExact(new Vector3f(0,0,1), rotation)); stack.mulPose(makeQuatFromAxisExact(new Vector3f(0,0,1), rotation));
stack.multiply(makeQuatFromAxisExact(new Vector3f(1,0,0), pitch)); stack.mulPose(makeQuatFromAxisExact(new Vector3f(1,0,0), pitch));
stack.multiply(makeQuatFromAxisExact(new Vector3f(0,1,0), yaw)); stack.mulPose(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(new Matrix4f().scale(1-2*(flip&1), 1-(flip&2), 1-((flip>>1)&2)));
stack.translate(-0.5f,-0.5f,-0.5f); 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) { private static Quaternionf makeQuatFromAxisExact(Vector3f vec, float angle) {

View File

@@ -2,12 +2,13 @@ package me.cortex.voxy.client.core.model.bakery;
import me.cortex.voxy.common.util.MemoryBuffer; import me.cortex.voxy.common.util.MemoryBuffer;
import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.render.model.BakedQuad;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import static me.cortex.voxy.client.core.model.bakery.BudgetBufferRenderer.VERTEX_FORMAT_SIZE; 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 { public final class ReuseVertexConsumer implements VertexConsumer {
private MemoryBuffer buffer = new MemoryBuffer(8192); private MemoryBuffer buffer = new MemoryBuffer(8192);
private long ptr; private long ptr;
@@ -24,7 +25,7 @@ public final class ReuseVertexConsumer implements VertexConsumer {
} }
@Override @Override
public ReuseVertexConsumer vertex(float x, float y, float z) { public ReuseVertexConsumer addVertex(float x, float y, float z) {
this.ensureCanPut(); this.ensureCanPut();
this.ptr += VERTEX_FORMAT_SIZE; this.count++; //Goto next vertex this.ptr += VERTEX_FORMAT_SIZE; this.count++; //Goto next vertex
this.meta(this.defaultMeta); this.meta(this.defaultMeta);
@@ -40,43 +41,43 @@ public final class ReuseVertexConsumer implements VertexConsumer {
} }
@Override @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; return this;
} }
@Override @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 + 16, u);
MemoryUtil.memPutFloat(this.ptr + 20, v); MemoryUtil.memPutFloat(this.ptr + 20, v);
return this; return this;
} }
@Override @Override
public ReuseVertexConsumer overlay(int u, int v) { public ReuseVertexConsumer setUv1(int u, int v) {
return this; return this;
} }
@Override @Override
public ReuseVertexConsumer light(int u, int v) { public ReuseVertexConsumer setUv2(int u, int v) {
return this; return this;
} }
@Override @Override
public ReuseVertexConsumer normal(float x, float y, float z) { public ReuseVertexConsumer setNormal(float x, float y, float z) {
return this; return this;
} }
public ReuseVertexConsumer quad(BakedQuad quad, int metadata) { public ReuseVertexConsumer quad(BakedQuad quad, int metadata) {
this.ensureCanPut(); this.ensureCanPut();
int[] data = quad.vertexData(); int[] data = quad.vertices();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
float x = Float.intBitsToFloat(data[i * 8]); float x = Float.intBitsToFloat(data[i * 8]);
float y = Float.intBitsToFloat(data[i * 8 + 1]); float y = Float.intBitsToFloat(data[i * 8 + 1]);
float z = Float.intBitsToFloat(data[i * 8 + 2]); 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 u = Float.intBitsToFloat(data[i * 8 + 4]);
float v = Float.intBitsToFloat(data[i * 8 + 5]); float v = Float.intBitsToFloat(data[i * 8 + 5]);
this.texture(u,v); this.setUv(u,v);
this.meta(metadata); this.meta(metadata);
} }

View File

@@ -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.SharedIndexBuffer;
import me.cortex.voxy.client.core.rendering.util.UploadStream; import me.cortex.voxy.client.core.rendering.util.UploadStream;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.joml.Vector3i; import org.joml.Vector3i;
@@ -91,7 +90,7 @@ public class ChunkBoundRenderer {
long ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, 128); long ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, 128);
long matPtr = ptr; ptr += 4*4*4; 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 {//This is recomputed to be in chunk section space not worldsection
int sx = (int)(viewport.cameraX); int sx = (int)(viewport.cameraX);

View File

@@ -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.DepthFramebuffer;
import me.cortex.voxy.client.core.rendering.util.HiZBuffer; import me.cortex.voxy.client.core.rendering.util.HiZBuffer;
import net.caffeinemc.mods.sodium.client.util.FogParameters; import net.caffeinemc.mods.sodium.client.util.FogParameters;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.Mth;
import org.joml.*; import org.joml.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@@ -101,9 +101,9 @@ public abstract class Viewport <A extends Viewport<A>> {
this.frustum.set(this.MVP, false); this.frustum.set(this.MVP, false);
//Translation vectors //Translation vectors
int sx = MathHelper.floor(this.cameraX)>>5; int sx = Mth.floor(this.cameraX)>>5;
int sy = MathHelper.floor(this.cameraY)>>5; int sy = Mth.floor(this.cameraY)>>5;
int sz = MathHelper.floor(this.cameraZ)>>5; int sz = Mth.floor(this.cameraZ)>>5;
this.section.set(sx, sy, sz); this.section.set(sx, sy, sz);
this.innerTranslation.set( this.innerTranslation.set(

View File

@@ -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.Viewport;
import me.cortex.voxy.client.core.rendering.util.SharedIndexBuffer; import me.cortex.voxy.client.core.rendering.util.SharedIndexBuffer;
import me.cortex.voxy.client.core.rendering.util.UploadStream; 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.Matrix4f;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL15;
@@ -38,9 +38,9 @@ public class DebugRenderer {
private void uploadUniform(Viewport<?> viewport) { private void uploadUniform(Viewport<?> viewport) {
long ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, 1024); long ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, 1024);
int sx = MathHelper.floor(viewport.cameraX)>>5; int sx = Mth.floor(viewport.cameraX)>>5;
int sy = MathHelper.floor(viewport.cameraY)>>5; int sy = Mth.floor(viewport.cameraY)>>5;
int sz = MathHelper.floor(viewport.cameraZ)>>5; int sz = Mth.floor(viewport.cameraZ)>>5;
new Matrix4f(viewport.projection).mul(viewport.modelView).getToAddress(ptr); ptr += 4*4*4; new Matrix4f(viewport.projection).mul(viewport.modelView).getToAddress(ptr); ptr += 4*4*4;

View File

@@ -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.client.core.rendering.util.UploadStream;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldEngine;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
@@ -104,7 +104,7 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
.defineIf("TAA_PATCH", taa != null) .defineIf("TAA_PATCH", taa != null)
.defineIf("DEBUG_RENDER", false) .defineIf("DEBUG_RENDER", false)
.defineIf("DARKENED_TINTING", MinecraftClient.getInstance().world.getDimensionEffects().isDarkened())//TODO: FIXME: this is really jank atm .defineIf("DARKENED_TINTING", Minecraft.getInstance().level.effects().constantAmbientLight())//TODO: FIXME: this is really jank atm
.addSource(ShaderType.VERTEX, vertex); .addSource(ShaderType.VERTEX, vertex);

View File

@@ -1,13 +1,13 @@
package me.cortex.voxy.client.core.rendering.util; package me.cortex.voxy.client.core.rendering.util;
import net.minecraft.client.MinecraftClient;
import static org.lwjgl.opengl.GL33.glBindSampler; import static org.lwjgl.opengl.GL33.glBindSampler;
import static org.lwjgl.opengl.GL45.glBindTextureUnit; import static org.lwjgl.opengl.GL45.glBindTextureUnit;
import net.minecraft.client.Minecraft;
public class LightMapHelper { public class LightMapHelper {
public static void bind(int lightingIndex) { public static void bind(int lightingIndex) {
glBindSampler(lightingIndex, 0); glBindSampler(lightingIndex, 0);
glBindTextureUnit(lightingIndex, ((net.minecraft.client.texture.GlTexture)(MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().getGlTextureView().texture())).getGlId()); glBindTextureUnit(lightingIndex, ((com.mojang.blaze3d.opengl.GlTexture)(Minecraft.getInstance().gameRenderer.lightTexture().getTextureView().texture())).glId());
} }
} }

View File

@@ -3,7 +3,7 @@ package me.cortex.voxy.client.iris;
import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.client.config.VoxyConfig;
import me.cortex.voxy.client.core.IGetVoxyRenderSystem; import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
import net.irisshaders.iris.gl.uniform.UniformHolder; import net.irisshaders.iris.gl.uniform.UniformHolder;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Matrix4fc; import org.joml.Matrix4fc;
@@ -14,7 +14,7 @@ import static net.irisshaders.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
public class VoxyUniforms { public class VoxyUniforms {
public static Matrix4f getViewProjection() {//This is 1 frame late ;-; cries, since the update occurs _before_ the voxy render pipeline public static Matrix4f getViewProjection() {//This is 1 frame late ;-; cries, since the update occurs _before_ the voxy render pipeline
var getVrs = (IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer; var getVrs = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer;
if (getVrs == null || getVrs.getVoxyRenderSystem() == null) { if (getVrs == null || getVrs.getVoxyRenderSystem() == null) {
return new Matrix4f(); return new Matrix4f();
} }
@@ -23,7 +23,7 @@ public class VoxyUniforms {
} }
public static Matrix4f getModelView() {//This is 1 frame late ;-; cries, since the update occurs _before_ the voxy render pipeline public static Matrix4f getModelView() {//This is 1 frame late ;-; cries, since the update occurs _before_ the voxy render pipeline
var getVrs = (IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer; var getVrs = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer;
if (getVrs == null || getVrs.getVoxyRenderSystem() == null) { if (getVrs == null || getVrs.getVoxyRenderSystem() == null) {
return new Matrix4f(); return new Matrix4f();
} }
@@ -32,7 +32,7 @@ public class VoxyUniforms {
} }
public static Matrix4f getProjection() {//This is 1 frame late ;-; cries, since the update occurs _before_ the voxy render pipeline public static Matrix4f getProjection() {//This is 1 frame late ;-; cries, since the update occurs _before_ the voxy render pipeline
var getVrs = (IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer; var getVrs = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer;
if (getVrs == null || getVrs.getVoxyRenderSystem() == null) { if (getVrs == null || getVrs.getVoxyRenderSystem() == null) {
return new Matrix4f(); return new Matrix4f();
} }

View File

@@ -5,7 +5,7 @@ import com.moulberry.flashback.record.Recorder;
import me.cortex.voxy.client.VoxyClientInstance; import me.cortex.voxy.client.VoxyClientInstance;
import me.cortex.voxy.client.compat.IFlashbackMeta; import me.cortex.voxy.client.compat.IFlashbackMeta;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.core.RegistryAccess;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@@ -18,7 +18,7 @@ public class MixinFlashbackRecorder {
@Shadow @Final private FlashbackMeta metadata; @Shadow @Final private FlashbackMeta metadata;
@Inject(method = "<init>", at = @At("TAIL")) @Inject(method = "<init>", at = @At("TAIL"))
private void voxy$getStoragePath(DynamicRegistryManager registryAccess, CallbackInfo retInf) { private void voxy$getStoragePath(RegistryAccess registryAccess, CallbackInfo retInf) {
if (VoxyCommon.isAvailable()) { if (VoxyCommon.isAvailable()) {
var instance = VoxyCommon.getInstance(); var instance = VoxyCommon.getInstance();
if (instance instanceof VoxyClientInstance ci) { if (instance instanceof VoxyClientInstance ci) {

View File

@@ -6,7 +6,6 @@ import net.irisshaders.iris.Iris;
import net.irisshaders.iris.shaderpack.ShaderPack; import net.irisshaders.iris.shaderpack.ShaderPack;
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId; import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
import net.irisshaders.iris.shaderpack.programs.ProgramSet; import net.irisshaders.iris.shaderpack.programs.ProgramSet;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Redirect;

View File

@@ -10,7 +10,7 @@ import net.irisshaders.iris.gl.buffer.ShaderStorageBufferHolder;
import net.irisshaders.iris.pipeline.IrisRenderingPipeline; import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
import net.irisshaders.iris.shaderpack.programs.ProgramSet; import net.irisshaders.iris.shaderpack.programs.ProgramSet;
import net.irisshaders.iris.uniforms.custom.CustomUniforms; import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@@ -44,7 +44,7 @@ public class MixinIrisRenderingPipeline implements IGetVoxyPatchData, IGetIrisVo
@Inject(method = "beginLevelRendering", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/opengl/GlStateManager;_activeTexture(I)V", shift = At.Shift.BEFORE), remap = true) @Inject(method = "beginLevelRendering", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/opengl/GlStateManager;_activeTexture(I)V", shift = At.Shift.BEFORE), remap = true)
private void voxy$injectViewportSetup(CallbackInfo ci) { private void voxy$injectViewportSetup(CallbackInfo ci) {
if (IrisUtil.CAPTURED_VIEWPORT_PARAMETERS != null) { if (IrisUtil.CAPTURED_VIEWPORT_PARAMETERS != null) {
var renderer = ((IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer).getVoxyRenderSystem(); var renderer = ((IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer).getVoxyRenderSystem();
if (renderer != null) { if (renderer != null) {
IrisUtil.CAPTURED_VIEWPORT_PARAMETERS.apply(renderer); IrisUtil.CAPTURED_VIEWPORT_PARAMETERS.apply(renderer);
} }

View File

@@ -1,17 +1,17 @@
package me.cortex.voxy.client.mixin.iris; package me.cortex.voxy.client.mixin.iris;
import com.mojang.blaze3d.buffers.GpuBufferSlice; import com.mojang.blaze3d.buffers.GpuBufferSlice;
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
import me.cortex.voxy.client.core.IGetVoxyRenderSystem; import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
import me.cortex.voxy.client.core.VoxyRenderSystem; import me.cortex.voxy.client.core.VoxyRenderSystem;
import me.cortex.voxy.client.core.util.IrisUtil; import me.cortex.voxy.client.core.util.IrisUtil;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices; import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices;
import net.caffeinemc.mods.sodium.client.util.FogStorage; import net.caffeinemc.mods.sodium.client.util.FogStorage;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Camera;
import net.minecraft.client.render.Camera; import net.minecraft.client.DeltaTracker;
import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.Minecraft;
import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.util.ObjectAllocator;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector4f; import org.joml.Vector4f;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@@ -23,14 +23,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static org.lwjgl.opengl.GL11C.glViewport; import static org.lwjgl.opengl.GL11C.glViewport;
@Mixin(WorldRenderer.class) @Mixin(LevelRenderer.class)
public class MixinWorldRenderer { public class MixinWorldRenderer {
@Shadow @Final private MinecraftClient client; @Shadow @Final private Minecraft minecraft;
@Inject(method = "render", at = @At("HEAD"), order = 100) @Inject(method = "renderLevel", at = @At("HEAD"), order = 100)
private void voxy$injectIrisCompat( private void voxy$injectIrisCompat(
ObjectAllocator allocator, GraphicsResourceAllocator allocator,
RenderTickCounter tickCounter, DeltaTracker tickCounter,
boolean renderBlockOutline, boolean renderBlockOutline,
Camera camera, Camera camera,
Matrix4f positionMatrix, Matrix4f positionMatrix,
@@ -44,10 +44,10 @@ public class MixinWorldRenderer {
var renderer = ((IGetVoxyRenderSystem) this).getVoxyRenderSystem(); var renderer = ((IGetVoxyRenderSystem) this).getVoxyRenderSystem();
if (renderer != null) { if (renderer != null) {
//Fixthe fucking viewport dims, fuck iris //Fixthe fucking viewport dims, fuck iris
glViewport(0,0,MinecraftClient.getInstance().getFramebuffer().textureWidth, MinecraftClient.getInstance().getFramebuffer().textureHeight); glViewport(0,0,Minecraft.getInstance().getMainRenderTarget().width, Minecraft.getInstance().getMainRenderTarget().height);
var pos = camera.getCameraPos(); var pos = camera.position();
IrisUtil.CAPTURED_VIEWPORT_PARAMETERS = new IrisUtil.CapturedViewportParameters(new ChunkRenderMatrices(projectionMatrix, positionMatrix), ((FogStorage) this.client.gameRenderer).sodium$getFogParameters(), pos.x, pos.y, pos.z); IrisUtil.CAPTURED_VIEWPORT_PARAMETERS = new IrisUtil.CapturedViewportParameters(new ChunkRenderMatrices(projectionMatrix, positionMatrix), ((FogStorage) this.minecraft.gameRenderer).sodium$getFogParameters(), pos.x, pos.y, pos.z);
} }
} }
} }

View File

@@ -4,9 +4,9 @@ import me.cortex.voxy.client.ICheekyClientChunkManager;
import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.client.config.VoxyConfig;
import me.cortex.voxy.common.world.service.VoxelIngestService; import me.cortex.voxy.common.world.service.VoxelIngestService;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.world.ClientChunkManager; import net.minecraft.client.multiplayer.ClientChunkCache;
import net.minecraft.util.math.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
@@ -14,20 +14,20 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ClientChunkManager.class) @Mixin(ClientChunkCache.class)
public class MixinClientChunkManager implements ICheekyClientChunkManager { public class MixinClientChunkManager implements ICheekyClientChunkManager {
@Unique @Unique
private static final boolean BOBBY_INSTALLED = FabricLoader.getInstance().isModLoaded("bobby"); private static final boolean BOBBY_INSTALLED = FabricLoader.getInstance().isModLoaded("bobby");
@Shadow volatile ClientChunkManager.ClientChunkMap chunks; @Shadow volatile ClientChunkCache.Storage storage;
@Override @Override
public WorldChunk voxy$cheekyGetChunk(int x, int z) { public LevelChunk voxy$cheekyGetChunk(int x, int z) {
//This doesnt do the in range check stuff, it just gets the chunk at all costs //This doesnt do the in range check stuff, it just gets the chunk at all costs
return this.chunks.getChunk(this.chunks.getIndex(x, z)); return this.storage.getChunk(this.storage.getIndex(x, z));
} }
@Inject(method = "unload", at = @At("HEAD")) @Inject(method = "drop", at = @At("HEAD"))
public void voxy$captureChunkBeforeUnload(ChunkPos pos, CallbackInfo ci) { public void voxy$captureChunkBeforeUnload(ChunkPos pos, CallbackInfo ci) {
if (VoxyConfig.CONFIG.ingestEnabled && BOBBY_INSTALLED) { if (VoxyConfig.CONFIG.ingestEnabled && BOBBY_INSTALLED) {
var chunk = this.voxy$cheekyGetChunk(pos.x, pos.z); var chunk = this.voxy$cheekyGetChunk(pos.x, pos.z);

View File

@@ -1,19 +1,19 @@
package me.cortex.voxy.client.mixin.minecraft; package me.cortex.voxy.client.mixin.minecraft;
import me.cortex.voxy.client.LoadException; import me.cortex.voxy.client.LoadException;
import net.minecraft.client.network.ClientCommonNetworkHandler; import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import net.minecraft.network.packet.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; import net.minecraft.network.protocol.game.ClientboundLoginPacket;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ClientCommonNetworkHandler.class) @Mixin(ClientCommonPacketListenerImpl.class)
public class MixinClientCommonNetworkHandler { public class MixinClientCommonNetworkHandler {
@Inject(method = "onPacketException", at = @At("HEAD"), cancellable = true) @Inject(method = "onPacketError", at = @At("HEAD"), cancellable = true)
private void handleDisconnectAsCrash(Packet<?> packet, Exception exception, CallbackInfo ci) { private void handleDisconnectAsCrash(Packet<?> packet, Exception exception, CallbackInfo ci) {
if (packet instanceof GameJoinS2CPacket) { if (packet instanceof ClientboundLoginPacket) {
ci.cancel(); ci.cancel();
throw new LoadException("Force crashing due to exception during on game join", exception); throw new LoadException("Force crashing due to exception during on game join", exception);
} }

View File

@@ -4,17 +4,17 @@ import me.cortex.voxy.client.VoxyClient;
import me.cortex.voxy.client.VoxyClientInstance; import me.cortex.voxy.client.VoxyClientInstance;
import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.client.config.VoxyConfig;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; import net.minecraft.network.protocol.game.ClientboundLoginPacket;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ClientPlayNetworkHandler.class) @Mixin(ClientPacketListener.class)
public class MixinClientLoginNetworkHandler { 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;")) @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(GameJoinS2CPacket packet, CallbackInfo ci) { private void voxy$init(ClientboundLoginPacket packet, CallbackInfo ci) {
if (VoxyCommon.isAvailable() && !VoxyClientInstance.isInGame) { if (VoxyCommon.isAvailable() && !VoxyClientInstance.isInGame) {
VoxyClientInstance.isInGame = true; VoxyClientInstance.isInGame = true;
if (VoxyConfig.CONFIG.enabled) { if (VoxyConfig.CONFIG.enabled) {

View File

@@ -5,18 +5,18 @@ import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
import me.cortex.voxy.common.world.service.VoxelIngestService; import me.cortex.voxy.common.world.service.VoxelIngestService;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import me.cortex.voxy.commonImpl.WorldIdentifier; import me.cortex.voxy.commonImpl.WorldIdentifier;
import net.minecraft.block.BlockState; import net.minecraft.client.multiplayer.ClientChunkCache;
import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.world.ClientChunkManager; import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.world.ClientWorld; import net.minecraft.core.BlockPos;
import net.minecraft.registry.RegistryKey; import net.minecraft.core.Holder;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.core.SectionPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.resources.ResourceKey;
import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.world.level.Level;
import net.minecraft.world.LightType; import net.minecraft.world.level.LightLayer;
import net.minecraft.world.World; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; 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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ClientWorld.class) @Mixin(ClientLevel.class)
public abstract class MixinClientWorld { public abstract class MixinClientWorld {
@Unique @Unique
private int bottomSectionY; 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 = "<init>", at = @At("TAIL")) @Inject(method = "<init>", at = @At("TAIL"))
private void voxy$getBottom( private void voxy$getBottom(
ClientPlayNetworkHandler networkHandler, ClientPacketListener networkHandler,
ClientWorld.Properties properties, ClientLevel.ClientLevelData properties,
RegistryKey<World> registryRef, ResourceKey<Level> registryRef,
RegistryEntry<DimensionType> dimensionType, Holder<DimensionType> dimensionType,
int loadDistance, int loadDistance,
int simulationDistance, int simulationDistance,
WorldRenderer worldRenderer, LevelRenderer worldRenderer,
boolean debugWorld, boolean debugWorld,
long seed, long seed,
int seaLevel, int seaLevel,
CallbackInfo cir) { 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) { private void voxy$injectIngestOnStateChange(BlockPos pos, BlockState old, BlockState updated, CallbackInfo cir) {
if (old == updated) return; if (old == updated) return;
@@ -61,7 +61,7 @@ public abstract class MixinClientWorld {
if (!VoxyConfig.CONFIG.ingestEnabled) return;//Only ingest if setting enabled 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); var wi = WorldIdentifier.of(self);
if (wi == null) { if (wi == null) {
return; return;
@@ -71,15 +71,15 @@ public abstract class MixinClientWorld {
int y = pos.getY()&15; int y = pos.getY()&15;
int z = pos.getZ()&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 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 section = self.getChunk(pos).getSection(csp.y()-this.bottomSectionY);
var lp = self.getLightingProvider(); var lp = self.getLightEngine();
var blp = lp.get(LightType.BLOCK).getLightSection(csp); var blp = lp.getLayerListener(LightLayer.BLOCK).getDataLayerData(csp);
var slp = lp.get(LightType.SKY).getLightSection(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());
} }
} }
} }

View File

@@ -2,9 +2,9 @@ package me.cortex.voxy.client.mixin.minecraft;
import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.client.config.VoxyConfig;
import me.cortex.voxy.client.core.IGetVoxyRenderSystem; import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.client.render.fog.FogData; import net.minecraft.client.renderer.fog.FogData;
import net.minecraft.client.render.fog.FogRenderer; import net.minecraft.client.renderer.fog.FogRenderer;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@@ -12,9 +12,9 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(FogRenderer.class) @Mixin(FogRenderer.class)
public class MixinFogRenderer { 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) { 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) { if (VoxyConfig.CONFIG.renderVanillaFog || vrs == null || vrs.getVoxyRenderSystem() == null) {
instance.renderDistanceEnd = distance; instance.renderDistanceEnd = distance;

View File

@@ -2,7 +2,7 @@ package me.cortex.voxy.client.mixin.minecraft;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; 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.slf4j.Logger;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
@@ -13,9 +13,9 @@ import java.io.StringWriter;
@Mixin(GlDebug.class) @Mixin(GlDebug.class)
public class MixinGlDebug { 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<Void> original) { private void voxy$wrapDebug(Logger instance, String base, Object msgObj, Operation<Void> original) {
if (msgObj instanceof GlDebug.DebugMessage msg) { if (msgObj instanceof GlDebug.LogEntry msg) {
var throwable = new Throwable(msg.toString()); var throwable = new Throwable(msg.toString());
if (isCausedByVoxy(throwable.getStackTrace())) { if (isCausedByVoxy(throwable.getStackTrace())) {
original.call(instance, base+"\n"+getStackTraceAsString(throwable), throwable); original.call(instance, base+"\n"+getStackTraceAsString(throwable), throwable);

View File

@@ -2,15 +2,15 @@ package me.cortex.voxy.client.mixin.minecraft;
import me.cortex.voxy.client.VoxyClientInstance; import me.cortex.voxy.client.VoxyClientInstance;
import me.cortex.voxy.commonImpl.VoxyCommon; 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.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftClient.class) @Mixin(Minecraft.class)
public class MixinMinecraftClient { 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) { private void voxy$injectWorldClose(CallbackInfo ci) {
if (VoxyCommon.isAvailable() && VoxyClientInstance.isInGame) { if (VoxyCommon.isAvailable() && VoxyClientInstance.isInGame) {
VoxyCommon.shutdownInstance(); VoxyCommon.shutdownInstance();

View File

@@ -4,7 +4,7 @@ package me.cortex.voxy.client.mixin.minecraft;
import com.mojang.blaze3d.shaders.ShaderType; import com.mojang.blaze3d.shaders.ShaderType;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import me.cortex.voxy.client.VoxyClient; 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.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@@ -17,7 +17,7 @@ import java.util.function.BiFunction;
public class MixinRenderSystem { public class MixinRenderSystem {
//We need to inject before iris to initalize our systems //We need to inject before iris to initalize our systems
@Inject(method = "initRenderer", order = 900, remap = false, at = @At("RETURN")) @Inject(method = "initRenderer", order = 900, remap = false, at = @At("RETURN"))
private static void voxy$injectInit(long windowHandle, int debugVerbosity, boolean sync, BiFunction<Identifier, ShaderType, String> shaderSourceGetter, boolean renderDebugLabels, CallbackInfo ci) { private static void voxy$injectInit(long windowHandle, int debugVerbosity, boolean sync, BiFunction<ResourceLocation, ShaderType, String> shaderSourceGetter, boolean renderDebugLabels, CallbackInfo ci) {
VoxyClient.initVoxyClient(); VoxyClient.initVoxyClient();
} }
} }

View File

@@ -1,17 +1,18 @@
package me.cortex.voxy.client.mixin.minecraft; package me.cortex.voxy.client.mixin.minecraft;
import me.cortex.voxy.client.LoadException; 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.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ThreadExecutor.class) @Mixin(BlockableEventLoop.class)
public abstract class MixinThreadExecutor { 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) { private boolean voxy$forceCrashOnError(Throwable exception) {
if (exception instanceof LoadException le) { if (exception instanceof LoadException le) {
if (le.getCause() instanceof RuntimeException cause) { if (le.getCause() instanceof RuntimeException cause) {
@@ -19,6 +20,6 @@ public abstract class MixinThreadExecutor {
} }
throw le; throw le;
} }
return isMemoryError(exception); return isNonRecoverable(exception);
} }
} }

View File

@@ -1,11 +1,11 @@
package me.cortex.voxy.client.mixin.minecraft; 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.client.GPUSelectorWindows2;
import me.cortex.voxy.common.util.ThreadUtils; 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.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@@ -13,8 +13,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Window.class) @Mixin(Window.class)
public class MixinWindow { public class MixinWindow {
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;throwOnGlError()V")) @Inject(method = "<init>", at = @At(value = "INVOKE", target = "setBootErrorCallback"))
private void injectInitWindow(WindowEventHandler eventHandler, MonitorTracker monitorTracker, WindowSettings settings, String fullscreenVideoMode, String title, CallbackInfo ci) { private void injectInitWindow(WindowEventHandler eventHandler, ScreenManager monitorTracker, DisplayData settings, String fullscreenVideoMode, String title, CallbackInfo ci) {
//System.load("C:\\Program Files\\RenderDoc\\renderdoc.dll"); //System.load("C:\\Program Files\\RenderDoc\\renderdoc.dll");
var prop = System.getProperty("voxy.forceGpuSelectionIndex", "NO"); var prop = System.getProperty("voxy.forceGpuSelectionIndex", "NO");
if (!prop.equals("NO")) { if (!prop.equals("NO")) {

View File

@@ -9,9 +9,8 @@ import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import me.cortex.voxy.commonImpl.WorldIdentifier; import me.cortex.voxy.commonImpl.WorldIdentifier;
import net.minecraft.client.render.Frustum; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.world.ClientWorld;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; 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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(WorldRenderer.class) @Mixin(LevelRenderer.class)
public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem { public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem {
@Shadow private @Nullable ClientWorld world; @Shadow private @Nullable ClientLevel level;
@Unique private VoxyRenderSystem renderer; @Unique private VoxyRenderSystem renderer;
@Override @Override
@@ -30,17 +29,17 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem {
return this.renderer; 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) { private void reloadVoxyRenderer(CallbackInfo ci) {
this.shutdownRenderer(); this.shutdownRenderer();
if (this.world != null) { if (this.level != null) {
this.createRenderer(); this.createRenderer();
} }
} }
@Inject(method = "setWorld", at = @At("HEAD")) @Inject(method = "setLevel", at = @At("HEAD"))
private void voxy$captureSetWorld(ClientWorld world, CallbackInfo ci) { private void voxy$captureSetWorld(ClientLevel world, CallbackInfo ci) {
if (this.world != world) { if (this.level != world) {
this.shutdownRenderer(); this.shutdownRenderer();
} }
} }
@@ -65,7 +64,7 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem {
Logger.info("Not creating renderer due to disabled"); Logger.info("Not creating renderer due to disabled");
return; return;
} }
if (this.world == null) { if (this.level == null) {
Logger.error("Not creating renderer due to null world"); Logger.error("Not creating renderer due to null world");
return; return;
} }
@@ -74,7 +73,7 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem {
Logger.error("Not creating renderer due to null instance"); Logger.error("Not creating renderer due to null instance");
return; return;
} }
WorldEngine world = WorldIdentifier.ofEngine(this.world); WorldEngine world = WorldIdentifier.ofEngine(this.level);
if (world == null) { if (world == null) {
Logger.error("Null world selected"); Logger.error("Null world selected");
return; return;

View File

@@ -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.chunk.terrain.TerrainRenderPass;
import net.caffeinemc.mods.sodium.client.render.viewport.Viewport; import net.caffeinemc.mods.sodium.client.render.viewport.Viewport;
import net.caffeinemc.mods.sodium.client.util.FogParameters; 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.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinRenderPipeline { public class MixinRenderPipeline {
@Inject(method = "renderFrame", at = @At("RETURN")) @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) { 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) { if (renderer != null) {
renderer.renderOpaque(renderer.setupViewport(crm, fogParameters, px, py, pz)); renderer.renderOpaque(renderer.setupViewport(crm, fogParameters, px, py, pz));
} }

View File

@@ -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.chunk.vertex.format.ChunkVertexType;
import net.caffeinemc.mods.sodium.client.render.viewport.CameraTransform; import net.caffeinemc.mods.sodium.client.render.viewport.CameraTransform;
import net.caffeinemc.mods.sodium.client.util.FogParameters; 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.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@@ -48,7 +48,7 @@ public abstract class MixinDefaultChunkRenderer extends ShaderChunkRenderer {
@Unique @Unique
private void doRender(ChunkRenderMatrices matrices, TerrainRenderPass renderPass, CameraTransform camera, FogParameters fogParameters) { private void doRender(ChunkRenderMatrices matrices, TerrainRenderPass renderPass, CameraTransform camera, FogParameters fogParameters) {
if (renderPass == DefaultTerrainRenderPasses.CUTOUT) { if (renderPass == DefaultTerrainRenderPasses.CUTOUT) {
var renderer = ((IGetVoxyRenderSystem) MinecraftClient.getInstance().worldRenderer).getVoxyRenderSystem(); var renderer = ((IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer).getVoxyRenderSystem();
if (renderer != null) { if (renderer != null) {
Viewport<?> viewport = null; Viewport<?> viewport = null;
if (IrisUtil.irisShaderPackEnabled()) { if (IrisUtil.irisShaderPackEnabled()) {

View File

@@ -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.map.ChunkTrackerHolder;
import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.SortBehavior; import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.SortBehavior;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.util.math.ChunkPos; import net.minecraft.core.SectionPos;
import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.LightType; import net.minecraft.world.level.LightLayer;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.level.chunk.status.ChunkStatus;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@@ -34,19 +34,19 @@ public class MixinRenderSectionManager {
@Unique @Unique
private static final boolean BOBBY_INSTALLED = FabricLoader.getInstance().isModLoaded("bobby"); 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; @Shadow @Final private ChunkBuilder builder;
@Inject(method = "<init>", at = @At("TAIL")) @Inject(method = "<init>", at = @At("TAIL"))
private void voxy$resetChunkTracker(ClientWorld level, int renderDistance, SortBehavior sortBehavior, CommandList commandList, CallbackInfo ci) { private void voxy$resetChunkTracker(ClientLevel level, int renderDistance, SortBehavior sortBehavior, CommandList commandList, CallbackInfo ci) {
if (level.worldRenderer != null) { if (level.levelRenderer != null) {
var system = ((IGetVoxyRenderSystem)(level.worldRenderer)).getVoxyRenderSystem(); var system = ((IGetVoxyRenderSystem)(level.levelRenderer)).getVoxyRenderSystem();
if (system != null) { if (system != null) {
system.chunkBoundRenderer.reset(); system.chunkBoundRenderer.reset();
} }
} }
this.bottomSectionY = this.level.getBottomY()>>4; this.bottomSectionY = this.level.getMinY()>>4;
{ {
//TODO: put in a better position //TODO: put in a better position
@@ -61,7 +61,7 @@ public class MixinRenderSectionManager {
private void injectIngest(int x, int z, CallbackInfo ci) { private void injectIngest(int x, int z, CallbackInfo ci) {
//TODO: Am not quite sure if this is right //TODO: Am not quite sure if this is right
if (VoxyConfig.CONFIG.ingestEnabled && !BOBBY_INSTALLED) { if (VoxyConfig.CONFIG.ingestEnabled && !BOBBY_INSTALLED) {
var cccm = (ICheekyClientChunkManager)this.level.getChunkManager(); var cccm = (ICheekyClientChunkManager)this.level.getChunkSource();
if (cccm != null) { if (cccm != null) {
var chunk = cccm.voxy$cheekyGetChunk(x, z); var chunk = cccm.voxy$cheekyGetChunk(x, z);
if (chunk != null) { if (chunk != null) {
@@ -74,8 +74,8 @@ public class MixinRenderSectionManager {
@Inject(method = "onChunkAdded", at = @At("HEAD")) @Inject(method = "onChunkAdded", at = @At("HEAD"))
private void voxy$ingestOnAdd(int x, int z, CallbackInfo ci) { private void voxy$ingestOnAdd(int x, int z, CallbackInfo ci) {
if (this.level.worldRenderer != null && VoxyConfig.CONFIG.ingestEnabled) { if (this.level.levelRenderer != null && VoxyConfig.CONFIG.ingestEnabled) {
var cccm = this.level.getChunkManager(); var cccm = this.level.getChunkSource();
if (cccm != null) { if (cccm != null) {
var chunk = cccm.getChunk(x, z, ChunkStatus.FULL, false); var chunk = cccm.getChunk(x, z, ChunkStatus.FULL, false);
if (chunk != null) { if (chunk != null) {
@@ -115,7 +115,7 @@ public class MixinRenderSectionManager {
if (flags == 0)//Only process things with stuff if (flags == 0)//Only process things with stuff
return true; return true;
VoxyRenderSystem system = ((IGetVoxyRenderSystem)(this.level.worldRenderer)).getVoxyRenderSystem(); VoxyRenderSystem system = ((IGetVoxyRenderSystem)(this.level.levelRenderer)).getVoxyRenderSystem();
if (system == null) { if (system == null) {
return true; return true;
} }
@@ -125,18 +125,18 @@ public class MixinRenderSectionManager {
var tracker = ((AccessorChunkTracker)ChunkTrackerHolder.get(this.level)).getChunkStatus(); 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 //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! // 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) { if (key != this.cachedChunkPos) {
this.cachedChunkPos = key; this.cachedChunkPos = key;
this.cachedChunkStatus = tracker.getOrDefault(key, 0); this.cachedChunkStatus = tracker.getOrDefault(key, 0);
} }
if (this.cachedChunkStatus == 3) {//If this chunk still has surrounding chunks if (this.cachedChunkStatus == 3) {//If this chunk still has surrounding chunks
var section = this.level.getChunk(x,z).getSection(y-this.bottomSectionY); 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 csp = SectionPos.of(x,y,z);
var blp = lp.get(LightType.BLOCK).getLightSection(csp); var blp = lp.getLayerListener(LightLayer.BLOCK).getDataLayerData(csp);
var slp = lp.get(LightType.SKY).getLightSection(csp); var slp = lp.getLayerListener(LightLayer.SKY).getDataLayerData(csp);
//Note: we dont do this check and just blindly ingest, it shouldbe ok :tm: //Note: we dont do this check and just blindly ingest, it shouldbe ok :tm:
//if (blp != null || slp != null) //if (blp != null || slp != null)
@@ -150,7 +150,7 @@ public class MixinRenderSectionManager {
x-=sector<<10; x-=sector<<10;
y+=16+(256-32-sector*30); y+=16+(256-32-sector*30);
} }
long pos = ChunkSectionPos.asLong(x,y,z); long pos = SectionPos.asLong(x,y,z);
if (wasBuilt) {//Remove if (wasBuilt) {//Remove
//TODO: on chunk remove do ingest if is surrounded by built chunks (or when the tracker says is ok) //TODO: on chunk remove do ingest if is surrounded by built chunks (or when the tracker says is ok)

View File

@@ -4,7 +4,7 @@ import me.cortex.voxy.client.config.VoxyConfigScreenPages;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI; import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
import net.caffeinemc.mods.sodium.client.gui.options.OptionPage; 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.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;

View File

@@ -1,7 +1,7 @@
package me.cortex.voxy.client.taskbar; package me.cortex.voxy.client.taskbar;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
public abstract class Taskbar { public abstract class Taskbar {
@@ -37,7 +37,7 @@ public abstract class Taskbar {
private static ITaskbar createInterface() { private static ITaskbar createInterface() {
if (SystemUtils.IS_OS_WINDOWS) { if (SystemUtils.IS_OS_WINDOWS) {
try { try {
return new WindowsTaskbar(MinecraftClient.getInstance().getWindow().getHandle()); return new WindowsTaskbar(Minecraft.getInstance().getWindow().handle());
} catch (Exception e) { } catch (Exception e) {
Logger.error("Unable to create windows taskbar interface", e); Logger.error("Unable to create windows taskbar interface", e);
return new NoopTaskbar(); return new NoopTaskbar();

View File

@@ -1,8 +1,8 @@
package me.cortex.voxy.common; package me.cortex.voxy.common;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Arrays; 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(" ")); String error = (INSERT_CLASS?("["+callClsName()+"]: "):"") + Stream.of(args).map(Logger::objToString).collect(Collectors.joining(" "));
LOGGER.error(error, throwable); LOGGER.error(error, throwable);
if (VoxyCommon.IS_IN_MINECRAFT && !VoxyCommon.IS_DEDICATED_SERVER) { if (VoxyCommon.IS_IN_MINECRAFT && !VoxyCommon.IS_DEDICATED_SERVER) {
var instance = MinecraftClient.getInstance(); var instance = Minecraft.getInstance();
if (instance != null) { if (instance != null) {
instance.executeSync(() -> { instance.executeIfPossible(() -> {
var player = MinecraftClient.getInstance().player; var player = Minecraft.getInstance().player;
if (player != null) player.sendMessage(Text.literal(error), true); if (player != null) player.displayClientMessage(Component.literal(error), true);
}); });
} }
} }

View File

@@ -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.StorageBackend;
import me.cortex.voxy.common.config.storage.StorageConfig; import me.cortex.voxy.common.config.storage.StorageConfig;
import me.cortex.voxy.common.util.MemoryBuffer; 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.apache.commons.lang3.stream.Streams;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
@@ -26,7 +26,7 @@ public class MemoryStorageBackend extends StorageBackend {
} }
private Long2ObjectMap<MemoryBuffer> getMap(long key) { private Long2ObjectMap<MemoryBuffer> 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 @Override

View File

@@ -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.StorageBackend;
import me.cortex.voxy.common.config.storage.StorageConfig; import me.cortex.voxy.common.config.storage.StorageConfig;
import me.cortex.voxy.common.util.MemoryBuffer; 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.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -30,7 +29,7 @@ public class FragmentedStorageBackendAdaptor extends StorageBackend {
} }
private int getSegmentId(long key) { 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 @Override

View File

@@ -5,13 +5,18 @@ import me.cortex.voxy.common.world.other.Mapper;
import me.cortex.voxy.common.world.other.Mipper; import me.cortex.voxy.common.world.other.Mipper;
import net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette; import net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.BlockState; import net.minecraft.core.Holder;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.SimpleBitStorage;
import net.minecraft.util.collection.EmptyPaletteStorage; import net.minecraft.util.ZeroBitStorage;
import net.minecraft.util.collection.PackedIntegerArray; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.biome.Biome; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.chunk.*; 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; import java.util.WeakHashMap;
public class WorldConversionFactory { public class WorldConversionFactory {
@@ -40,7 +45,7 @@ public class WorldConversionFactory {
for (int i = 0; i < vp.getSize(); i++) { for (int i = 0; i < vp.getSize(); i++) {
BlockState state = null; BlockState state = null;
int blockId = -1; int blockId = -1;
try { state = vp.get(i); } catch (Exception e) {} try { state = vp.valueFor(i); } catch (Exception e) {}
if (state != null) { if (state != null) {
blockId = blockCache.getOrDefault(state, -1); blockId = blockCache.getOrDefault(state, -1);
if (blockId == -1) { if (blockId == -1) {
@@ -55,9 +60,9 @@ public class WorldConversionFactory {
return false; return false;
} }
private static void setupLocalPalette(Palette<BlockState> vp, Reference2IntOpenHashMap<BlockState> blockCache, Mapper mapper, int[] pc) { private static void setupLocalPalette(Palette<BlockState> vp, Reference2IntOpenHashMap<BlockState> blockCache, Mapper mapper, int[] pc) {
if (vp instanceof ArrayPalette<BlockState>) { if (vp instanceof LinearPalette<BlockState>) {
for (int i = 0; i < vp.getSize(); i++) { for (int i = 0; i < vp.getSize(); i++) {
var state = vp.get(i); var state = vp.valueFor(i);
int blockId = -1; int blockId = -1;
if (state != null) { if (state != null) {
blockId = blockCache.getOrDefault(state, -1); blockId = blockCache.getOrDefault(state, -1);
@@ -68,14 +73,14 @@ public class WorldConversionFactory {
} }
pc[i] = blockId; pc[i] = blockId;
} }
} else if (vp instanceof BiMapPalette<BlockState> pal) { } else if (vp instanceof HashMapPalette<BlockState> pal) {
//var map = pal.map; //var map = pal.map;
//TODO: heavily optimize this by reading the map directly //TODO: heavily optimize this by reading the map directly
for (int i = 0; i < vp.getSize(); i++) { for (int i = 0; i < vp.getSize(); i++) {
BlockState state = null; BlockState state = null;
int blockId = -1; int blockId = -1;
try { state = vp.get(i); } catch (Exception e) {} try { state = vp.valueFor(i); } catch (Exception e) {}
if (state != null) { if (state != null) {
blockId = blockCache.getOrDefault(state, -1); blockId = blockCache.getOrDefault(state, -1);
if (blockId == -1) { if (blockId == -1) {
@@ -86,9 +91,9 @@ public class WorldConversionFactory {
pc[i] = blockId; pc[i] = blockId;
} }
} else if (vp instanceof SingularPalette<BlockState>) { } else if (vp instanceof SingleValuePalette<BlockState>) {
int blockId = -1; int blockId = -1;
var state = vp.get(0); var state = vp.valueFor(0);
if (state != null) { if (state != null) {
blockId = blockCache.getOrDefault(state, -1); blockId = blockCache.getOrDefault(state, -1);
if (blockId == -1) { if (blockId == -1) {
@@ -107,7 +112,7 @@ public class WorldConversionFactory {
public static VoxelizedSection convert(VoxelizedSection section, public static VoxelizedSection convert(VoxelizedSection section,
Mapper stateMapper, Mapper stateMapper,
PalettedContainer<BlockState> blockContainer, PalettedContainer<BlockState> blockContainer,
ReadableContainer<RegistryEntry<Biome>> biomeContainer, PalettedContainerRO<Holder<Biome>> biomeContainer,
ILightingSupplier lightSupplier) { ILightingSupplier lightSupplier) {
//Cheat by creating a local pallet then read the data directly //Cheat by creating a local pallet then read the data directly
@@ -121,9 +126,9 @@ public class WorldConversionFactory {
var vp = blockContainer.data.palette; var vp = blockContainer.data.palette;
var pc = cache.getPaletteCache(vp.getSize()); var pc = cache.getPaletteCache(vp.getSize());
IdListPalette<BlockState> bps = null; GlobalPalette<BlockState> bps = null;
if (blockContainer.data.palette instanceof IdListPalette<BlockState> _bps) { if (blockContainer.data.palette instanceof GlobalPalette<BlockState> _bps) {
bps = _bps; bps = _bps;
} else { } else {
setupLocalPalette(vp, blockCache, stateMapper, pc); setupLocalPalette(vp, blockCache, stateMapper, pc);
@@ -142,12 +147,12 @@ public class WorldConversionFactory {
int nonZeroCnt = 0; int nonZeroCnt = 0;
if (blockContainer.data.storage instanceof PackedIntegerArray bStor) { if (blockContainer.data.storage instanceof SimpleBitStorage bStor) {
var bDat = bStor.getData(); var bDat = bStor.getRaw();
int iterPerLong = (64 / bStor.getElementBits()) - 1; int iterPerLong = (64 / bStor.getBits()) - 1;
int MSK = (1 << bStor.getElementBits()) - 1; int MSK = (1 << bStor.getBits()) - 1;
int eBits = bStor.getElementBits(); int eBits = bStor.getBits();
long sample = 0; long sample = 0;
int c = 0; int c = 0;
@@ -161,7 +166,7 @@ public class WorldConversionFactory {
if (bps == null) { if (bps == null) {
bId = pc[(int) (sample & MSK)]; bId = pc[(int) (sample & MSK)];
} else { } else {
bId = stateMapper.getIdForBlockState(bps.get((int) (sample&MSK))); bId = stateMapper.getIdForBlockState(bps.valueFor((int) (sample&MSK)));
} }
sample >>>= eBits; sample >>>= eBits;
@@ -170,7 +175,7 @@ public class WorldConversionFactory {
data[i] = Mapper.composeMappingId(light, bId, biomes[Integer.compress(i,0b1100_1100_1100)]); data[i] = Mapper.composeMappingId(light, bId, biomes[Integer.compress(i,0b1100_1100_1100)]);
} }
} else { } else {
if (!(blockContainer.data.storage instanceof EmptyPaletteStorage)) { if (!(blockContainer.data.storage instanceof ZeroBitStorage)) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
int bId = pc[0]; int bId = pc[0];

View File

@@ -5,7 +5,7 @@ import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.util.MemoryBuffer; import me.cortex.voxy.common.util.MemoryBuffer;
import me.cortex.voxy.common.util.UnsafeUtil; import me.cortex.voxy.common.util.UnsafeUtil;
import me.cortex.voxy.common.world.other.Mapper; 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 org.lwjgl.system.MemoryUtil;
import java.util.Arrays; 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 //TODO: see if tight bitpacking is better or if bitpacking with pow2 pack size is better
{//Store blocks {//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 rem = 32;
int batch = 0; int batch = 0;
@@ -195,7 +195,7 @@ public class SaveLoadSystem2 {
if (biomeMapping.size() == 1) { if (biomeMapping.size() == 1) {
//If its only a single mapping, dont put anything //If its only a single mapping, dont put anything
} else { } 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 rem = 32;
int batch = 0; int batch = 0;
@@ -295,7 +295,7 @@ public class SaveLoadSystem2 {
short[] blocks = new short[32*32*32]; short[] blocks = new short[32*32*32];
short[] biomes = new short[32*32*32]; short[] biomes = new short[32*32*32];
{//Block {//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 rem = 32;
int batch = MemoryUtil.memGetInt(ptr); ptr += 4; int batch = MemoryUtil.memGetInt(ptr); ptr += 4;
int msk = (1<<SIZE)-1; int msk = (1<<SIZE)-1;
@@ -315,7 +315,7 @@ public class SaveLoadSystem2 {
if (biomeMapSize == 1) { if (biomeMapSize == 1) {
Arrays.fill(biomes, (short) 0); Arrays.fill(biomes, (short) 0);
} else { } else {
final int SIZE = MathHelper.smallestEncompassingPowerOfTwo(MathHelper.floorLog2(MathHelper.smallestEncompassingPowerOfTwo(biomeMapSize))); final int SIZE = Mth.smallestEncompassingPowerOfTwo(Mth.log2(Mth.smallestEncompassingPowerOfTwo(biomeMapSize)));
int rem = 32; int rem = 32;
int batch = MemoryUtil.memGetInt(ptr); ptr += 4; int batch = MemoryUtil.memGetInt(ptr); ptr += 4;
int msk = (1<<SIZE)-1; int msk = (1<<SIZE)-1;

View File

@@ -4,20 +4,20 @@ import com.mojang.serialization.Dynamic;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.config.IMappingStorage; import me.cortex.voxy.common.config.IMappingStorage;
import me.cortex.voxy.common.util.Pair;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.block.Block; import net.minecraft.core.Holder;
import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.Blocks; import net.minecraft.nbt.NbtAccounter;
import net.minecraft.block.LeavesBlock;
import net.minecraft.datafixer.Schemas;
import net.minecraft.datafixer.TypeReferences;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.NbtSizeTracker; import net.minecraft.util.datafix.DataFixers;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.datafix.fixes.References;
import net.minecraft.util.Pair; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.biome.Biome; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -57,7 +57,7 @@ public class Mapper {
public Mapper(IMappingStorage storage) { public Mapper(IMappingStorage storage) {
this.storage = storage; this.storage = storage;
//Insert air since its a special entry (index 0) //Insert air since its a special entry (index 0)
var airEntry = new StateEntry(0, Blocks.AIR.getDefaultState()); var airEntry = new StateEntry(0, Blocks.AIR.defaultBlockState());
this.block2stateEntry.put(airEntry.state, airEntry); this.block2stateEntry.put(airEntry.state, airEntry);
this.blockId2stateEntry.add(airEntry); this.blockId2stateEntry.add(airEntry);
@@ -142,7 +142,7 @@ public class Mapper {
var rand = new Random(); var rand = new Random();
for (var error : sentryErrors) { for (var error : sentryErrors) {
while (true) { while (true) {
var state = new StateEntry(error.getRight(), Block.STATE_IDS.get(rand.nextInt(Block.STATE_IDS.size() - 1))); var state = new StateEntry(error.right(), Block.BLOCK_STATE_REGISTRY.byId(rand.nextInt(Block.BLOCK_STATE_REGISTRY.size() - 1)));
if (this.block2stateEntry.put(state.state, state) == null) { if (this.block2stateEntry.put(state.state, state) == null) {
sentries.add(state); sentries.add(state);
break; break;
@@ -225,7 +225,7 @@ public class Mapper {
//TODO:FIXME: IS VERY SLOW NEED TO MAKE IT LOCK FREE, or at minimum use a concurrent map //TODO:FIXME: IS VERY SLOW NEED TO MAKE IT LOCK FREE, or at minimum use a concurrent map
public long getBaseId(byte light, BlockState state, RegistryEntry<Biome> biome) { public long getBaseId(byte light, BlockState state, Holder<Biome> biome) {
if (state.isAir()) return Byte.toUnsignedLong(light) <<56;//Special case and fast return for air, dont care about the 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)); return composeMappingId(light, this.getIdForBlockState(state), this.getIdForBiome(biome));
} }
@@ -254,8 +254,8 @@ public class Mapper {
return this.blockId2stateEntry.get(blockId).opacity; return this.blockId2stateEntry.get(blockId).opacity;
} }
public int getIdForBiome(RegistryEntry<Biome> biome) { public int getIdForBiome(Holder<Biome> biome) {
String biomeId = biome.getKey().get().getValue().toString(); String biomeId = biome.unwrapKey().get().location().toString();
var entry = this.biome2biomeEntry.get(biomeId); var entry = this.biome2biomeEntry.get(biomeId);
if (entry == null) { if (entry == null) {
entry = this.registerNewBiome(biomeId); entry = this.registerNewBiome(biomeId);
@@ -354,13 +354,13 @@ public class Mapper {
if (state.getBlock() instanceof LeavesBlock) { if (state.getBlock() instanceof LeavesBlock) {
this.opacity = 15; this.opacity = 15;
} else { } else {
this.opacity = state.getOpacity(); this.opacity = state.getLightBlock();
} }
} }
public byte[] serialize() { public byte[] serialize() {
try { try {
var serialized = new NbtCompound(); var serialized = new CompoundTag();
serialized.putInt("id", this.id); serialized.putInt("id", this.id);
serialized.put("block_state", BlockState.CODEC.encodeStart(NbtOps.INSTANCE, this.state).result().get()); serialized.put("block_state", BlockState.CODEC.encodeStart(NbtOps.INSTANCE, this.state).result().get());
var out = new ByteArrayOutputStream(); var out = new ByteArrayOutputStream();
@@ -373,19 +373,19 @@ public class Mapper {
public static StateEntry deserialize(int id, byte[] data, boolean[] forceResave) { public static StateEntry deserialize(int id, byte[] data, boolean[] forceResave) {
try { try {
var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtSizeTracker.ofUnlimitedBytes()); var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtAccounter.unlimitedHeap());
if (compound.getInt("id", -1) != id) { if (compound.getIntOr("id", -1) != id) {
throw new IllegalStateException("Encoded id != expected id"); throw new IllegalStateException("Encoded id != expected id");
} }
var bsc = compound.getCompound("block_state").orElseThrow(); var bsc = compound.getCompound("block_state").orElseThrow();
var state = BlockState.CODEC.parse(NbtOps.INSTANCE, bsc); var state = BlockState.CODEC.parse(NbtOps.INSTANCE, bsc);
if (state.isError()) { if (state.isError()) {
Logger.info("Could not decode blockstate, attempting fixes, error: "+ state.error().get().message()); 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); state = BlockState.CODEC.parse(NbtOps.INSTANCE, bsc);
if (state.isError()) { if (state.isError()) {
Logger.error("Could not decode blockstate setting to air. id:" + id + " error: " + state.error().get().message()); 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 { } else {
Logger.info("Fixed blockstate to: " + state.getOrThrow()); Logger.info("Fixed blockstate to: " + state.getOrThrow());
forceResave[0] |= true; forceResave[0] |= true;
@@ -411,7 +411,7 @@ public class Mapper {
public byte[] serialize() { public byte[] serialize() {
try { try {
var serialized = new NbtCompound(); var serialized = new CompoundTag();
serialized.putInt("id", this.id); serialized.putInt("id", this.id);
serialized.putString("biome_id", this.biome); serialized.putString("biome_id", this.biome);
var out = new ByteArrayOutputStream(); var out = new ByteArrayOutputStream();
@@ -424,11 +424,11 @@ public class Mapper {
public static BiomeEntry deserialize(int id, byte[] data) { public static BiomeEntry deserialize(int id, byte[] data) {
try { try {
var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtSizeTracker.ofUnlimitedBytes()); var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtAccounter.unlimitedHeap());
if (compound.getInt("id", -1) != id) { if (compound.getIntOr("id", -1) != id) {
throw new IllegalStateException("Encoded id != expected 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); return new BiomeEntry(id, biome);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);

View File

@@ -10,12 +10,12 @@ import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.common.world.WorldUpdater; import me.cortex.voxy.common.world.WorldUpdater;
import me.cortex.voxy.commonImpl.VoxyCommon; import me.cortex.voxy.commonImpl.VoxyCommon;
import me.cortex.voxy.commonImpl.WorldIdentifier; import me.cortex.voxy.commonImpl.WorldIdentifier;
import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.core.SectionPos;
import net.minecraft.world.LightType; import net.minecraft.world.level.LightLayer;
import net.minecraft.world.chunk.ChunkNibbleArray; import net.minecraft.world.level.chunk.DataLayer;
import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.chunk.light.LightStorage; import net.minecraft.world.level.lighting.LayerLightSectionStorage;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
@@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentLinkedDeque;
public class VoxelIngestService { public class VoxelIngestService {
private static final ThreadLocal<VoxelizedSection> SECTION_CACHE = ThreadLocal.withInitial(VoxelizedSection::createEmpty); private static final ThreadLocal<VoxelizedSection> SECTION_CACHE = ThreadLocal.withInitial(VoxelizedSection::createEmpty);
private final Service service; 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<IngestSection> ingestQueue = new ConcurrentLinkedDeque<>(); private final ConcurrentLinkedDeque<IngestSection> ingestQueue = new ConcurrentLinkedDeque<>();
public VoxelIngestService(ServiceManager pool) { public VoxelIngestService(ServiceManager pool) {
@@ -37,14 +37,14 @@ public class VoxelIngestService {
var section = task.section; var section = task.section;
var vs = SECTION_CACHE.get().setPosition(task.cx, task.cy, task.cz); 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()); WorldUpdater.insertUpdate(task.world, vs.zero());
} else { } else {
VoxelizedSection csec = WorldConversionFactory.convert( VoxelizedSection csec = WorldConversionFactory.convert(
SECTION_CACHE.get(), SECTION_CACHE.get(),
task.world.getMapper(), task.world.getMapper(),
section.getBlockStateContainer(), section.getStates(),
section.getBiomeContainer(), section.getBiomes(),
getLightingSupplier(task) getLightingSupplier(task)
); );
WorldConversionFactory.mipSection(csec, task.world.getMapper()); WorldConversionFactory.mipSection(csec, task.world.getMapper());
@@ -57,8 +57,8 @@ public class VoxelIngestService {
ILightingSupplier supplier = (x,y,z) -> (byte) 0; ILightingSupplier supplier = (x,y,z) -> (byte) 0;
var sla = task.skyLight; var sla = task.skyLight;
var bla = task.blockLight; var bla = task.blockLight;
boolean sl = sla != null && !sla.isUninitialized(); boolean sl = sla != null && !sla.isEmpty();
boolean bl = bla != null && !bla.isUninitialized(); boolean bl = bla != null && !bla.isEmpty();
if (sl || bl) { if (sl || bl) {
if (sl && bl) { if (sl && bl) {
supplier = (x,y,z)-> { supplier = (x,y,z)-> {
@@ -83,11 +83,11 @@ public class VoxelIngestService {
return supplier; 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; return true;
} }
public boolean enqueueIngest(WorldEngine engine, WorldChunk chunk) { public boolean enqueueIngest(WorldEngine engine, LevelChunk chunk) {
if (!this.service.isLive()) { if (!this.service.isLive()) {
return false; return false;
} }
@@ -97,26 +97,26 @@ public class VoxelIngestService {
engine.markActive(); engine.markActive();
var lightingProvider = chunk.getWorld().getLightingProvider(); var lightingProvider = chunk.getLevel().getLightEngine();
boolean gotLighting = false; boolean gotLighting = false;
int i = chunk.getBottomSectionCoord() - 1; int i = chunk.getMinSectionY() - 1;
boolean allEmpty = true; boolean allEmpty = true;
for (var section : chunk.getSectionArray()) { for (var section : chunk.getSections()) {
i++; i++;
if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue; if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue;
allEmpty&=section.isEmpty(); allEmpty&=section.hasOnlyAir();
//if (section.isEmpty()) continue; //if (section.isEmpty()) continue;
var pos = ChunkSectionPos.from(chunk.getPos(), i); var pos = SectionPos.of(chunk.getPos(), i);
if (lightingProvider.getStatus(LightType.SKY, pos) != LightStorage.Status.LIGHT_AND_DATA && lightingProvider.getStatus(LightType.BLOCK, pos) != LightStorage.Status.LIGHT_AND_DATA) if (lightingProvider.getDebugSectionType(LightLayer.SKY, pos) != LayerLightSectionStorage.SectionType.LIGHT_AND_DATA && lightingProvider.getDebugSectionType(LightLayer.BLOCK, pos) != LayerLightSectionStorage.SectionType.LIGHT_AND_DATA)
continue; continue;
gotLighting = true; gotLighting = true;
} }
if (allEmpty&&!gotLighting) { if (allEmpty&&!gotLighting) {
//Special case all empty chunk columns, we need to clear it out //Special case all empty chunk columns, we need to clear it out
i = chunk.getBottomSectionCoord() - 1; i = chunk.getMinSectionY() - 1;
for (var section : chunk.getSectionArray()) { for (var section : chunk.getSections()) {
i++; i++;
if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue; 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)); 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; return false;
} }
var blp = lightingProvider.get(LightType.BLOCK); var blp = lightingProvider.getLayerListener(LightLayer.BLOCK);
var slp = lightingProvider.get(LightType.SKY); var slp = lightingProvider.getLayerListener(LightLayer.SKY);
i = chunk.getBottomSectionCoord() - 1; i = chunk.getMinSectionY() - 1;
for (var section : chunk.getSectionArray()) { for (var section : chunk.getSections()) {
i++; i++;
if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue; if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue;
//if (section.isEmpty()) 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) { if (bl != null) {
bl = bl.copy(); bl = bl.copy();
} }
var sl = slp.getLightSection(pos); var sl = slp.getDataLayerData(pos);
if (sl != null) { if (sl != null) {
sl = sl.copy(); sl = sl.copy();
} }
@@ -179,7 +179,7 @@ public class VoxelIngestService {
} }
//Utility method to ingest a chunk into the given WorldIdentifier or world //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; if (worldId == null) return false;
var instance = VoxyCommon.getInstance(); var instance = VoxyCommon.getInstance();
if (instance == null) return false; if (instance == null) return false;
@@ -190,11 +190,11 @@ public class VoxelIngestService {
} }
//Try to automatically ingest the chunk into the correct world //Try to automatically ingest the chunk into the correct world
public static boolean tryAutoIngestChunk(WorldChunk chunk) { public static boolean tryAutoIngestChunk(LevelChunk chunk) {
return tryIngestChunk(WorldIdentifier.of(chunk.getWorld()), 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)); this.ingestQueue.add(new IngestSection(x, y, z, engine, section, bl, sl));
try { try {
this.service.execute(); 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; if (id == null) return false;
var engine = id.getOrCreateEngine(); var engine = id.getOrCreateEngine();
if (engine == null) return false; if (engine == null) return false;
return rawIngest(engine, section, x, y, z, bl, sl); 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 (!shouldIngestSection(section, x, y, z)) return false;
if (engine.instanceIn == null) return false; if (engine.instanceIn == null) return false;
if (!engine.instanceIn.isIngestEnabled(null)) return false;//TODO: dont pass in null if (!engine.instanceIn.isIngestEnabled(null)) return false;//TODO: dont pass in null

View File

@@ -1,11 +1,11 @@
package me.cortex.voxy.commonImpl; package me.cortex.voxy.commonImpl;
import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldEngine;
import net.minecraft.registry.RegistryKey; import net.minecraft.core.registries.Registries;
import net.minecraft.registry.RegistryKeys; import net.minecraft.resources.ResourceKey;
import net.minecraft.util.Identifier; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -14,15 +14,15 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
public class WorldIdentifier { public class WorldIdentifier {
private static final RegistryKey<DimensionType> NULL_DIM_KEY = RegistryKey.of(RegistryKeys.DIMENSION_TYPE, Identifier.of("voxy:null_dimension_id")); private static final ResourceKey<DimensionType> NULL_DIM_KEY = ResourceKey.create(Registries.DIMENSION_TYPE, ResourceLocation.parse("voxy:null_dimension_id"));
public final RegistryKey<World> key; public final ResourceKey<Level> key;
public final long biomeSeed; public final long biomeSeed;
public final RegistryKey<DimensionType> dimension;//Maybe? public final ResourceKey<DimensionType> dimension;//Maybe?
private final transient long hashCode; private final transient long hashCode;
@Nullable transient WeakReference<WorldEngine> cachedEngineObject; @Nullable transient WeakReference<WorldEngine> cachedEngineObject;
public WorldIdentifier(@NotNull RegistryKey<World> key, long biomeSeed, @Nullable RegistryKey<DimensionType> dimension) { public WorldIdentifier(@NotNull ResourceKey<Level> key, long biomeSeed, @Nullable ResourceKey<DimensionType> dimension) {
if (key == null) { if (key == null) {
throw new IllegalStateException("Key cannot be null"); throw new IllegalStateException("Key cannot be null");
} }
@@ -50,10 +50,10 @@ public class WorldIdentifier {
return false; return false;
} }
private static <T> boolean equal(RegistryKey<T> a, RegistryKey<T> b) { private static <T> boolean equal(ResourceKey<T> a, ResourceKey<T> b) {
if (a == b) return true; if (a == b) return true;
if (a == null || b == null) return false; 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 //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); return instance.getNullable(this);
} }
public static WorldIdentifier of(World world) { public static WorldIdentifier of(Level world) {
//Gets or makes an identifier for world //Gets or makes an identifier for world
if (world == null) { if (world == null) {
return null; return null;
@@ -88,7 +88,7 @@ public class WorldIdentifier {
} }
//Common utility function to get or create a world engine //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); var id = of(world);
if (id == null) { if (id == null) {
return null; return null;
@@ -96,7 +96,7 @@ public class WorldIdentifier {
return id.getOrCreateEngine(); return id.getOrCreateEngine();
} }
public static WorldEngine ofEngineNullable(World world) { public static WorldEngine ofEngineNullable(Level world) {
var id = of(world); var id = of(world);
if (id == null) { if (id == null) {
return null; return null;
@@ -115,9 +115,9 @@ public class WorldIdentifier {
return this.hashCode; return this.hashCode;
} }
private static long registryKeyHashCode(RegistryKey<?> key) { private static long registryKeyHashCode(ResourceKey<?> key) {
var A = key.getRegistry(); var A = key.registry();
var B = key.getValue(); var B = key.location();
int a = A==null?0:A.hashCode(); int a = A==null?0:A.hashCode();
int b = B==null?0:B.hashCode(); int b = B==null?0:B.hashCode();
return (Integer.toUnsignedLong(a)<<32)|Integer.toUnsignedLong(b); return (Integer.toUnsignedLong(a)<<32)|Integer.toUnsignedLong(b);

View File

@@ -9,16 +9,16 @@ import me.cortex.voxy.common.voxelization.WorldConversionFactory;
import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.common.world.WorldUpdater; import me.cortex.voxy.common.world.WorldUpdater;
import me.cortex.voxy.common.world.other.Mapper; import me.cortex.voxy.common.world.other.Mapper;
import net.minecraft.block.Block; import net.minecraft.core.Holder;
import net.minecraft.block.BlockState; import net.minecraft.core.Registry;
import net.minecraft.block.Blocks; import net.minecraft.core.registries.Registries;
import net.minecraft.registry.Registry; import net.minecraft.resources.ResourceLocation;
import net.minecraft.registry.RegistryKeys; import net.minecraft.world.level.Level;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.world.level.biome.Biome;
import net.minecraft.util.Identifier; import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.World; import net.minecraft.world.level.block.Block;
import net.minecraft.world.biome.Biome; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.level.block.state.BlockState;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.tukaani.xz.BasicArrayCache; import org.tukaani.xz.BasicArrayCache;
import org.tukaani.xz.ResettableArrayCache; import org.tukaani.xz.ResettableArrayCache;
@@ -44,10 +44,10 @@ public class DHImporter implements IDataImporter {
private final Connection db; private final Connection db;
private final WorldEngine engine; private final WorldEngine engine;
private final Service service; private final Service service;
private final World world; private final Level world;
private final int bottomOfWorld; private final int bottomOfWorld;
private final int worldHeightSections; private final int worldHeightSections;
private final RegistryEntry.Reference<Biome> defaultBiome; private final Holder.Reference<Biome> defaultBiome;
private final Registry<Biome> biomeRegistry; private final Registry<Biome> biomeRegistry;
private final Registry<Block> blockRegistry; private final Registry<Block> blockRegistry;
private Thread runner; 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.engine = worldEngine;
this.world = mcWorld; this.world = mcWorld;
this.biomeRegistry = mcWorld.getRegistryManager().getOrThrow(RegistryKeys.BIOME); this.biomeRegistry = mcWorld.registryAccess().lookupOrThrow(Registries.BIOME);
this.defaultBiome = this.biomeRegistry.getOrThrow(BiomeKeys.PLAINS); this.defaultBiome = this.biomeRegistry.getOrThrow(Biomes.PLAINS);
this.blockRegistry = mcWorld.getRegistryManager().getOrThrow(RegistryKeys.BLOCK); this.blockRegistry = mcWorld.registryAccess().lookupOrThrow(Registries.BLOCK);
this.bottomOfWorld = mcWorld.getBottomY(); this.bottomOfWorld = mcWorld.getMinY();
int worldHeight = mcWorld.getHeight(); int worldHeight = mcWorld.getHeight();
this.worldHeightSections = (worldHeight+15)/16; this.worldHeightSections = (worldHeight+15)/16;
@@ -179,8 +179,8 @@ public class DHImporter implements IDataImporter {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
for (var prop : props) { for (var prop : props) {
String val = "NULL"; String val = "NULL";
if (state.contains(prop)) { if (state.hasProperty(prop)) {
val = state.get(prop).toString(); val = state.getValue(prop).toString();
} }
b.append("{").append(prop.getName()).append(":").append(val).append("}"); b.append("{").append(prop.getName()).append(":").append(val).append("}");
} }
@@ -205,8 +205,8 @@ public class DHImporter implements IDataImporter {
if (idx == -1) if (idx == -1)
throw new IllegalStateException(); throw new IllegalStateException();
{ {
var biomeRes = Identifier.of(encEntry.substring(0, idx)); var biomeRes = ResourceLocation.parse(encEntry.substring(0, idx));
var biome = this.biomeRegistry.getEntry(biomeRes).orElse(this.defaultBiome); var biome = this.biomeRegistry.get(biomeRes).orElse(this.defaultBiome);
biomeId = this.engine.getMapper().getIdForBiome(biome); biomeId = this.engine.getMapper().getIdForBiome(biome);
} }
{ {
@@ -219,16 +219,16 @@ public class DHImporter implements IDataImporter {
if (sIdx != -1) { if (sIdx != -1) {
bStateStr = encEntry.substring(sIdx + STATE_STRING_SEPARATOR.length()); bStateStr = encEntry.substring(sIdx + STATE_STRING_SEPARATOR.length());
} }
var bId = Identifier.of(encEntry.substring(b, sIdx != -1 ? sIdx : encEntry.length())); var bId = ResourceLocation.parse(encEntry.substring(b, sIdx != -1 ? sIdx : encEntry.length()));
var maybeBlock = this.blockRegistry.getEntry(bId); var maybeBlock = this.blockRegistry.get(bId);
Block block = Blocks.AIR; Block block = Blocks.AIR;
if (maybeBlock.isPresent()) { if (maybeBlock.isPresent()) {
block = maybeBlock.get().value(); block = maybeBlock.get().value();
} }
var state = block.getDefaultState(); var state = block.defaultBlockState();
if (bStateStr != null && block != Blocks.AIR) { if (bStateStr != null && block != Blocks.AIR) {
boolean found = false; boolean found = false;
for (BlockState bState : block.getStateManager().getStates()) { for (BlockState bState : block.getStateDefinition().getPossibleStates()) {
if (getSerialBlockState(bState).equals(bStateStr)) { if (getSerialBlockState(bState).equals(bStateStr)) {
state = bState; state = bState;
found = true; found = true;

View File

@@ -11,18 +11,23 @@ import me.cortex.voxy.common.voxelization.VoxelizedSection;
import me.cortex.voxy.common.voxelization.WorldConversionFactory; import me.cortex.voxy.common.voxelization.WorldConversionFactory;
import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.common.world.WorldUpdater; import me.cortex.voxy.common.world.WorldUpdater;
import net.minecraft.block.BlockState; import net.minecraft.core.Holder;
import net.minecraft.nbt.NbtCompound; import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.registry.RegistryKeys; import net.minecraft.world.level.Level;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.World; import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.biome.Biome; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.level.chunk.DataLayer;
import net.minecraft.world.chunk.*; import net.minecraft.world.level.chunk.PalettedContainer;
import net.minecraft.world.storage.ChunkCompressionFormat; 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.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile; import org.apache.commons.compress.archivers.zip.ZipFile;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
@@ -45,8 +50,8 @@ import java.util.function.Predicate;
public class WorldImporter implements IDataImporter { public class WorldImporter implements IDataImporter {
private final WorldEngine world; private final WorldEngine world;
private final ReadableContainer<RegistryEntry<Biome>> defaultBiomeProvider; private final PalettedContainerRO<Holder<Biome>> defaultBiomeProvider;
private final Codec<ReadableContainer<RegistryEntry<Biome>>> biomeCodec; private final Codec<PalettedContainerRO<Holder<Biome>>> biomeCodec;
private final Codec<PalettedContainer<BlockState>> blockStateCodec; private final Codec<PalettedContainer<BlockState>> blockStateCodec;
private final AtomicInteger estimatedTotalChunks = new AtomicInteger();//Slowly converges to the true value private final AtomicInteger estimatedTotalChunks = new AtomicInteger();//Slowly converges to the true value
private final AtomicInteger totalChunks = new AtomicInteger(); private final AtomicInteger totalChunks = new AtomicInteger();
@@ -57,65 +62,65 @@ public class WorldImporter implements IDataImporter {
private volatile boolean isRunning; 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.world = worldEngine;
this.service = sm.createService(()->new Pair<>(()->this.jobQueue.poll().run(), ()->{}), 3, "World importer", runChecker); this.service = sm.createService(()->new Pair<>(()->this.jobQueue.poll().run(), ()->{}), 3, "World importer", runChecker);
var biomeRegistry = mcWorld.getRegistryManager().getOrThrow(RegistryKeys.BIOME); var biomeRegistry = mcWorld.registryAccess().lookupOrThrow(Registries.BIOME);
var defaultBiome = biomeRegistry.getOrThrow(BiomeKeys.PLAINS); var defaultBiome = biomeRegistry.getOrThrow(Biomes.PLAINS);
this.defaultBiomeProvider = new ReadableContainer<>() { this.defaultBiomeProvider = new PalettedContainerRO<>() {
@Override @Override
public RegistryEntry<Biome> get(int x, int y, int z) { public Holder<Biome> get(int x, int y, int z) {
return defaultBiome; return defaultBiome;
} }
@Override @Override
public void forEachValue(Consumer<RegistryEntry<Biome>> action) { public void getAll(Consumer<Holder<Biome>> action) {
} }
@Override @Override
public void writePacket(PacketByteBuf buf) { public void write(FriendlyByteBuf buf) {
} }
@Override @Override
public int getPacketSize() { public int getSerializedSize() {
return 0; return 0;
} }
@Override @Override
public int getElementBits() { public int bitsPerEntry() {
return 0; return 0;
} }
@Override @Override
public boolean hasAny(Predicate<RegistryEntry<Biome>> predicate) { public boolean maybeHas(Predicate<Holder<Biome>> predicate) {
return false; return false;
} }
@Override @Override
public void count(PalettedContainer.Counter<RegistryEntry<Biome>> counter) { public void count(PalettedContainer.CountConsumer<Holder<Biome>> counter) {
} }
@Override @Override
public PalettedContainer<RegistryEntry<Biome>> copy() { public PalettedContainer<Holder<Biome>> copy() {
return null; return null;
} }
@Override @Override
public PalettedContainer<RegistryEntry<Biome>> slice() { public PalettedContainer<Holder<Biome>> recreate() {
return null; return null;
} }
@Override @Override
public Serialized<RegistryEntry<Biome>> serialize(PaletteProvider<RegistryEntry<Biome>> provider) { public PackedData<Holder<Biome>> pack(Strategy<Holder<Biome>> provider) {
return null; return null;
} }
}; };
var factory = PalettesFactory.fromRegistryManager(mcWorld.getRegistryManager()); var factory = PalettedContainerFactory.create(mcWorld.registryAccess());
this.biomeCodec = factory.biomeContainerCodec(); this.biomeCodec = factory.biomeContainerCodec();
this.blockStateCodec = factory.blockStatesContainerCodec(); this.blockStateCodec = factory.blockStatesContainerCodec();
} }
@@ -379,7 +384,7 @@ public class WorldImporter implements IDataImporter {
if (decompressedData == null) { if (decompressedData == null) {
Logger.error("Error decompressing chunk data"); Logger.error("Error decompressing chunk data");
} else { } else {
var nbt = NbtIo.readCompound(decompressedData); var nbt = NbtIo.read(decompressedData);
this.importChunkNBT(nbt, x, z); this.importChunkNBT(nbt, x, z);
} }
} }
@@ -424,7 +429,7 @@ public class WorldImporter implements IDataImporter {
} }
private DataInputStream decompress(byte flags, MemoryBuffer stream) throws IOException { private DataInputStream decompress(byte flags, MemoryBuffer stream) throws IOException {
ChunkCompressionFormat chunkStreamVersion = ChunkCompressionFormat.get(flags); RegionFileVersion chunkStreamVersion = RegionFileVersion.fromId(flags);
if (chunkStreamVersion == null) { if (chunkStreamVersion == null) {
Logger.error("Chunk has invalid chunk stream version"); Logger.error("Chunk has invalid chunk stream version");
return null; 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")) { if (!chunk.contains("Status")) {
//Its not real so decrement the chunk //Its not real so decrement the chunk
this.totalChunks.decrementAndGet(); this.totalChunks.decrementAndGet();
@@ -441,22 +446,22 @@ public class WorldImporter implements IDataImporter {
} }
//Dont process non full chunk sections //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 if (status != ChunkStatus.FULL && status != ChunkStatus.EMPTY) {//We also import empty since they are from data upgrade
this.totalChunks.decrementAndGet(); this.totalChunks.decrementAndGet();
return; return;
} }
try { try {
int x = chunk.getInt("xPos", Integer.MIN_VALUE); int x = chunk.getIntOr("xPos", Integer.MIN_VALUE);
int z = chunk.getInt("zPos", Integer.MIN_VALUE); int z = chunk.getIntOr("zPos", Integer.MIN_VALUE);
if (x>>5 != regionX || z>>5 != regionZ) { 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"); 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()) { for (var sectionE : chunk.getList("sections").orElseThrow()) {
var section = (NbtCompound) sectionE; var section = (CompoundTag) sectionE;
int y = section.getInt("Y", Integer.MIN_VALUE); int y = section.getIntOr("Y", Integer.MIN_VALUE);
this.importSectionNBT(x, y, z, section); this.importSectionNBT(x, y, z, section);
} }
} catch (Exception e) { } catch (Exception e) {
@@ -468,7 +473,7 @@ public class WorldImporter implements IDataImporter {
private static final byte[] EMPTY = new byte[0]; private static final byte[] EMPTY = new byte[0];
private static final ThreadLocal<VoxelizedSection> SECTION_CACHE = ThreadLocal.withInitial(VoxelizedSection::createEmpty); private static final ThreadLocal<VoxelizedSection> 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()) { if (section.getCompound("block_states").isEmpty()) {
return; return;
} }
@@ -476,16 +481,16 @@ public class WorldImporter implements IDataImporter {
byte[] blockLightData = section.getByteArray("BlockLight").orElse(EMPTY); byte[] blockLightData = section.getByteArray("BlockLight").orElse(EMPTY);
byte[] skyLightData = section.getByteArray("SkyLight").orElse(EMPTY); byte[] skyLightData = section.getByteArray("SkyLight").orElse(EMPTY);
ChunkNibbleArray blockLight; DataLayer blockLight;
if (blockLightData.length != 0) { if (blockLightData.length != 0) {
blockLight = new ChunkNibbleArray(blockLightData); blockLight = new DataLayer(blockLightData);
} else { } else {
blockLight = null; blockLight = null;
} }
ChunkNibbleArray skyLight; DataLayer skyLight;
if (skyLightData.length != 0) { if (skyLightData.length != 0) {
skyLight = new ChunkNibbleArray(skyLightData); skyLight = new DataLayer(skyLightData);
} else { } else {
skyLight = null; skyLight = null;
} }

View File

@@ -3,10 +3,10 @@ package me.cortex.voxy.commonImpl.mixin.chunky;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.cortex.voxy.common.world.service.VoxelIngestService; import me.cortex.voxy.common.world.service.VoxelIngestService;
import net.minecraft.server.world.OptionalChunk; import net.minecraft.server.level.ChunkResult;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.level.chunk.status.ChunkStatus;
import org.popcraft.chunky.mixin.ServerChunkCacheMixin; import org.popcraft.chunky.mixin.ServerChunkCacheMixin;
import org.popcraft.chunky.platform.FabricWorld; import org.popcraft.chunky.platform.FabricWorld;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -17,14 +17,14 @@ import java.util.concurrent.CompletableFuture;
@Mixin(FabricWorld.class) @Mixin(FabricWorld.class)
public class MixinFabricWorld { 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;")) @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<OptionalChunk<Chunk>> captureGeneratedChunk(ServerChunkCacheMixin instance, int i, int j, ChunkStatus chunkStatus, boolean b, Operation<CompletableFuture<OptionalChunk<Chunk>>> original) { private CompletableFuture<ChunkResult<ChunkAccess>> captureGeneratedChunk(ServerChunkCacheMixin instance, int i, int j, ChunkStatus chunkStatus, boolean b, Operation<CompletableFuture<ChunkResult<ChunkAccess>>> original) {
var future = original.call(instance, i, j, chunkStatus, b); var future = original.call(instance, i, j, chunkStatus, b);
if (false) {//TODO: ADD SERVER CONFIG THING if (false) {//TODO: ADD SERVER CONFIG THING
return future; return future;
} else { } else {
return future.thenApply(res -> { return future.thenApply(res -> {
res.ifPresent(chunk -> { res.ifSuccess(chunk -> {
if (chunk instanceof WorldChunk worldChunk) { if (chunk instanceof LevelChunk worldChunk) {
VoxelIngestService.tryAutoIngestChunk(worldChunk); VoxelIngestService.tryAutoIngestChunk(worldChunk);
} }
}); });

View File

@@ -2,35 +2,35 @@ package me.cortex.voxy.commonImpl.mixin.minecraft;
import me.cortex.voxy.commonImpl.IWorldGetIdentifier; import me.cortex.voxy.commonImpl.IWorldGetIdentifier;
import me.cortex.voxy.commonImpl.WorldIdentifier; import me.cortex.voxy.commonImpl.WorldIdentifier;
import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.core.Holder;
import net.minecraft.registry.RegistryKey; import net.minecraft.core.RegistryAccess;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.resources.ResourceKey;
import net.minecraft.world.MutableWorldProperties; import net.minecraft.world.level.Level;
import net.minecraft.world.World; import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.level.storage.WritableLevelData;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(World.class) @Mixin(Level.class)
public class MixinWorld implements IWorldGetIdentifier { public class MixinWorld implements IWorldGetIdentifier {
@Unique @Unique
private WorldIdentifier identifier; private WorldIdentifier identifier;
@Inject(method = "<init>", at = @At("RETURN")) @Inject(method = "<init>", at = @At("RETURN"))
private void voxy$injectIdentifier(MutableWorldProperties properties, private void voxy$injectIdentifier(WritableLevelData properties,
RegistryKey<World> key, ResourceKey<Level> key,
DynamicRegistryManager registryManager, RegistryAccess registryManager,
RegistryEntry<DimensionType> dimensionEntry, Holder<DimensionType> dimensionEntry,
boolean isClient, boolean isClient,
boolean debugWorld, boolean debugWorld,
long seed, long seed,
int maxChainedNeighborUpdates, int maxChainedNeighborUpdates,
CallbackInfo ci) { CallbackInfo ci) {
if (key != null) { 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 { } else {
this.identifier = null; this.identifier = null;
} }

View File

@@ -1,38 +1,25 @@
accessWidener v1 named accessWidener v1 named
accessible class net/minecraft/client/render/RenderLayer$MultiPhase accessible class net/minecraft/client/multiplayer/ClientChunkCache$Storage
accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters 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/multiplayer/ClientLevel levelRenderer Lnet/minecraft/client/renderer/LevelRenderer;
accessible field net/minecraft/client/render/Frustum frustumIntersection Lorg/joml/FrustumIntersection; accessible field com/mojang/blaze3d/opengl/GlBuffer handle I
accessible field net/minecraft/client/color/block/BlockColors providers Lnet/minecraft/util/collection/IdList; accessible field net/minecraft/client/color/block/BlockColors blockColors Lnet/minecraft/core/IdMapper;
accessible field net/minecraft/client/world/ClientWorld worldRenderer Lnet/minecraft/client/render/WorldRenderer; accessible field net/minecraft/client/renderer/texture/TextureAtlas mipLevel I
accessible field net/minecraft/world/biome/source/BiomeAccess seed J 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/renderer/RenderType$CompositeRenderType state Lnet/minecraft/client/renderer/RenderType$CompositeState;
accessible field net/minecraft/client/render/RenderLayer$MultiPhase phases Lnet/minecraft/client/render/RenderLayer$MultiPhaseParameters; accessible field net/minecraft/client/renderer/RenderType$CompositeState textureState Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard;
accessible field net/minecraft/client/network/ClientPlayerInteractionManager networkHandler Lnet/minecraft/client/network/ClientPlayNetworkHandler; 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/renderer/texture/MipmapGenerator alphaBlend (IIIIZ)I
accessible method net/minecraft/client/render/RenderPhase$TextureBase getId ()Ljava/util/Optional; 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 method net/minecraft/client/multiplayer/ClientChunkCache$Storage getChunk (I)Lnet/minecraft/world/level/chunk/LevelChunk;
accessible field net/minecraft/world/chunk/PalettedContainer$Data storage Lnet/minecraft/util/collection/PaletteStorage; accessible method net/minecraft/client/multiplayer/ClientChunkCache$Storage getIndex (II)I
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