Skip to content

Commit e0210ec

Browse files
committed
change: NeoHooks -> FoxifiedLoader
1 parent 590034f commit e0210ec

File tree

13 files changed

+78
-31
lines changed

13 files changed

+78
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
## Changelog
2-
- port to 1.21.3
3-
- rework `customSticky` mixin
4-
- fix conflict with worldedit
2+
- change: `NeoHooks` -> `FoxifiedLoader`

src/main/java/carpet/CarpetServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import net.minecraft.server.MinecraftServer;
3939
import net.minecraft.server.commands.PerfCommand;
4040
import net.minecraft.server.level.ServerPlayer;
41-
import org.thinkingstudio.bedsheet.util.NeoHooks;
41+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
4242

4343
@SuppressWarnings("removal")
4444
public class CarpetServer // static for now - easier to handle all around the code, its one anyways
@@ -141,7 +141,7 @@ public static void registerCarpetCommands(CommandDispatcher<CommandSourceStack>
141141
if (environment != Commands.CommandSelection.DEDICATED)
142142
PerfCommand.register(dispatcher);
143143

144-
if (NeoHooks.isDevelopmentEnvironment())
144+
if (FoxifiedLoader.isDevelopmentEnvironment())
145145
TestCommand.register(dispatcher);
146146
// todo 1.16 - re-registerer apps if that's a reload operation.
147147
}

src/main/java/carpet/CarpetSettings.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.slf4j.Logger;
3030
import org.slf4j.LoggerFactory;
3131
import org.thinkingstudio.bedsheet.BedSheetModReference;
32-
import org.thinkingstudio.bedsheet.util.NeoHooks;
32+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
3333

3434
import java.util.Optional;
3535

@@ -48,10 +48,10 @@
4848
@SuppressWarnings({"CanBeFinal", "removal"}) // removal should be removed after migrating rules to the new system
4949
public class CarpetSettings
5050
{
51-
public static final String carpetVersion = NeoHooks.getModContainer(BedSheetModReference.MODID).orElseThrow().getModInfo().getVersion().toString();
51+
public static final String carpetVersion = FoxifiedLoader.getModContainer(BedSheetModReference.MODID).orElseThrow().getModInfo().getVersion().toString();
5252
public static final int [] releaseTarget = {
53-
NeoHooks.getModContainer("minecraft").orElseThrow().getModInfo().getVersion().getMinorVersion(),
54-
NeoHooks.getModContainer("minecraft").orElseThrow().getModInfo().getVersion().getIncrementalVersion()
53+
FoxifiedLoader.getModContainer("minecraft").orElseThrow().getModInfo().getVersion().getMinorVersion(),
54+
FoxifiedLoader.getModContainer("minecraft").orElseThrow().getModInfo().getVersion().getIncrementalVersion()
5555
};
5656
public static final Logger LOG = LoggerFactory.getLogger(BedSheetModReference.MODNAME);
5757
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);

src/main/java/carpet/api/settings/SettingsManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
import net.minecraft.network.chat.Component;
5252
import net.minecraft.server.MinecraftServer;
5353
import net.minecraft.world.level.storage.LevelResource;
54-
import org.thinkingstudio.bedsheet.util.NeoHooks;
54+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
5555

