First update. NOTE MEM LEAK NOTED!!!!
This commit is contained in:
@@ -2,6 +2,8 @@ package com.seibel.lod.common.wrappers.chunk;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.seibel.lod.core.util.LevelPosUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.common.wrappers.block.BlockPosWrapper;
|
||||
@@ -83,13 +85,13 @@ public class ChunkPosWrapper extends AbstractChunkPosWrapper
|
||||
@Override
|
||||
public int getRegionX()
|
||||
{
|
||||
return chunkPos.getRegionX();
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunkPos.x, LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionZ()
|
||||
{
|
||||
return chunkPos.getRegionZ();
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunkPos.z, LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
public ChunkPos getChunkPos()
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.seibel.lod.common.wrappers.chunk;
|
||||
|
||||
import com.seibel.lod.core.util.LevelPosUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.IBlockColorWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.IBlockShapeWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
@@ -102,12 +104,12 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
@Override
|
||||
public int getRegionPosX(){
|
||||
return chunk.getPos().getRegionX();
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, getChunkPosX(), LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionPosZ(){
|
||||
return chunk.getPos().getRegionZ();
|
||||
return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, getChunkPosZ(), LodUtil.REGION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-5
@@ -212,7 +212,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAddPoint(int px, int pz, int range, Steps target) {
|
||||
public boolean tryAddPoint(int px, int pz, int range, Steps target, boolean genAllDetails) {
|
||||
int boxSize = range * 2 + 1;
|
||||
int x = Math.floorDiv(px, boxSize) * boxSize + range;
|
||||
int z = Math.floorDiv(pz, boxSize) * boxSize + range;
|
||||
@@ -222,7 +222,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
return false;
|
||||
}
|
||||
// System.out.println(x + ", "+z);
|
||||
events.add(new GenerationEvent(new ChunkPos(x, z), range, this, target));
|
||||
events.add(new GenerationEvent(new ChunkPos(x, z), range, this, target, genAllDetails));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -369,13 +369,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
if (ENABLE_LOAD_EVENT_LOGGING)
|
||||
ClientApi.LOGGER.info("Detected full existing chunk at {}", target.getPos());
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
new LodBuilderConfig(DistanceGenerationMode.FULL), true);
|
||||
new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails);
|
||||
} else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE) {
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
LodBuilderConfig.getFillVoidConfig(), true);
|
||||
LodBuilderConfig.getFillVoidConfig(), true, e.genAllDetails);
|
||||
} else {
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
new LodBuilderConfig(generationMode), true);
|
||||
new LodBuilderConfig(generationMode), true, e.genAllDetails);
|
||||
}
|
||||
if (e.lightMode == LightGenerationMode.FANCY || isFull) {
|
||||
lightEngine.retainData(target.getPos(), false);
|
||||
|
||||
+3
-1
@@ -27,8 +27,9 @@ public final class GenerationEvent {
|
||||
final Steps target;
|
||||
final LightGenerationMode lightMode;
|
||||
final PrefEvent pEvent = new PrefEvent();
|
||||
final boolean genAllDetails;
|
||||
|
||||
public GenerationEvent(ChunkPos pos, int range, BatchGenerationEnvironment generationGroup, Steps target) {
|
||||
public GenerationEvent(ChunkPos pos, int range, BatchGenerationEnvironment generationGroup, Steps target, boolean genAllDetails) {
|
||||
nanotime = System.nanoTime();
|
||||
this.pos = pos;
|
||||
this.range = range;
|
||||
@@ -38,6 +39,7 @@ public final class GenerationEvent {
|
||||
LightGenerationMode mode = CONFIG.client().worldGenerator().getLightGenerationMode();
|
||||
|
||||
this.lightMode = mode;
|
||||
this.genAllDetails = genAllDetails;
|
||||
|
||||
future = generationGroup.executors.submit(() -> {
|
||||
generationGroup.generateLodFromList(this);
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper {
|
||||
if (ca == null)
|
||||
throw new RuntimeException("This should NEVER be null due to bool being true");
|
||||
lodBuilder.generateLodNodeFromChunk(lodDim, new ChunkWrapper(ca, serverWorld),
|
||||
new LodBuilderConfig(generationMode), false);
|
||||
new LodBuilderConfig(generationMode), false, true);
|
||||
|
||||
// long duration = System.nanoTime()-t;
|
||||
|
||||
|
||||
+1
-1
Submodule core updated: 09b2d952b6...1b27161518
@@ -21,6 +21,7 @@ package com.seibel.lod.fabric;
|
||||
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.api.EventApi;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.DimensionTypeWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.WorldWrapper;
|
||||
@@ -46,6 +47,10 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
@@ -154,30 +159,39 @@ public class ClientProxy
|
||||
eventApi.blockChangeEvent(chunk, dimType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// The debug mode keybinding, which will be registered
|
||||
public static final KeyMapping DebugToggle = KeyBindingHelper.registerKeyBinding(
|
||||
new KeyMapping("key.lod.DebugToggle", GLFW.GLFW_KEY_F8, "key.lod.category"));
|
||||
|
||||
// The draw toggle keybinding, which will be registered
|
||||
public static final KeyMapping DrawToggle = KeyBindingHelper.registerKeyBinding(
|
||||
new KeyMapping("key.lod.DrawToggle", GLFW.GLFW_KEY_F6, "key.lod.category"));
|
||||
|
||||
boolean PreDebugToggle = false;
|
||||
boolean PreDrawToggle = false;
|
||||
private static final int[] KEY_TO_CHECK_FOR = {GLFW.GLFW_KEY_F6, GLFW.GLFW_KEY_F8};
|
||||
|
||||
HashSet<Integer> previousKeyDown = new HashSet<Integer>();
|
||||
|
||||
public void onKeyInput() {
|
||||
ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
if (CONFIG.client().advanced().debugging().getDebugKeybindingsEnabled())
|
||||
{
|
||||
// Only activates when you press the key
|
||||
if (DebugToggle.isDown() && DebugToggle.isDown() != PreDebugToggle)
|
||||
CONFIG.client().advanced().debugging().setDebugMode(CONFIG.client().advanced().debugging().getDebugMode().getNext());
|
||||
|
||||
if (DrawToggle.isDown() && DrawToggle.isDown() != PreDebugToggle)
|
||||
CONFIG.client().advanced().debugging().setDrawLods(!CONFIG.client().advanced().debugging().getDrawLods());
|
||||
HashSet<Integer> currectKeyDown = new HashSet<Integer>();
|
||||
|
||||
// Note: Minecraft's InputConstants is same as GLFW Key values
|
||||
//TODO: Use mixin to hook directly into the GLFW Keyboard event in minecraft KeyboardHandler
|
||||
// Check all keys we need
|
||||
for (int i = GLFW.GLFW_KEY_A; i <= GLFW.GLFW_KEY_Z; i++) {
|
||||
if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), i)) {
|
||||
currectKeyDown.add(i);
|
||||
}
|
||||
}
|
||||
for (int i : KEY_TO_CHECK_FOR) {
|
||||
if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), i)) {
|
||||
currectKeyDown.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Diff and trigger events
|
||||
for (int c : currectKeyDown) {
|
||||
if (!previousKeyDown.contains(c)) {
|
||||
ClientApi.INSTANCE.keyPressedEvent(c);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the set
|
||||
previousKeyDown = currectKeyDown;
|
||||
}
|
||||
PreDebugToggle = DebugToggle.isDown();
|
||||
PreDrawToggle = DrawToggle.isDown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,14 @@ package com.seibel.lod.forge;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.api.EventApi;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.DimensionTypeWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.WorldWrapper;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
@@ -102,7 +106,9 @@ public class ForgeClientProxy
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event)
|
||||
{
|
||||
eventApi.onKeyInput(event.getKey(), event.getAction());
|
||||
if (Minecraft.getInstance().player == null) return;
|
||||
if (event.getAction() != GLFW.GLFW_PRESS) return;
|
||||
clientApi.keyPressedEvent(event.getKey());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user