Initializer code reduction and reformatting
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
package com.seibel.distanthorizons.forge;
|
||||
|
||||
import com.seibel.distanthorizons.common.IEventProxy;
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.util.ProxyUtil;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
@@ -52,7 +52,6 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
//import net.minecraftforge.network.NetworkRegistry;
|
||||
//import net.minecraftforge.network.simple.SimpleChannel;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -73,7 +72,7 @@ import org.lwjgl.opengl.GL32;
|
||||
* @author James_Seibel
|
||||
* @version 2023-7-27
|
||||
*/
|
||||
public class ForgeClientProxy implements IEventProxy
|
||||
public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
{
|
||||
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
@@ -21,12 +21,13 @@ package com.seibel.distanthorizons.forge;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.IEventProxy;
|
||||
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
import com.seibel.distanthorizons.forge.wrappers.ForgeDependencySetup;
|
||||
|
||||
import com.seibel.distanthorizons.forge.wrappers.modAccessor.ModChecker;
|
||||
import com.seibel.distanthorizons.forge.wrappers.modAccessor.OptifineAccessor;
|
||||
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
@@ -68,11 +69,6 @@ import java.util.function.Consumer;
|
||||
* Initialize and setup the Mod. <br>
|
||||
* If you are looking for the real start of the mod
|
||||
* check out the ClientProxy.
|
||||
*
|
||||
* @author coolGi
|
||||
* @author Ran
|
||||
* @author James Seibel
|
||||
* @version 8-15-2022
|
||||
*/
|
||||
@Mod(ModInfo.ID)
|
||||
public class ForgeMain extends AbstractModInitializer
|
||||
@@ -85,22 +81,13 @@ public class ForgeMain extends AbstractModInitializer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createInitialBindings()
|
||||
{
|
||||
ForgeDependencySetup.createInitialBindings();
|
||||
}
|
||||
protected void createInitialBindings() { SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE); }
|
||||
|
||||
@Override
|
||||
protected IEventProxy createClientProxy()
|
||||
{
|
||||
return new ForgeClientProxy();
|
||||
}
|
||||
protected IEventProxy createClientProxy() { return new ForgeClientProxy(); }
|
||||
|
||||
@Override
|
||||
protected IEventProxy createServerProxy(boolean isDedicated)
|
||||
{
|
||||
return new ForgeServerProxy(isDedicated);
|
||||
}
|
||||
protected IEventProxy createServerProxy(boolean isDedicated) { return new ForgeServerProxy(isDedicated); }
|
||||
|
||||
@Override
|
||||
protected void initializeModCompat()
|
||||
@@ -122,10 +109,7 @@ public class ForgeMain extends AbstractModInitializer
|
||||
@Override
|
||||
protected void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.addListener((RegisterCommandsEvent e) ->
|
||||
{
|
||||
eventHandler.accept(e.getDispatcher());
|
||||
});
|
||||
MinecraftForge.EVENT_BUS.addListener((RegisterCommandsEvent e) -> { eventHandler.accept(e.getDispatcher()); });
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,9 +128,6 @@ public class ForgeMain extends AbstractModInitializer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runDelayedSetup()
|
||||
{
|
||||
ForgeDependencySetup.runDelayedSetup();
|
||||
}
|
||||
protected void runDelayedSetup() { SingletonInjector.INSTANCE.runDelayedSetup(); }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package com.seibel.distanthorizons.forge;
|
||||
|
||||
import com.seibel.distanthorizons.common.IEventProxy;
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.util.ProxyUtil;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.core.api.internal.ServerApi;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
@@ -41,7 +38,7 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ForgeServerProxy implements IEventProxy
|
||||
public class ForgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
{
|
||||
#if MC_VER < MC_1_19_2
|
||||
private static LevelAccessor GetEventLevel(WorldEvent e) { return e.getWorld(); }
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 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.distanthorizons.forge.wrappers;
|
||||
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.distanthorizons.forge.wrappers.modAccessor.ModChecker;
|
||||
|
||||
/**
|
||||
* Binds all necessary dependencies so we
|
||||
* can access them in Core. <br>
|
||||
* This needs to be called before any Core classes
|
||||
* are loaded.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @author Ran
|
||||
* @version 12-1-2021
|
||||
*/
|
||||
public class ForgeDependencySetup
|
||||
{
|
||||
public static void createInitialBindings()
|
||||
{
|
||||
SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE);
|
||||
}
|
||||
|
||||
public static void runDelayedSetup()
|
||||
{
|
||||
SingletonInjector.INSTANCE.runDelayedSetup();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user