Skip to content

Commit 2ce9a35

Browse files
committed
change: NeoHooks -> FoxifiedLoader
1 parent a0b0672 commit 2ce9a35

File tree

13 files changed

+68
-46
lines changed

13 files changed

+68
-46
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
## Changelog
2-
- fix compat with AnvilCraft's `PistonBaseBlockMixin` (#7)
2+
- change: `org/thinkingstudio/bedsheet/util/NeoHooks.java` -> `org/thinkingstudio/bedsheet/loader/FoxifiedLoader.java`

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ loom.platform = neoforge
1616

1717
curseforge_id=1193851
1818
modrinth_id=EZaGjo8d
19-
release_type=alpha
19+
release_type=beta

src/main/java/carpet/CarpetServer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,14 @@
3131
import carpet.utils.SpawnReporter;
3232
import com.mojang.brigadier.CommandDispatcher;
3333

34-
//import net.fabricmc.loader.api.FabricLoader;
3534
import net.minecraft.commands.CommandBuildContext;
3635
import net.minecraft.commands.CommandSourceStack;
3736
import net.minecraft.commands.Commands;
3837
import net.minecraft.network.chat.Component;
3938
import net.minecraft.server.MinecraftServer;
4039
import net.minecraft.server.commands.PerfCommand;
4140
import net.minecraft.server.level.ServerPlayer;
42-
import org.thinkingstudio.bedsheet.util.NeoHooks;
41+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
4342

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

145-
if (NeoHooks.isDevelopmentEnvironment())
144+
if (FoxifiedLoader.isDevelopmentEnvironment())
146145
TestCommand.register(dispatcher);
147146
// todo 1.16 - re-registerer apps if that's a reload operation.
148147
}

src/main/java/carpet/CarpetSettings.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import carpet.utils.Translations;
1010
import carpet.utils.CommandHelper;
1111
import carpet.utils.Messenger;
12-
//import net.fabricmc.loader.api.FabricLoader;
13-
//import net.fabricmc.loader.api.SemanticVersion;
1412
import net.minecraft.commands.CommandSourceStack;
1513
import net.minecraft.core.registries.Registries;
1614
import net.minecraft.resources.ResourceLocation;
@@ -30,7 +28,7 @@
3028

3129
import org.slf4j.Logger;
3230
import org.slf4j.LoggerFactory;
33-
import org.thinkingstudio.bedsheet.util.NeoHooks;
31+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
3432
import org.thinkingstudio.bedsheet.BedSheetModReference;
3533

