Skip to content

Commit c0cd1c7

Browse files
committed
Add Forge 1.21.10
1 parent 580eef4 commit c0cd1c7

11 files changed

Lines changed: 2981 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.dynmap.forge_1_21_10;
2+
3+
public class ClientProxy extends Proxy {
4+
public ClientProxy() {
5+
}
6+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package org.dynmap.forge_1_21_10;
2+
3+
import java.io.File;
4+
5+
import org.apache.commons.lang3.tuple.Pair;
6+
import org.dynmap.DynmapCommonAPI;
7+
import org.dynmap.DynmapCommonAPIListener;
8+
import org.dynmap.Log;
9+
import org.dynmap.forge_1_21_10.DynmapPlugin.OurLog;
10+
11+
import net.minecraft.server.MinecraftServer;
12+
import net.minecraftforge.fml.common.Mod;
13+
import net.minecraftforge.common.MinecraftForge;
14+
import net.minecraftforge.event.server.ServerAboutToStartEvent;
15+
import net.minecraftforge.event.server.ServerStartedEvent;
16+
import net.minecraftforge.event.server.ServerStartingEvent;
17+
import net.minecraftforge.event.server.ServerStoppingEvent;
18+
import net.minecraftforge.eventbus.api.bus.BusGroup;
19+
import net.minecraftforge.eventbus.api.bus.EventBus;
20+
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
21+
import net.minecraftforge.fml.DistExecutor;
22+
import net.minecraftforge.fml.IExtensionPoint;
23+
import net.minecraftforge.fml.ModList;
24+
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
25+
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
26+
27+
@Mod("dynmap")
28+
public class DynmapMod
29+
{
30+
// The instance of your mod that Forge uses.
31+
public static DynmapMod instance;
32+
public static BusGroup modBusGroup;
33+
34+
// Says where the client and server 'proxy' code is loaded.
35+
public static Proxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> Proxy::new);
36+
37+
public static DynmapPlugin plugin;
38+
public static File jarfile;
39+
public static String ver;
40+
public static boolean useforcedchunks;
41+
42+
public class APICallback extends DynmapCommonAPIListener {
43+
@Override
44+
public void apiListenerAdded() {
45+
if(plugin == null) {
46+
plugin = proxy.startServer(server);
47+
}
48+
}
49+
@Override
50+
public void apiEnabled(DynmapCommonAPI api) {
51+
}
52+
}
53+
54+
public DynmapMod(FMLJavaModLoadingContext context) {
55+
instance = this;
56+
57+
modBusGroup = context.getModBusGroup();
58+
59+
// Register the commonSetup method for modloading
60+
FMLCommonSetupEvent.getBus(modBusGroup).addListener(this::setup);
61+
62+
ServerStartedEvent.BUS.addListener(this::onServerStarted);
63+
ServerAboutToStartEvent.BUS.addListener(this::onServerStarting);
64+
ServerStoppingEvent.BUS.addListener(this::onServerStopping);
65+
66+
context.registerExtensionPoint(IExtensionPoint.DisplayTest.class,
67+
()->new IExtensionPoint.DisplayTest(()->IExtensionPoint.DisplayTest.IGNORESERVERONLY, (remote, isServer)-> true));
68+
69+
Log.setLogger(new OurLog());
70+
org.dynmap.modsupport.ModSupportImpl.init();
71+
}
72+
73+
public void setup(final FMLCommonSetupEvent event)
74+
{
75+
//TOOO
76+
jarfile = ModList.get().getModFileById("dynmap").getFile().getFilePath().toFile();
77+
78+
ver = ModList.get().getModContainerById("dynmap").get().getModInfo().getVersion().toString();
79+
80+
//// Load configuration file - use suggested (config/WesterosBlocks.cfg)
81+
//Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
82+
//try {
83+
// cfg.load();
84+
//
85+
// useforcedchunks = cfg.get("Settings", "UseForcedChunks", true).getBoolean(true);
86+
//}
87+
//finally
88+
//{
89+
// cfg.save();
90+
//}
91+
}
92+
93+
private MinecraftServer server;
94+
95+
public void onServerStarting(ServerAboutToStartEvent event) {
96+
server = event.getServer();
97+
if(plugin == null)
98+
plugin = proxy.startServer(server);
99+
plugin.onStarting(server.getCommands().getDispatcher());
100+
}
101+
102+
public void onServerStarted(ServerStartedEvent event) {
103+
DynmapCommonAPIListener.register(new APICallback());
104+
plugin.serverStarted();
105+
}
106+
107+
public void onServerStopping(ServerStoppingEvent event)
108+
{
109+
proxy.stopServer(plugin);
110+
plugin = null;
111+
}
112+
}

0 commit comments

Comments
 (0)