changes to ingest
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package me.cortex.voxy.client;
|
||||
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
public interface ICheekyClientChunkManager {
|
||||
WorldChunk voxy$cheekyGetChunk(int x, int z);
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package me.cortex.voxy.client.mixin.minecraft;
|
||||
|
||||
import me.cortex.voxy.client.ICheekyClientChunkManager;
|
||||
import me.cortex.voxy.client.config.VoxyConfig;
|
||||
import me.cortex.voxy.common.world.service.VoxelIngestService;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.world.ClientChunkManager;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
@@ -13,18 +15,21 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClientChunkManager.class)
|
||||
public class MixinClientChunkManager {
|
||||
public class MixinClientChunkManager implements ICheekyClientChunkManager {
|
||||
@Unique
|
||||
private static final boolean BOBBY_INSTALLED = FabricLoader.getInstance().isModLoaded("bobby");
|
||||
|
||||
@Shadow volatile ClientChunkManager.ClientChunkMap chunks;
|
||||
|
||||
@Unique
|
||||
private WorldChunk voxy$cheekyGetChunk(int x, int z) {
|
||||
@Override
|
||||
public WorldChunk voxy$cheekyGetChunk(int x, int z) {
|
||||
//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));
|
||||
}
|
||||
|
||||
@Inject(method = "unload", at = @At("HEAD"))
|
||||
public void voxy$captureChunkBeforeUnload(ChunkPos pos, CallbackInfo ci) {
|
||||
if (VoxyConfig.CONFIG.ingestEnabled) {
|
||||
if (VoxyConfig.CONFIG.ingestEnabled && BOBBY_INSTALLED) {
|
||||
var chunk = this.voxy$cheekyGetChunk(pos.x, pos.z);
|
||||
if (chunk != null) {
|
||||
VoxelIngestService.tryAutoIngestChunk(chunk);
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
package me.cortex.voxy.client.mixin.sodium;
|
||||
|
||||
import me.cortex.voxy.client.ICheekyClientChunkManager;
|
||||
import me.cortex.voxy.client.config.VoxyConfig;
|
||||
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
|
||||
import me.cortex.voxy.client.core.VoxyRenderSystem;
|
||||
import me.cortex.voxy.common.world.service.VoxelIngestService;
|
||||
import net.caffeinemc.mods.sodium.client.gl.device.CommandList;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionManager;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.data.BuiltSectionInfo;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -18,6 +25,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = RenderSectionManager.class, remap = false)
|
||||
public class MixinRenderSectionManager {
|
||||
@Unique
|
||||
private static final boolean BOBBY_INSTALLED = FabricLoader.getInstance().isModLoaded("bobby");
|
||||
|
||||
@Shadow @Final private ClientWorld level;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
@@ -30,6 +40,20 @@ public class MixinRenderSectionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "onChunkRemoved", at = @At("HEAD"))
|
||||
private void injectIngest(int x, int z, CallbackInfo ci) {
|
||||
//TODO: Am not quite sure if this is right
|
||||
if (VoxyConfig.CONFIG.ingestEnabled && !BOBBY_INSTALLED) {
|
||||
var cccm = (ICheekyClientChunkManager)this.level.getChunkManager();
|
||||
if (cccm != null) {
|
||||
var chunk = cccm.voxy$cheekyGetChunk(x, z);
|
||||
if (chunk != null) {
|
||||
VoxelIngestService.tryAutoIngestChunk(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Inject(method = "onChunkAdded", at = @At("HEAD"))
|
||||
private void voxy$trackChunkAdd(int x, int z, CallbackInfo ci) {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class VoxelIngestService {
|
||||
if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue;
|
||||
//if (section.isEmpty()) continue;
|
||||
var pos = ChunkSectionPos.from(chunk.getPos(), i);
|
||||
if (lightingProvider.getStatus(LightType.SKY, pos) != LightStorage.Status.LIGHT_AND_DATA || lightingProvider.getStatus(LightType.BLOCK, pos) != LightStorage.Status.LIGHT_AND_DATA)
|
||||
if (lightingProvider.getStatus(LightType.SKY, pos) != LightStorage.Status.LIGHT_AND_DATA && lightingProvider.getStatus(LightType.BLOCK, pos) != LightStorage.Status.LIGHT_AND_DATA)
|
||||
continue;
|
||||
gotLighting = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user