mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-12 17:47:37 +00:00
initial common ID extender api impl
This commit is contained in:
7 files changed
+91
No files matched your search
@@ -98,3 +98,49 @@ Mods not listed here may or may not work.
|
||||
user to this GitHub repo.
|
||||
|
||||
If you find any crashes or incompatibilities, don't hesitate to open an issue.
|
||||
|
||||
## Depending On Metadata Increase In Another Mod
|
||||
|
||||
**NOTE:** This API is available as of version <!--TODO--> of EndlessIDs.
|
||||
|
||||
EndlessIDs implements the common ID Extender API added in NotEnoughIDs Unofficial. See:
|
||||
https://github.com/GTNewHorizons/NotEnoughIds/pull/17
|
||||
|
||||
The description below is an excerpt of NEID-U's readme concerning this API:
|
||||
|
||||
In order to use the metadata, you should not create a hard dependency on the `endlessids` Mod ID, but rather on the `idextender` Mod ID.
|
||||
EndlessIDs bundles this "dummy" mod alongside itself.
|
||||
|
||||
Here is an example of how to use it, you could put this code in your Mod's pre-init for example:
|
||||
|
||||
```java
|
||||
import idextender;
|
||||
|
||||
int maxMeta = 15;
|
||||
|
||||
if (Loader.isModLoaded("idextender")) {
|
||||
maxMeta = (Integer) Class.forName("idextender.Metadata").getDeclaredMethod("maximumMetadata").invoke(null);
|
||||
}
|
||||
```
|
||||
|
||||
You can also query for the number of bits the metadata value is extended to, rather than the maximum value:
|
||||
|
||||
```java
|
||||
import idextender;
|
||||
|
||||
int metadataBits = 4;
|
||||
|
||||
if (Loader.isModLoaded("idextender")){
|
||||
metadataBits = (Integer) Class.forName("idextender.Metadata").getDeclaredMethod("metadataBits").invoke(null);
|
||||
}
|
||||
```
|
||||
|
||||
If for some reason, you need to know what parent mod is providing the `idextender` mod, you can do the following, which will give you
|
||||
back the Mod ID of the actual mod that has provided `idextender`. For example, `endlessids`:
|
||||
|
||||
```java
|
||||
// This will give back the value "endlessids" which is EndlessIDs' Mod ID
|
||||
String parentIDExtender = (String) Class.forName("idextender.IDExtender").getDeclaredMethod("parentModId").invoke(null);
|
||||
```
|
||||
|
||||
For more information, see the NotEnoughIDs readme.
|
||||
@@ -11,6 +11,11 @@ minecraft_fp {
|
||||
rootPkg = "$group.endlessids"
|
||||
}
|
||||
|
||||
api {
|
||||
packages = listOf("idextender")
|
||||
ignoreRootPkg = true
|
||||
}
|
||||
|
||||
mixin {
|
||||
pkg = "mixin.mixins"
|
||||
pluginClass = "mixin.plugin.MixinPlugin"
|
||||
|
||||
@@ -58,6 +58,9 @@ public class ExtendedConstants {
|
||||
public static final int itemIDCount = 1 << (bitsPerID - countCorrectionItemBits);
|
||||
public static final int maxItemID = itemIDCount - 1;
|
||||
|
||||
public static final int metadataCount = (1 << bitsPerMetadata);
|
||||
public static final int maxMetadata = metadataCount - 1;
|
||||
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
|
||||
|
||||
@@ -48,6 +48,9 @@ public class VanillaConstants {
|
||||
public static final int itemIDCount = 32000;
|
||||
public static final int maxItemID = itemIDCount - 1;
|
||||
|
||||
public static final int metadataCount = (1 << bitsPerMetadata);
|
||||
public static final int maxMetadata = metadataCount - 1;
|
||||
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package idextender;
|
||||
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
|
||||
@Mod(modid = "idextender", name = "ID Extender", version = "1.0.0")
|
||||
public class IDExtender {
|
||||
|
||||
public static String parentModId() {
|
||||
return Tags.MODID;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package idextender;
|
||||
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
|
||||
public class Metadata {
|
||||
public static int maximumMetadata() {
|
||||
return GeneralConfig.extendBlockItem ? ExtendedConstants.maxMetadata : VanillaConstants.maxMetadata;
|
||||
}
|
||||
|
||||
public static int metadataBits() {
|
||||
return GeneralConfig.extendBlockItem ? ExtendedConstants.bitsPerMetadata : VanillaConstants.bitsPerMetadata;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Interop with NEID Unofficial, to let mods avoid hard-depending on either NEIDu or EndlessIDs
|
||||
*/
|
||||
package idextender;
|
||||
Reference in new issue
Block a user