3634
import java.util.Optional;
@@ -50,10 +48,10 @@
5048
@SuppressWarnings({"CanBeFinal", "removal"}) // removal should be removed after migrating rules to the new system
5149
public class CarpetSettings
5250
{
53-
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();
5452
public static final int [] releaseTarget = {
55-
NeoHooks.getModContainer("minecraft").orElseThrow().getModInfo().getVersion().getMinorVersion(),
56-
NeoHooks.getModContainer("minecraft").orElseThrow().getModInfo().getVersion().getIncrementalVersion()
53+
FoxifiedLoader.getModContainer("minecraft").orElseThrow().getModInfo().getVersion().getMinorVersion(),
54+
FoxifiedLoader.getModContainer("minecraft").orElseThrow().getModInfo().getVersion().getIncrementalVersion()
5755
};
5856
public static final Logger LOG = LoggerFactory.getLogger(BedSheetModReference.MODNAME);
5957
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@
4545
import carpet.utils.Messenger;
4646
import carpet.utils.TranslationKeys;
4747
import carpet.utils.Translations;
48-
//import net.fabricmc.api.EnvType;
49-
//import net.fabricmc.loader.api.FabricLoader;
5048
import net.minecraft.commands.CommandBuildContext;
5149
import net.minecraft.commands.CommandSourceStack;
5250
import net.minecraft.commands.SharedSuggestionProvider;
5351
import net.minecraft.network.chat.Component;
5452
import net.minecraft.server.MinecraftServer;
5553
import net.minecraft.world.level.storage.LevelResource;
56-
import org.thinkingstudio.bedsheet.util.NeoHooks;
54+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
5755

5856
import static carpet.utils.Translations.tr;
5957
import static java.util.Comparator.comparing;
@@ -462,9 +460,9 @@ private ConfigReadResult readSettingsFromConf(Path path)
462460
}
463461
catch (NoSuchFileException e)
464462
{
465-
if (path.equals(getFile()) && NeoHooks.getEnvironmentType().isClient())
463+
if (path.equals(getFile()) && FoxifiedLoader.getEnvironmentType().isClient())
466464
{
467-
Path defaultsPath = NeoHooks.getConfigDir().resolve("carpet/default_"+identifier+".conf");
465+
Path defaultsPath = FoxifiedLoader.getConfigDir().resolve("carpet/default_"+identifier+".conf");
468466
try {
469467
if (Files.notExists(defaultsPath))
470468
{

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
import carpet.script.value.StringValue;
2121
import carpet.utils.CarpetProfiler;
2222
import carpet.utils.Messenger;
23-
//import net.fabricmc.api.EnvType;
24-
//import net.fabricmc.loader.api.FabricLoader;
25-
//import net.fabricmc.loader.api.ModContainer;
26-
//import net.fabricmc.loader.api.SemanticVersion;
27-
//import net.fabricmc.loader.api.Version;
28-
//import net.fabricmc.loader.api.VersionParsingException;
29-
//import net.fabricmc.loader.api.metadata.version.VersionPredicate;
3023
import net.minecraft.commands.CommandSourceStack;
3124
import net.minecraft.network.chat.Component;
3225
import net.minecraft.server.MinecraftServer;
@@ -36,7 +29,7 @@
3629
import org.apache.maven.artifact.versioning.ArtifactVersion;
3730
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
3831
import org.apache.maven.artifact.versioning.VersionRange;
39-
import org.thinkingstudio.bedsheet.util.NeoHooks;
32+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
4033

4134
import javax.annotation.Nullable;
4235
import java.io.IOException;
@@ -149,9 +142,9 @@ public static boolean getFillUpdates()
149142
@Nullable
150143
public static Module fetchGlobalModule(String name, boolean allowLibraries) throws IOException
151144
{
152-
if (NeoHooks.isDevelopmentEnvironment())
145+
if (FoxifiedLoader.isDevelopmentEnvironment())
153146
{
154-
Path globalFolder = NeoHooks.getConfigDir().resolve("carpet/scripts");
147+
Path globalFolder = FoxifiedLoader.getConfigDir().resolve("carpet/scripts");
155148
if (!Files.exists(globalFolder))
156149
{
157150
Files.createDirectories(globalFolder);
@@ -173,9 +166,9 @@ public static Module fetchGlobalModule(String name, boolean allowLibraries) thro
173166

174167
public static void addGlobalModules(final List<String> moduleNames, boolean includeBuiltIns) throws IOException
175168
{
176-
if (includeBuiltIns && (NeoHooks.getEnvironmentType().isClient()))
169+
if (includeBuiltIns && (FoxifiedLoader.getEnvironmentType().isClient()))
177170
{
178-
Path globalScripts = NeoHooks.getConfigDir().resolve("carpet/scripts");
171+
Path globalScripts = FoxifiedLoader.getConfigDir().resolve("carpet/scripts");
179172
if (!Files.exists(globalScripts))
180173
{
181174
Files.createDirectories(globalScripts);
@@ -201,11 +194,11 @@ public static void assertRequirementMet(CarpetScriptHost host, String requiredMo
201194
throw new InternalExpressionException("Failed to parse version conditions for '" + requiredModId + "' in 'requires': " + e.getMessage());
202195
}
203196

204-
ModContainer mod = NeoHooks.getModContainer(requiredModId).orElse(null);
197+
ModContainer mod = FoxifiedLoader.getModContainer(requiredModId).orElse(null);
205198
if (mod != null)
206199
{
207200
ArtifactVersion presentVersion = mod.getModInfo().getVersion();
208-
if (range.containsVersion(presentVersion) || (NeoHooks.isDevelopmentEnvironment() && !(presentVersion instanceof DefaultArtifactVersion)))
201+
if (range.containsVersion(presentVersion) || (FoxifiedLoader.isDevelopmentEnvironment() && !(presentVersion instanceof DefaultArtifactVersion)))
209202
{ // in a dev env, mod version is usually replaced with ${version}, and that isn't semantic
210203
return;
211204
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
import carpet.utils.SpawnReporter;
3434
import com.mojang.brigadier.CommandDispatcher;
3535
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
36-
//import net.fabricmc.loader.api.FabricLoader;
37-
//import net.fabricmc.loader.api.ModContainer;
3836
import net.minecraft.commands.CommandSourceStack;
3937
import net.minecraft.commands.arguments.blocks.BlockInput;
4038
import net.minecraft.core.BlockPos;
@@ -83,7 +81,7 @@
8381
import net.minecraft.world.scores.Scoreboard;
8482
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
8583
import net.neoforged.neoforgespi.language.IModInfo;
86-
import org.thinkingstudio.bedsheet.util.NeoHooks;
84+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
8785

8886
import java.util.Collection;
8987
import java.util.HashMap;
@@ -191,13 +189,13 @@ public static int MinecraftServer_getRunPermissionLevel(MinecraftServer server)
191189

192190
public static boolean isDevelopmentEnvironment()
193191
{
194-
return NeoHooks.isDevelopmentEnvironment();
192+
return FoxifiedLoader.isDevelopmentEnvironment();
195193
}
196194

197195
public static MapValue getServerMods(MinecraftServer server)
198196
{
199197
Map<Value, Value> ret = new HashMap<>();
200-
for (IModInfo mod : NeoHooks.getAllMods())
198+
for (IModInfo mod : FoxifiedLoader.getAllMods())
201199
{
202200
ret.put(new StringValue(mod.getModId()), new StringValue(mod.getVersion().toString()));
203201
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import joptsimple.OptionSet;
66
import joptsimple.OptionSpec;
77
import joptsimple.util.PathConverter;
8-
//import net.fabricmc.api.DedicatedServerModInitializer;
9-
//import net.fabricmc.loader.api.FabricLoader;
108

119
import java.io.IOException;
1210
import java.io.PrintStream;
@@ -17,19 +15,21 @@
1715

1816
import org.slf4j.Logger;
1917
import org.slf4j.LoggerFactory;
20-
import org.thinkingstudio.bedsheet.util.NeoHooks;
18+
import org.thinkingstudio.bedsheet.loader.FoxifiedLoader;
19+
import org.thinkingstudio.bedsheet.loader.entrypoint.DedicatedServerModInitializer;
2120

2221
/**
2322
* Provides a command line interface to generate a dump with all rules
2423
* in a pretty markdown format to a specified file, with an optional
2524
* category filter
2625
*
2726
*/
28-
public class CarpetRulePrinter /*implements DedicatedServerModInitializer*/ {
29-
public static void onInitializeServer() {
27+
public class CarpetRulePrinter implements DedicatedServerModInitializer {
28+
@Override
29+
public void onInitializeServer() {
3030
// When launching, we use the "--" separator to prevent the game rejecting to launch because of unknown options
3131
// Clear it in case it's present given else our option parser would also ignore them!
32-
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);
3333

3434
// Prepare an OptionParser for our parameters
3535
OptionParser parser = new OptionParser();

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +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-
13-
public BedSheetModEntrypoint(IEventBus modEventBus) {
15+
public BedSheetModEntrypoint(ModContainer modContainer, IEventBus modEventBus) {
16+
EntrypointHandler.init();
1417
CarpetServer.onGameStarted();
1518
BedSheetModEvents.registerEvents(modEventBus, NeoForge.EVENT_BUS);
1619
if (FMLLoader.getDist().isDedicatedServer()) {
17-
CarpetRulePrinter.onInitializeServer();
20+
modContainer.registerExtensionPoint(DedicatedServerModInitializer.class, new CarpetRulePrinter());
1821
}
1922
}
2023
}

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

Lines changed: 2 additions & 2 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() {

0 commit comments

Comments
 (0)