Milestone!! Both fabric:runclient & fabric:runserver now works!!!!! (in 1.18.2 for now)
This commit is contained in:
+3
@@ -41,6 +41,8 @@ import com.seibel.lod.core.objects.DHBlockPos;
|
||||
import com.seibel.lod.core.objects.DHChunkPos;
|
||||
import com.seibel.lod.common.wrappers.world.DimensionTypeWrapper;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -70,6 +72,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author James Seibel
|
||||
* @version 3-5-2022
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
|
||||
|
||||
+3
@@ -2,10 +2,13 @@ package com.seibel.lod.common.wrappers.minecraft;
|
||||
|
||||
import com.seibel.lod.core.api.internal.a7.SharedApi;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Environment(EnvType.SERVER)
|
||||
public class MinecraftDedicatedServerWrapper implements IMinecraftSharedWrapper {
|
||||
public static final MinecraftDedicatedServerWrapper INSTANCE = new MinecraftDedicatedServerWrapper();
|
||||
private MinecraftDedicatedServerWrapper() {}
|
||||
|
||||
+3
@@ -47,6 +47,8 @@ import com.seibel.lod.common.wrappers.McObjectConverter;
|
||||
import com.seibel.lod.common.wrappers.WrapperFactory;
|
||||
import com.seibel.lod.core.objects.DHBlockPos;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
@@ -75,6 +77,7 @@ import org.apache.logging.log4j.Logger;
|
||||
* @author James Seibel
|
||||
* @version 12-12-2021
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
{
|
||||
public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
|
||||
|
||||
@@ -35,6 +35,8 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
@@ -73,6 +75,7 @@ public class LevelWrapper implements ILevelWrapper
|
||||
levelType = ELevelType.Unknown;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private static LevelAccessor getSinglePlayerServerLevel() {
|
||||
MinecraftClientWrapper client = MinecraftClientWrapper.INSTANCE;
|
||||
return client.mc.getSingleplayerServer().getPlayerList()
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
public final StepLight stepLight = new StepLight(this);
|
||||
public boolean unsafeThreadingRecorded = false;
|
||||
//public boolean safeMode = false;
|
||||
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
|
||||
//private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
|
||||
public static final long EXCEPTION_TIMER_RESET_TIME = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
|
||||
public static final int EXCEPTION_COUNTER_TRIGGER = 20;
|
||||
public static final int RANGE_TO_RANGE_EMPTY_EXTENSION = 1;
|
||||
|
||||
+1
-1
Submodule core updated: 1c63dd5183...932146eea8
@@ -2,8 +2,11 @@ package com.seibel.lod.fabric;
|
||||
|
||||
import com.seibel.lod.common.wrappers.DependencySetup;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class FabricClientMain implements ClientModInitializer {
|
||||
public static FabricClientProxy client_proxy;
|
||||
public static FabricServerProxy server_proxy;
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||
@@ -49,13 +51,12 @@ import org.lwjgl.glfw.GLFW;
|
||||
* @author Ran
|
||||
* @version 11-23-2021
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class FabricClientProxy
|
||||
{
|
||||
private final ClientApi clientApi = ClientApi.INSTANCE;
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger("FabricClientProxy");
|
||||
|
||||
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
||||
|
||||
/**
|
||||
* Registers Fabric Events
|
||||
* @author Ran
|
||||
@@ -63,7 +64,6 @@ public class FabricClientProxy
|
||||
public void registerEvents() {
|
||||
LOGGER.info("Registering Fabric Client Events");
|
||||
|
||||
isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
|
||||
/* Register the mod needed event callbacks */
|
||||
|
||||
|
||||
@@ -2,11 +2,15 @@ package com.seibel.lod.fabric;
|
||||
|
||||
import com.seibel.lod.common.wrappers.DependencySetup;
|
||||
import com.seibel.lod.common.wrappers.minecraft.MinecraftDedicatedServerWrapper;
|
||||
import com.seibel.lod.core.api.internal.a7.SharedApi;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
|
||||
@Environment(EnvType.SERVER)
|
||||
public class FabricDedicatedServerMain implements DedicatedServerModInitializer {
|
||||
public static FabricServerProxy server_proxy;
|
||||
public boolean hasPostSetupDone = false;
|
||||
@@ -22,9 +26,10 @@ public class FabricDedicatedServerMain implements DedicatedServerModInitializer
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((server) -> {
|
||||
if (hasPostSetupDone) return;
|
||||
hasPostSetupDone = true;
|
||||
FabricMain.postInit();
|
||||
LodUtil.assertTrue(server instanceof DedicatedServer);
|
||||
MinecraftDedicatedServerWrapper.INSTANCE.dedicatedServer = (DedicatedServer) server;
|
||||
FabricMain.postInit();
|
||||
SharedApi.LOGGER.info("Dedicated server inited at {}", server.getServerDirectory());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ public class FabricMain
|
||||
public static void postInit() {
|
||||
LOGGER.info("Post-Initializing Mod");
|
||||
FabricDependencySetup.runDelayedSetup();
|
||||
LodCommonMain.initConfig();
|
||||
LOGGER.info("Mod Post-Initialized");
|
||||
}
|
||||
|
||||
@@ -69,7 +70,6 @@ public class FabricMain
|
||||
LodCommonMain.startup(null);
|
||||
FabricDependencySetup.createInitialBindings();
|
||||
FabricDependencySetup.finishBinding();
|
||||
LodCommonMain.initConfig();
|
||||
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
|
||||
|
||||
if (SingletonHandler.get(IModChecker.class).isModLoaded("sodium")) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.seibel.lod.fabric;
|
||||
import com.seibel.lod.common.networking.Networking;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.lod.common.wrappers.world.LevelWrapper;
|
||||
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.lod.core.api.internal.a7.ServerApi;
|
||||
import com.seibel.lod.core.api.internal.a7.SharedApi;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
@@ -19,6 +20,8 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the server,
|
||||
* and is the starting point for most of the mod.
|
||||
@@ -27,18 +30,20 @@ import org.apache.logging.log4j.Logger;
|
||||
* @version 5-11-2022
|
||||
*/
|
||||
|
||||
// TODO
|
||||
public class FabricServerProxy {
|
||||
private final ServerApi serverApi = ServerApi.INSTANCE;
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger("FabricServerProxy");
|
||||
private final boolean isDedicated;
|
||||
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
||||
|
||||
public FabricServerProxy(boolean isDedicated) {
|
||||
this.isDedicated = isDedicated;
|
||||
}
|
||||
|
||||
private boolean isValidTime() {
|
||||
//FIXME: return true immediately if this is a dedicated server
|
||||
if (isDedicated) return true;
|
||||
|
||||
//FIXME: This may cause init issue...
|
||||
return !(Minecraft.getInstance().screen instanceof TitleScreen);
|
||||
}
|
||||
private LevelWrapper getLevelWrapper(Level level) {
|
||||
@@ -46,10 +51,11 @@ public class FabricServerProxy {
|
||||
}
|
||||
/**
|
||||
* Registers Fabric Events
|
||||
* @author Ran, Tom
|
||||
* @author Ran, Tomlee
|
||||
*/
|
||||
public void registerEvents() {
|
||||
LOGGER.info("Registering Fabric Server Events");
|
||||
isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
|
||||
/* Register the mod needed event callbacks */
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(DedicatedServer.class)
|
||||
@Deprecated // Please use the OnServerLoadEvent in core instead, or
|
||||
// the ServerLifecycleEvents in Fabric
|
||||
public class MixinDedicatedServer {
|
||||
// @Inject(method = "initServer", at = @At("TAIL"))
|
||||
// public void initServer(CallbackInfoReturnable<Boolean> cir) {
|
||||
// Main.initServer();
|
||||
// }
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2022 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.fabric.mixins;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
/**
|
||||
* Loads the mod after minecraft loads.
|
||||
* @author Ran
|
||||
*/
|
||||
@Mixin(value = Minecraft.class)
|
||||
@Deprecated // Moved to using fabric lifecycle events
|
||||
public class MixinMinecraft {
|
||||
// @Inject(method = "<init>", at = @At("TAIL"))
|
||||
// private void startMod(GameConfig gameConfig, CallbackInfo ci) {
|
||||
// Main.init();
|
||||
// }
|
||||
}
|
||||
+5
-3
@@ -23,6 +23,8 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.seibel.lod.fabric.FabricClientProxy;
|
||||
import com.seibel.lod.fabric.FabricDedicatedServerMain;
|
||||
import com.seibel.lod.fabric.FabricServerProxy;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -38,7 +40,7 @@ public class MixinUtilBackgroudThread
|
||||
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable<ExecutorService> ci)
|
||||
{
|
||||
if (FabricClientProxy.isGenerationThreadChecker != null && FabricClientProxy.isGenerationThreadChecker.get())
|
||||
if (FabricServerProxy.isGenerationThreadChecker != null && FabricServerProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util backgroundExecutor triggered");
|
||||
ci.setReturnValue(new DummyRunExecutorService());
|
||||
@@ -50,7 +52,7 @@ public class MixinUtilBackgroudThread
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable<Runnable> ci)
|
||||
{
|
||||
if (FabricClientProxy.isGenerationThreadChecker != null && FabricClientProxy.isGenerationThreadChecker.get())
|
||||
if (FabricServerProxy.isGenerationThreadChecker != null && FabricServerProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered");
|
||||
ci.setReturnValue(r);
|
||||
@@ -62,7 +64,7 @@ public class MixinUtilBackgroudThread
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier<?> r, CallbackInfoReturnable<Supplier<?>> ci)
|
||||
{
|
||||
if (FabricClientProxy.isGenerationThreadChecker != null && FabricClientProxy.isGenerationThreadChecker.get())
|
||||
if (FabricServerProxy.isGenerationThreadChecker != null && FabricServerProxy.isGenerationThreadChecker.get())
|
||||
{
|
||||
//ApiShared.LOGGER.info("util wrapThreadWithTaskName(Supplier) triggered");
|
||||
ci.setReturnValue(r);
|
||||
|
||||
Reference in New Issue
Block a user