Update core & comment out debug. Fixed/Cleaned up Fabric/Forge warpper

This commit is contained in:
tom lee
2022-01-06 16:28:25 +08:00
parent 6aa6c32299
commit e23244181a
5 changed files with 41 additions and 23 deletions
@@ -126,8 +126,23 @@ public class ExperimentalGenerator extends AbstractExperimentalWorldGeneratorWra
if (priority == GenerationPriority.FAR_FIRST) {
int nearCount = posToGenerate.getNumberOfNearPos();
int farCount = posToGenerate.getNumberOfFarPos();
//ClientApi.LOGGER.info("WorldGen. Near:"+nearCount+" Far:"+farCount);
int maxIteration = Math.max(nearCount, farCount);
for (int i = 0; i < maxIteration; i++) {
// We have farPos to go though
if (i < farCount && posToGenerate.getNthDetail(i, false) != 0) {
positionGoneThough++;
// TODO: Add comment here on why theres a '-1'.
// Not sure what's happening here. This is copied from previous codes.
byte detailLevel = (byte) (posToGenerate.getNthDetail(i, false) - 1);
int chunkX = LevelPosUtil.getChunkPos(detailLevel, posToGenerate.getNthPosX(i, false));
int chunkZ = LevelPosUtil.getChunkPos(detailLevel, posToGenerate.getNthPosZ(i, false));
if (generationGroup.tryAddPoint(chunkX, chunkZ, generationGroupSizeFar, targetStep)) {
//ClientApi.LOGGER.info("WorldGen added 1 far point");
toGenerate--;
}
}
// We have nearPos to go though
if (i < nearCount && posToGenerate.getNthDetail(i, true) != 0) {
@@ -139,22 +154,11 @@ public class ExperimentalGenerator extends AbstractExperimentalWorldGeneratorWra
int chunkZ = LevelPosUtil.getChunkPos(detailLevel, posToGenerate.getNthPosZ(i, true));
int genSize = detailLevel > LodUtil.CHUNK_DETAIL_LEVEL ? 0 : generationGroupSize;
if (generationGroup.tryAddPoint(chunkX, chunkZ, genSize, targetStep)) {
//ClientApi.LOGGER.info("WorldGen added 1 near point");
toGenerate--;
}
}
// We have farPos to go though
if (i < farCount && posToGenerate.getNthDetail(i, false) != 0) {
positionGoneThough++;
// TODO: Add comment here on why theres a '-1'.
// Not sure what's happening here. This is copied from previous codes.
byte detailLevel = (byte) (posToGenerate.getNthDetail(i, false) - 1);
int chunkX = LevelPosUtil.getChunkPos(detailLevel, posToGenerate.getNthPosX(i, false));
int chunkZ = LevelPosUtil.getChunkPos(detailLevel, posToGenerate.getNthPosZ(i, false));
if (generationGroup.tryAddPoint(chunkX, chunkZ, generationGroupSizeFar, targetStep)) {
toGenerate--;
}
}
if (toGenerate <= 0)
break;
}
@@ -239,7 +243,7 @@ public class ExperimentalGenerator extends AbstractExperimentalWorldGeneratorWra
ClientApi.LOGGER.info("1.18 Experimental Chunk Generator shutting down...");
generationGroup.executors.shutdownNow();
try {
if (!generationGroup.executors.awaitTermination(3, TimeUnit.SECONDS)) {
if (!generationGroup.executors.awaitTermination(30, TimeUnit.SECONDS)) {
ClientApi.LOGGER.warn("1.18 Experimental Chunk Generator shutdown failed! Ignoring child threads...");
}
} catch (InterruptedException e) {}
+1 -1
Submodule core updated: 1a5fd87346...c664564fb0
@@ -20,19 +20,26 @@
package com.seibel.lod.fabric;
import com.seibel.lod.common.Config;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.api.EventApi;
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 com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.fabric.mixins.events.MixinClientLevel;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
import net.fabricmc.fabric.mixin.event.lifecycle.client.ClientChunkManagerMixin;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientChunkCache;
import net.minecraft.core.BlockPos;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.Level;
@@ -61,16 +68,19 @@ public class ClientProxy
// TODO: Fix this if it's wrong
/* World Events */
ServerTickEvents.START_SERVER_TICK.register(this::serverTickEvent);
//ServerTickEvents.START_SERVER_TICK.register(this::serverTickEvent);
ServerTickEvents.END_SERVER_TICK.register(this::serverTickEvent);
/* World Events */
ServerChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
//ServerChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
ClientChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
/* World Events */
ServerWorldEvents.LOAD.register((server, level) -> this.worldLoadEvent(level));
ServerWorldEvents.UNLOAD.register((server, level) -> this.worldUnloadEvent());
ServerWorldEvents.UNLOAD.register((server, level) -> this.worldUnloadEvent(level));
/* The Client World Events are in the mixins
Client world load event is in MixinClientLevel
Client world unload event is in MixinMinecraft */
@@ -106,9 +116,11 @@ public class ClientProxy
}
}
public void worldUnloadEvent()
public void worldUnloadEvent(Level level)
{
eventApi.worldUnloadEvent();
if (level != null) {
eventApi.worldUnloadEvent(WorldWrapper.getWorldWrapper(level));
}
}
/**
@@ -4,6 +4,8 @@ import com.seibel.lod.fabric.Main;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -21,11 +23,11 @@ public class MixinMinecraft {
@Inject(method = "setLevel", at = @At("HEAD"))
private void unloadWorldEvent_sL(ClientLevel clientLevel, CallbackInfo ci) {
if (level != null) Main.client_proxy.worldUnloadEvent();
if (level != null) Main.client_proxy.worldUnloadEvent(level);
}
@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;updateScreenAndTick(Lnet/minecraft/client/gui/screens/Screen;)V", shift = At.Shift.AFTER))
@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
private void unloadWorldEvent_cL(Screen screen, CallbackInfo ci) {
if (this.level != null) Main.client_proxy.worldUnloadEvent();
if (this.level != null) Main.client_proxy.worldUnloadEvent(this.level);
}
}
@@ -75,7 +75,7 @@ public class ForgeClientProxy
@SubscribeEvent
public void worldUnloadEvent(WorldEvent.Unload event)
{
eventApi.worldUnloadEvent();
eventApi.worldUnloadEvent(WorldWrapper.getWorldWrapper(event.getWorld()));
}
@SubscribeEvent