5656
import static carpet.utils.Translations.tr;
5757
import static java.util.Comparator.comparing;
@@ -460,9 +460,9 @@ private ConfigReadResult readSettingsFromConf(Path path)
460460
}
461461
catch (NoSuchFileException e)
462462
{
463-
if (path.equals(getFile()) && NeoHooks.getEnvironmentType().isClient())
463+
if (path.equals(getFile()) && FoxifiedLoader.getEnvironmentType().isClient())
464464
{
465-
Path defaultsPath = NeoHooks.getConfigDir().resolve("carpet/default_"+identifier+".conf");
465+
Path defaultsPath = FoxifiedLoader.getConfigDir().resolve("carpet/default_"+identifier+".conf");
466466
try {
467467
if (Files.notExists(defaultsPath))
468468
{

src/main/java/carpet/script/external/Carpet.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.apache.maven.artifact.versioning.ArtifactVersion;
3030
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
3131
import org.apache.maven.artifact.versioning.VersionRange;
32-
import org.thinkingstudio.bedsheet.util.NeoHooks;
32+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
3333

3434
import javax.annotation.Nullable;
3535
import java.io.IOException;
@@ -142,9 +142,9 @@ public static boolean getFillUpdates()
142142
@Nullable
143143
public static Module fetchGlobalModule(String name, boolean allowLibraries) throws IOException
144144
{
145-
if (NeoHooks.isDevelopmentEnvironment())
145+
if (FoxifiedLoader.isDevelopmentEnvironment())
146146
{
147-
Path globalFolder = NeoHooks.getConfigDir().resolve("carpet/scripts");
147+
Path globalFolder = FoxifiedLoader.getConfigDir().resolve("carpet/scripts");
148148
if (!Files.exists(globalFolder))
149149
{
150150
Files.createDirectories(globalFolder);
@@ -166,9 +166,9 @@ public static Module fetchGlobalModule(String name, boolean allowLibraries) thro
166166

167167
public static void addGlobalModules(final List<String> moduleNames, boolean includeBuiltIns) throws IOException
168168
{
169-
if (includeBuiltIns && (NeoHooks.getEnvironmentType().isClient()))
169+
if (includeBuiltIns && (FoxifiedLoader.getEnvironmentType().isClient()))
170170
{
171-
Path globalScripts = NeoHooks.getConfigDir().resolve("carpet/scripts");
171+
Path globalScripts = FoxifiedLoader.getConfigDir().resolve("carpet/scripts");
172172
if (!Files.exists(globalScripts))
173173
{
174174
Files.createDirectories(globalScripts);
@@ -194,11 +194,11 @@ public static void assertRequirementMet(CarpetScriptHost host, String requiredMo
194194
throw new InternalExpressionException("Failed to parse version conditions for '" + requiredModId + "' in 'requires': " + e.getMessage());
195195
}
196196

197-
ModContainer mod = NeoHooks.getModContainer(requiredModId).orElse(null);
197+
ModContainer mod = FoxifiedLoader.getModContainer(requiredModId).orElse(null);
198198
if (mod != null)
199199
{
200200
ArtifactVersion presentVersion = mod.getModInfo().getVersion();
201-
if (range.containsVersion(presentVersion) || (NeoHooks.isDevelopmentEnvironment() && !(presentVersion instanceof DefaultArtifactVersion)))
201+
if (range.containsVersion(presentVersion) || (FoxifiedLoader.isDevelopmentEnvironment() && !(presentVersion instanceof DefaultArtifactVersion)))
202202
{ // in a dev env, mod version is usually replaced with ${version}, and that isn't semantic
203203
return;
204204
}

src/main/java/carpet/script/external/Vanilla.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
import net.minecraft.world.scores.Scoreboard;
7373
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
7474
import net.neoforged.neoforgespi.language.IModInfo;
75-
import org.thinkingstudio.bedsheet.util.NeoHooks;
75+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
7676

7777
import java.util.HashMap;
7878
import java.util.List;
@@ -169,13 +169,13 @@ public static int MinecraftServer_getRunPermissionLevel(MinecraftServer server)
169169

170170
public static boolean isDevelopmentEnvironment()
171171
{
172-
return NeoHooks.isDevelopmentEnvironment();
172+
return FoxifiedLoader.isDevelopmentEnvironment();
173173
}
174174

175175
public static MapValue getServerMods(MinecraftServer server)
176176
{
177177
Map<Value, Value> ret = new HashMap<>();
178-
for (IModInfo mod : NeoHooks.getAllMods())
178+
for (IModInfo mod : FoxifiedLoader.getAllMods())
179179
{
180180
ret.put(new StringValue(mod.getModId()), new StringValue(mod.getVersion().toString()));
181181
}

src/main/java/carpet/utils/CarpetRulePrinter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@
1515

1616
import org.slf4j.Logger;
1717
import org.slf4j.LoggerFactory;
18-
import org.thinkingstudio.bedsheet.util.NeoHooks;
18+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
19+
import org.thinkingstudio.bedsheet.loader.entrypoint.DedicatedServerModInitializer;
1920

2021
/**
2122
* Provides a command line interface to generate a dump with all rules
2223
* in a pretty markdown format to a specified file, with an optional
2324
* category filter
2425
*
2526
*/
26-
public class CarpetRulePrinter {
27-
public static void onInitializeServer() {
27+
public class CarpetRulePrinter implements DedicatedServerModInitializer {
28+
@Override
29+
public void onInitializeServer() {
2830
// When launching, we use the "--" separator to prevent the game rejecting to launch because of unknown options
2931
// Clear it in case it's present given else our option parser would also ignore them!
30-
String[] args = Arrays.stream(NeoHooks.getLaunchArguments(true)).filter(opt -> !opt.equals("--")).toArray(String[]::new);
32+
String[] args = Arrays.stream(FoxifiedLoader.getLaunchArguments(true)).filter(opt -> !opt.equals("--")).toArray(String[]::new);
3133

3234
// Prepare an OptionParser for our parameters
3335
OptionParser parser = new OptionParser();

src/main/java/org/thinkingstudio/bedsheet/BedSheetModEntrypoint.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
import carpet.CarpetServer;
44
import carpet.utils.CarpetRulePrinter;
55
import net.neoforged.bus.api.IEventBus;
6+
import net.neoforged.fml.ModContainer;
67
import net.neoforged.fml.common.Mod;
78
import net.neoforged.fml.loading.FMLLoader;
89
import net.neoforged.neoforge.common.NeoForge;
10+
import org.thinkingstudio.bedsheet.loader.entrypoint.DedicatedServerModInitializer;
11+
import org.thinkingstudio.bedsheet.loader.entrypoint.EntrypointHandler;
912

1013
@Mod(BedSheetModReference.MODID)
1114
public class BedSheetModEntrypoint {
12-
public BedSheetModEntrypoint(IEventBus modEventBus) {
15+
public BedSheetModEntrypoint(ModContainer modContainer, IEventBus modEventBus) {
16+
EntrypointHandler.init();
1317
CarpetServer.onGameStarted();
1418
BedSheetModEvents.registerEvents(modEventBus, NeoForge.EVENT_BUS);
1519
if (FMLLoader.getDist().isDedicatedServer()) {
16-
CarpetRulePrinter.onInitializeServer();
20+
modContainer.registerExtensionPoint(DedicatedServerModInitializer.class, new CarpetRulePrinter());
1721
}
1822
}
1923
}

src/main/java/org/thinkingstudio/bedsheet/util/NeoHooks.java renamed to src/main/java/org/thinkingstudio/bedsheet/loader/FoxifiedLoader.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.thinkingstudio.bedsheet.util;
1+
package org.thinkingstudio.bedsheet.loader;
22

33
import cpw.mods.modlauncher.ArgumentHandler;
44
import cpw.mods.modlauncher.Launcher;
@@ -14,7 +14,7 @@
1414
import java.util.List;
1515
import java.util.Optional;
1616

17-
public class NeoHooks {
17+
public class FoxifiedLoader {
1818
private static String[] launchArgs;
1919

2020
public static boolean isDevelopmentEnvironment() {
@@ -50,5 +50,4 @@ public static String[] getLaunchArguments(boolean sanitize) {
5050
public static List<IModInfo> getAllMods() {
5151
return ModList.get().getMods();
5252
}
53-
5453
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.thinkingstudio.bedsheet.loader.entrypoint;
2+
3+
import net.neoforged.fml.IExtensionPoint;
4+
5+
public interface ClientModInitializer extends IExtensionPoint {
6+
void onInitializeClient();
7+
}

0 commit comments

Comments
 (0)