Config and fixes for world managing
This commit is contained in:
@@ -31,6 +31,10 @@ public class VoxyClientInstance extends VoxyInstance {
|
||||
vworld = this.createWorld(SELECTOR.getBestSelectionOrCreate(world).createSectionStorageBackend());
|
||||
((IVoxyWorldSetter)world).setWorldEngine(vworld);
|
||||
this.importWrapper = new WorldImportWrapper(this.threadPool, vworld);
|
||||
} else {
|
||||
if (!this.activeWorlds.contains(vworld)) {
|
||||
throw new IllegalStateException("World referenced does not exist in instance");
|
||||
}
|
||||
}
|
||||
return vworld;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package me.cortex.voxy.client.config;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
|
||||
import me.cortex.voxy.commonImpl.IVoxyWorldGetter;
|
||||
import me.cortex.voxy.commonImpl.IVoxyWorldSetter;
|
||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||
@@ -36,13 +38,24 @@ public class VoxyConfigScreenFactory implements ModMenuApi {
|
||||
|
||||
builder.setSavingRunnable(() -> {
|
||||
//After saving the core should be reloaded/reset
|
||||
var world = MinecraftClient.getInstance().worldRenderer;
|
||||
if (world != null && ON_SAVE_RELOAD) {
|
||||
var worldRenderer = MinecraftClient.getInstance().worldRenderer;
|
||||
var world = MinecraftClient.getInstance().world;
|
||||
if (worldRenderer != null && world != null && ON_SAVE_RELOAD) {
|
||||
//Reload voxy
|
||||
((IGetVoxyRenderSystem)world).shutdownRenderer();
|
||||
((IGetVoxyRenderSystem)worldRenderer).shutdownRenderer();
|
||||
|
||||
//This is a hack inserted for the client world thing
|
||||
//TODO: FIXME: MAKE BETTER
|
||||
var engine = ((IVoxyWorldGetter)world).getWorldEngine();
|
||||
if (engine != null) {
|
||||
VoxyCommon.getInstance().stopWorld(engine);
|
||||
}
|
||||
((IVoxyWorldSetter)world).setWorldEngine(null);
|
||||
|
||||
|
||||
VoxyCommon.shutdownInstance();
|
||||
VoxyCommon.createInstance();
|
||||
((IGetVoxyRenderSystem)world).createRenderer();
|
||||
((IGetVoxyRenderSystem)worldRenderer).createRenderer();
|
||||
}
|
||||
ON_SAVE_RELOAD = false;
|
||||
VoxyConfig.CONFIG.save();
|
||||
@@ -71,6 +84,12 @@ public class VoxyConfigScreenFactory implements ModMenuApi {
|
||||
.setDefaultValue(DEFAULT.ingestEnabled)
|
||||
.build());
|
||||
|
||||
category.addEntry(entryBuilder.startBooleanToggle(Text.translatable("voxy.config.general.rendering"), config.enableRendering)
|
||||
.setTooltip(Text.translatable("voxy.config.general.rendering.tooltip"))
|
||||
.setSaveConsumer(val -> {if (config.enableRendering != val) reload(); config.enableRendering = val;})
|
||||
.setDefaultValue(DEFAULT.enableRendering)
|
||||
.build());
|
||||
|
||||
category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.subDivisionSize"), (int) config.subDivisionSize, 25, 256)
|
||||
.setTooltip(Text.translatable("voxy.config.general.subDivisionSize.tooltip"))
|
||||
.setSaveConsumer(val -> config.subDivisionSize = val)
|
||||
|
||||
@@ -143,7 +143,7 @@ public class NodeManager {
|
||||
long pos = sectionResult.position;
|
||||
int nodeId = this.activeSectionMap.get(pos);
|
||||
if (nodeId == -1) {
|
||||
Logger.error("Got geometry update for pos " + WorldEngine.pprintPos(pos) + " but it was not in active map, discarding!");
|
||||
Logger.warn("Got geometry update for pos " + WorldEngine.pprintPos(pos) + " but it was not in active map, discarding!");
|
||||
sectionResult.free();
|
||||
return;
|
||||
}
|
||||
@@ -988,7 +988,7 @@ public class NodeManager {
|
||||
|
||||
if (childExistence == 0) {
|
||||
if (!this.topLevelNodes.contains(pos)) {//Top level nodes are special, as they can have a request with child existence of 0 for performance reasons
|
||||
Logger.warn("Not creating a leaf request with existence mask of 0");
|
||||
Logger.warn("Not creating a leaf request with existence mask of 0 at pos", WorldEngine.pprintPos(pos));
|
||||
this.nodeData.unmarkRequestInFlight(nodeId);
|
||||
this.invalidateNode(nodeId);
|
||||
return;
|
||||
|
||||
@@ -7,6 +7,7 @@ import me.cortex.voxy.client.core.rendering.VoxyRenderSystem;
|
||||
import me.cortex.voxy.common.Logger;
|
||||
import me.cortex.voxy.common.world.WorldEngine;
|
||||
import me.cortex.voxy.commonImpl.IVoxyWorldGetter;
|
||||
import me.cortex.voxy.commonImpl.IVoxyWorldSetter;
|
||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||
import me.cortex.voxy.commonImpl.VoxyInstance;
|
||||
import net.minecraft.client.render.*;
|
||||
@@ -50,7 +51,7 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem {
|
||||
@Unique private ClientWorld refCopy;
|
||||
|
||||
@Inject(method = "setWorld", at = @At("HEAD"))
|
||||
private void initVoxelCore(ClientWorld world, CallbackInfo ci) {
|
||||
private void voxy$captureSetWorld(ClientWorld world, CallbackInfo ci) {
|
||||
this.refCopy = this.world;
|
||||
}
|
||||
|
||||
@@ -65,6 +66,7 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem {
|
||||
if (engine != null) {
|
||||
VoxyCommon.getInstance().stopWorld(engine);
|
||||
}
|
||||
((IVoxyWorldSetter)this.refCopy).setWorldEngine(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.cortex.voxy.client.mixin.sodium;
|
||||
|
||||
import me.cortex.voxy.client.VoxyClientInstance;
|
||||
import me.cortex.voxy.client.config.VoxyConfig;
|
||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionManager;
|
||||
@@ -20,7 +21,14 @@ public class MixinRenderSectionManager {
|
||||
//TODO: Am not quite sure if this is right
|
||||
var instance = VoxyCommon.getInstance();
|
||||
if (instance != null && VoxyConfig.CONFIG.ingestEnabled) {
|
||||
instance.getIngestService().enqueueIngest(this.level.getChunk(x, z), false);
|
||||
var chunk = this.level.getChunk(x, z);
|
||||
var world = chunk.getWorld();
|
||||
if (world instanceof ClientWorld cw) {
|
||||
var engine = ((VoxyClientInstance)instance).getOrMakeRenderWorld(cw);
|
||||
if (engine != null) {
|
||||
instance.getIngestService().enqueueIngest(engine, chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,9 @@ public class VoxelIngestService {
|
||||
}
|
||||
|
||||
public void enqueueIngest(WorldEngine engine, WorldChunk chunk) {
|
||||
if (!engine.isLive()) {
|
||||
throw new IllegalStateException("Tried inserting chunk into WorldEngine that was not alive");
|
||||
}
|
||||
var lightingProvider = chunk.getWorld().getLightingProvider();
|
||||
var blp = lightingProvider.get(LightType.BLOCK);
|
||||
var slp = lightingProvider.get(LightType.SKY);
|
||||
|
||||
@@ -6,7 +6,10 @@ import me.cortex.voxy.commonImpl.IVoxyWorldGetter;
|
||||
import me.cortex.voxy.commonImpl.IVoxyWorldSetter;
|
||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.block.NeighborUpdater;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -14,6 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(World.class)
|
||||
public class MixinWorld implements IVoxyWorldGetter, IVoxyWorldSetter {
|
||||
@Shadow @Final protected NeighborUpdater neighborUpdater;
|
||||
@Unique private WorldEngine voxyWorld;
|
||||
|
||||
@Override
|
||||
@@ -23,7 +27,7 @@ public class MixinWorld implements IVoxyWorldGetter, IVoxyWorldSetter {
|
||||
|
||||
@Override
|
||||
public void setWorldEngine(WorldEngine engine) {
|
||||
if (this.voxyWorld != null) {
|
||||
if (engine != null && this.voxyWorld != null) {
|
||||
throw new IllegalStateException("WorldEngine not null");
|
||||
}
|
||||
this.voxyWorld = engine;
|
||||
|
||||
Reference in New Issue
Block a user