Skip to content

Commit

Permalink
分离客户端部分
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Nov 7, 2024
1 parent d6bb2be commit 2e54874
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/main/java/dev/anvilcraft/rg/RollingGate.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.anvilcraft.rg.api.RGAdditional;
import dev.anvilcraft.rg.api.server.ServerRGRuleManager;
import dev.anvilcraft.rg.api.server.TranslationUtil;
import dev.anvilcraft.rg.client.RollingGateClientRules;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
Expand All @@ -24,7 +25,6 @@ public class RollingGate implements RGAdditional {
public static final String MODID = "rolling_gate";
public static final Logger LOGGER = LogUtils.getLogger();
private static final ServerRGRuleManager SERVER_RULE_MANAGER = new ServerRGRuleManager(RollingGate.MODID);
private static final ClientRGRuleManager CLIENT_RULE_MANAGER = new ClientRGRuleManager(RollingGate.MODID);

public RollingGate(@NotNull IEventBus modEventBus, @NotNull ModContainer modContainer) {
modEventBus.addListener(this::onLoadComplete);
Expand All @@ -51,9 +51,7 @@ public void onLoadComplete(FMLLoadCompleteEvent event) {
RollingGate.SERVER_RULE_MANAGER.setNamespace(modId);
Optional<RGAdditional> additional = modContainer.getCustomExtension(RGAdditional.class);
additional.ifPresent(add -> add.loadServerRules(RollingGate.SERVER_RULE_MANAGER));
additional.ifPresent(add -> add.loadClientRules(RollingGate.CLIENT_RULE_MANAGER));
});
RollingGate.CLIENT_RULE_MANAGER.reInit();
}

@SubscribeEvent
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/dev/anvilcraft/rg/client/RollingGateClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package dev.anvilcraft.rg.client;

import dev.anvilcraft.rg.RollingGate;
import dev.anvilcraft.rg.api.RGAdditional;
import dev.anvilcraft.rg.api.client.ClientRGRuleManager;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent;

import java.util.Optional;

@EventBusSubscriber(value = Dist.CLIENT, modid = RollingGate.MODID, bus = EventBusSubscriber.Bus.MOD)
public class RollingGateClient {
private static final ClientRGRuleManager CLIENT_RULE_MANAGER = new ClientRGRuleManager(RollingGate.MODID);

@SubscribeEvent
public static void onLoadComplete(FMLLoadCompleteEvent event) {
ModList.get().forEachModContainer((modId, modContainer) -> {
RollingGateClient.CLIENT_RULE_MANAGER.setNamespace(modId);
Optional<RGAdditional> additional = modContainer.getCustomExtension(RGAdditional.class);
additional.ifPresent(add -> add.loadClientRules(RollingGateClient.CLIENT_RULE_MANAGER));
});
RollingGateClient.CLIENT_RULE_MANAGER.reInit();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.anvilcraft.rg;
package dev.anvilcraft.rg.client;

public class RollingGateClientRules {
}

0 comments on commit 2e54874

Please sign in to comment.