generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable nutrition/saturation feature when nostalgic tweaks is present
- Loading branch information
1 parent
fd5e364
commit 7a947f0
Showing
11 changed files
with
81 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
common/src/main/java/uk/debb/vanilla_disable/platform/Services.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package uk.debb.vanilla_disable.platform; | ||
|
||
import uk.debb.vanilla_disable.Constants; | ||
import uk.debb.vanilla_disable.platform.services.IPlatformHelper; | ||
|
||
import java.util.ServiceLoader; | ||
|
||
public class Services { | ||
public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class); | ||
|
||
public static <T> T load(Class<T> clazz) { | ||
final T loadedService = ServiceLoader.load(clazz) | ||
.findFirst() | ||
.orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName())); | ||
Constants.LOG.debug("Loaded {} for service {}", loadedService, clazz); | ||
return loadedService; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
common/src/main/java/uk/debb/vanilla_disable/platform/services/IPlatformHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package uk.debb.vanilla_disable.platform.services; | ||
|
||
public interface IPlatformHelper { | ||
boolean isModLoaded(String modId); | ||
} |
11 changes: 11 additions & 0 deletions
11
fabric/src/main/java/uk/debb/vanilla_disable/platform/FabricPlatformHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package uk.debb.vanilla_disable.platform; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import uk.debb.vanilla_disable.platform.services.IPlatformHelper; | ||
|
||
public class FabricPlatformHelper implements IPlatformHelper { | ||
@Override | ||
public boolean isModLoaded(String modId) { | ||
return FabricLoader.getInstance().isModLoaded(modId); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ain/resources/META-INF/services/uk.debb.vanilla_disable.platform.services.IPlatformHelper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uk.debb.vanilla_disable.platform.FabricPlatformHelper |
13 changes: 13 additions & 0 deletions
13
neoforge/src/main/java/uk/debb/vanilla_disable/platform/NeoForgePlatformHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package uk.debb.vanilla_disable.platform; | ||
|
||
import net.neoforged.fml.loading.LoadingModList; | ||
import uk.debb.vanilla_disable.platform.services.IPlatformHelper; | ||
|
||
import java.util.Optional; | ||
|
||
public class NeoForgePlatformHelper implements IPlatformHelper { | ||
@Override | ||
public boolean isModLoaded(String modId) { | ||
return Optional.ofNullable(LoadingModList.get()).map(ml -> ml.getModFileById(modId)).isPresent(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ain/resources/META-INF/services/uk.debb.vanilla_disable.platform.services.IPlatformHelper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uk.debb.vanilla_disable.platform.NeoForgePlatformHelper |