Compare commits

..
4 Commits
Author SHA1 Message Date
FalsePattern dc4879114d DataWatcher idextender API 2024-11-14 21:22:10 +01:00
FalsePattern 3a4194a3ff update readme with notice 2024-11-14 21:22:10 +01:00
FalsePattern 09d7677541 IDExtender make child of endlessids 2024-11-14 21:22:10 +01:00
FalsePattern 3f9173bdfe initial common ID extender api impl 2024-11-14 21:22:10 +01:00
21 changed files with 262 additions and 237 deletions

No files matched your search

+54 -1
View File
@@ -25,7 +25,7 @@ If you notice any problems when opening NEID worlds with EndlessIDs, please open
| Entity IDs | 256 | 256 | 256 | 32,768 | | Entity IDs | 256 | 256 | 256 | 32,768 |
| Potion IDs | 32 | 32 | 32 | 65,536 | | Potion IDs | 32 | 32 | 32 | 65,536 |
| Enchantment IDs | 256 | 256 | 256 | 32,768 | | Enchantment IDs | 256 | 256 | 256 | 32,768 |
| DataWatcher IDs | 32 | 127 (Broken) | 127 (Broken) | 65,536 | | DataWatcher IDs | 32 | 127 (Broken) | 127 | 65,536 |
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same | Same | | Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same | Same |
## Mod compat ## Mod compat
@@ -98,3 +98,56 @@ Mods not listed here may or may not work.
user to this GitHub repo. user to this GitHub repo.
If you find any crashes or incompatibilities, don't hesitate to open an issue. 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 introduced 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);
}
```
The `idextender.DataWatcher` class also exposes the extended DataWatcher count (used for entity data syncing over network)
in a similar fashion.
Note that these values CAN be identical to the vanilla values if the ID Extension mod implementing it has a config to
toggle itself, existence of the IDExtender class does not guarantee a fixed increase, and you should check that the
returned value is large enough for your needs.
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.
+24 -23
View File
@@ -1,5 +1,5 @@
plugins { plugins {
id("fpgradle-minecraft") version ("0.10.0") id("fpgradle-minecraft") version ("0.8.0")
} }
group = "com.falsepattern" group = "com.falsepattern"
@@ -11,6 +11,11 @@ minecraft_fp {
rootPkg = "$group.endlessids" rootPkg = "$group.endlessids"
} }
api {
packages = listOf("idextender")
ignoreRootPkg = true
}
mixin { mixin {
pkg = "mixin.mixins" pkg = "mixin.mixins"
pluginClass = "mixin.plugin.MixinPlugin" pluginClass = "mixin.plugin.MixinPlugin"
@@ -62,31 +67,17 @@ repositories {
} }
dependencies { dependencies {
// region Our deps ////////////////Our dependencies////////////////
implementationSplit("com.falsepattern:falsepatternlib-mc1.7.10:1.5.5") implementationSplit("com.falsepattern:falsepatternlib-mc1.7.10:1.4.1")
implementation("it.unimi.dsi:fastutil:8.5.15") implementation("it.unimi.dsi:fastutil:8.5.13")
implementationSplit("com.falsepattern:chunkapi-mc1.7.10:0.6.0") implementationSplit("com.falsepattern:chunkapi-mc1.7.10:0.5.1")
// endregion
// region maintained mods ////////////////Patched mods////////////////
//DragonAPI V33b
compileOnly(deobfCurse("dragonapi-235591:4722480"))
//Immersive Cavegen 1.2g hotfix5
compileOnly(deobfCurse("immersivecavegen-521557:4723376"))
//Hbm's Nuclear Tech Mod 1.0.27X5188
compileOnly(deobfCurse("hbm-ntm-235439:6017897"))
// endregion
// region unmaintained mods
//AbyssalCraft 1.9.1.3-FINAL //AbyssalCraft 1.9.1.3-FINAL
compileOnly(deobfCurse("abyssalcraft-53686:2311135")) compileOnly(deobfCurse("abyssalcraft-53686:2311135"))
//Advanced Rocketry 1.4.0-32 //Advanced Rocketry
compileOnly(deobfCurse("advancedrocketry-236542:2985057")) compileOnly(deobfCurse("advancedrocketry-236542:2985057"))
//Alternate Terrain Generation 0.12.0 //Alternate Terrain Generation 0.12.0
@@ -98,6 +89,9 @@ dependencies {
//Anti ID Conflict 1.3.5 //Anti ID Conflict 1.3.5
compileOnly(deobfCurse("antiidconflict-246288:2308279")) compileOnly(deobfCurse("antiidconflict-246288:2308279"))
// //ArchaicFix 0.2.0
// compileOnly("com.github.embeddedt:ArchaicFix:0.2.0:dev")
//Atum 0.6.77 //Atum 0.6.77
compileOnly(deobfCurse("atum-59621:2256356")) compileOnly(deobfCurse("atum-59621:2256356"))
@@ -130,6 +124,9 @@ dependencies {
//Source: https://github.com/CannibalVox/DimDoors/releases/download/2.2.5-test9/DimensionalDoors-2.2.5-test9.jar //Source: https://github.com/CannibalVox/DimDoors/releases/download/2.2.5-test9/DimensionalDoors-2.2.5-test9.jar
compileOnly(deobf("CannibalVox.DimDoors:DimensionalDoors:2.2.5-test9")) compileOnly(deobf("CannibalVox.DimDoors:DimensionalDoors:2.2.5-test9"))
//DragonAPI V32a
compileOnly(deobfCurse("dragonapi-235591:4611379"))
//Dynamic Surroundings 1.0.6.4 //Dynamic Surroundings 1.0.6.4
compileOnly(deobfCurse("dynamicsurrounding-238891:2642381")) compileOnly(deobfCurse("dynamicsurrounding-238891:2642381"))
@@ -161,6 +158,9 @@ dependencies {
//Highlands 2.2.3 //Highlands 2.2.3
compileOnly(deobfCurse("highlands-221226:2227924")) compileOnly(deobfCurse("highlands-221226:2227924"))
//Immersive Cavegen 1.2g
compileOnly(deobfCurse("immersivecavegen-521557:3649411"))
//Industrial Revolution by Redstone Rebooted 1.1.1 //Industrial Revolution by Redstone Rebooted 1.1.1
compileOnly(deobfCurse("industrialrevolutionbyredstonerebooted-241812:2538035")) compileOnly(deobfCurse("industrialrevolutionbyredstonerebooted-241812:2538035"))
@@ -185,6 +185,9 @@ dependencies {
//Nostalgic World Generation 1.0.0 //Nostalgic World Generation 1.0.0
compileOnly(deobfCurse("nostalgiagenerator-927053:4816167")) compileOnly(deobfCurse("nostalgiagenerator-927053:4816167"))
//Hbm's Nuclear Tech Mod 1.0.27X5027
compileOnly(deobfCurse("hbm-ntm-235439:5534354"))
//RandomThings 2.2.4 //RandomThings 2.2.4
compileOnly(deobfCurse("randomthings-59816:2225310")) compileOnly(deobfCurse("randomthings-59816:2225310"))
@@ -218,8 +221,6 @@ dependencies {
//WorldEdit 6.1.1 //WorldEdit 6.1.1
compileOnly(deobfCurse("worldedit-225608:2309699")) compileOnly(deobfCurse("worldedit-225608:2309699"))
// endregion
////////////////Dependencies for patched mods//////////////// ////////////////Dependencies for patched mods////////////////
//SpaceCore 0.7.14 //SpaceCore 0.7.14
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -1
View File
@@ -86,7 +86,8 @@ done
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -43,8 +43,8 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
version = Tags.VERSION, version = Tags.VERSION,
name = Tags.MODNAME, name = Tags.MODNAME,
acceptedMinecraftVersions = "[1.7.10]", acceptedMinecraftVersions = "[1.7.10]",
dependencies = "required-after:chunkapi@[0.6.0,);" + dependencies = "required-after:chunkapi@[0.5.0,0.6.0);" +
"required-after:falsepatternlib@[1.5.5,);" + "required-after:falsepatternlib@[1.4.1,);" +
"after:antiidconflict") "after:antiidconflict")
public class EndlessIDs { public class EndlessIDs {
public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0]; public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
@@ -58,6 +58,9 @@ public class ExtendedConstants {
public static final int itemIDCount = 1 << (bitsPerID - countCorrectionItemBits); public static final int itemIDCount = 1 << (bitsPerID - countCorrectionItemBits);
public static final int maxItemID = itemIDCount - 1; 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 bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
public static final int nibblesPerBlock = bitsPerBlock / 4; public static final int nibblesPerBlock = bitsPerBlock / 4;
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16; 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 itemIDCount = 32000;
public static final int maxItemID = itemIDCount - 1; 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 bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
public static final int nibblesPerBlock = bitsPerBlock / 4; public static final int nibblesPerBlock = bitsPerBlock / 4;
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16; public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
@@ -27,15 +27,13 @@ import com.falsepattern.chunk.api.ArrayUtil;
import com.falsepattern.chunk.api.DataManager; import com.falsepattern.chunk.api.DataManager;
import com.falsepattern.endlessids.Tags; import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook; import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
import com.falsepattern.endlessids.util.DataUtil;
import lombok.val; import lombok.val;
import lombok.var; import lombok.var;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray; import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@@ -46,7 +44,7 @@ import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerS
import static com.falsepattern.endlessids.util.DataUtil.*; import static com.falsepattern.endlessids.util.DataUtil.*;
//NOTE: Also change the save logic in MapWriter mod if changing this //NOTE: Also change the save logic in MapWriter mod if changing this
public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager, DataManager.BlockPacketDataManager { public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
@Override @Override
public String domain() { public String domain() {
@@ -75,24 +73,24 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
} }
val subChunk = (SubChunkBlockHook) subChunkList[i]; val subChunk = (SubChunkBlockHook) subChunkList[i];
storageFlags |= subChunk.eid$getBlockMask() << (i * 2); storageFlags |= subChunk.getBlockMask() << (i * 2);
val b1 = subChunk.eid$getB1(); val b1 = subChunk.getB1();
data.put(b1); data.put(b1);
val b2Low = subChunk.eid$getB2Low(); val b2Low = subChunk.getB2Low();
if (b2Low == null) { if (b2Low == null) {
continue; continue;
} }
data.put(b2Low.data); data.put(b2Low.data);
val b2High = subChunk.eid$getB2High(); val b2High = subChunk.getB2High();
if (b2High == null) { if (b2High == null) {
continue; continue;
} }
data.put(b2High.data); data.put(b2High.data);
val b3 = subChunk.eid$getB3(); val b3 = subChunk.getB3();
if (b3 != null) { if (b3 != null) {
data.put(b3); data.put(b3);
} }
@@ -110,36 +108,36 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
} }
val subChunk = (SubChunkBlockHook) subChunkList[i]; val subChunk = (SubChunkBlockHook) subChunkList[i];
val storageFlag = (storageFlags >>> (i * 2)) & 3; val storageFlag = (storageFlags >>> (i * 2)) & 3;
val b1 = subChunk.eid$getB1(); val b1 = subChunk.getB1();
buffer.get(b1); buffer.get(b1);
if (storageFlag == 0b00) { if (storageFlag == 0b00) {
subChunk.eid$setB2Low(null); subChunk.setB2Low(null);
subChunk.eid$setB2High(null); subChunk.setB2High(null);
subChunk.eid$setB3(null); subChunk.setB3(null);
continue; continue;
} }
var b2Low = subChunk.eid$getB2Low(); var b2Low = subChunk.getB2Low();
if (b2Low == null) { if (b2Low == null) {
b2Low = subChunk.eid$createB2Low(); b2Low = subChunk.createB2Low();
} }
buffer.get(b2Low.data); buffer.get(b2Low.data);
if (storageFlag == 0b01) { if (storageFlag == 0b01) {
subChunk.eid$setB2High(null); subChunk.setB2High(null);
subChunk.eid$setB3(null); subChunk.setB3(null);
continue; continue;
} }
var b2High = subChunk.eid$getB2High(); var b2High = subChunk.getB2High();
if (b2High == null) { if (b2High == null) {
b2High = subChunk.eid$createB2High(); b2High = subChunk.createB2High();
} }
buffer.get(b2High.data); buffer.get(b2High.data);
if (storageFlag == 0b10) { if (storageFlag == 0b10) {
subChunk.eid$setB3(null); subChunk.setB3(null);
continue; continue;
} }
var b3 = subChunk.eid$getB3(); var b3 = subChunk.getB3();
if (b3 == null) { if (b3 == null) {
b3 = subChunk.eid$createB3(); b3 = subChunk.createB3();
} }
buffer.get(b3); buffer.get(b3);
} }
@@ -154,10 +152,10 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
@Override @Override
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) { public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla; val subChunk = (SubChunkBlockHook) subChunkVanilla;
val b1 = subChunk.eid$getB1(); val b1 = subChunk.getB1();
val b2Low = subChunk.eid$getB2Low(); val b2Low = subChunk.getB2Low();
val b2High = subChunk.eid$getB2High(); val b2High = subChunk.getB2High();
val b3 = subChunk.eid$getB3(); val b3 = subChunk.getB3();
nbt.setByteArray("Blocks", b1); nbt.setByteArray("Blocks", b1);
if (b2Low != null) { if (b2Low != null) {
nbt.setByteArray("Add", b2Low.data); nbt.setByteArray("Add", b2Low.data);
@@ -186,9 +184,9 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
b2L[nI] |= (byte) (((s & 0x0F00) >>> 8) << mI); b2L[nI] |= (byte) (((s & 0x0F00) >>> 8) << mI);
b2H[nI] |= (byte) (((s & 0xF000) >>> 12) << mI); b2H[nI] |= (byte) (((s & 0xF000) >>> 12) << mI);
} }
subChunk.eid$setB1(b1); subChunk.setB1(b1);
subChunk.eid$setB2Low(new NibbleArray(b2L, 4)); subChunk.setB2Low(new NibbleArray(b2L, 4));
subChunk.eid$setB2High(new NibbleArray(b2H, 4)); subChunk.setB2High(new NibbleArray(b2H, 4));
} }
@Override @Override
@@ -204,10 +202,10 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null; final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null; final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
subChunk.eid$setB1(ensureSubChunkByteArray(b1)); subChunk.setB1(ensureSubChunkByteArray(b1));
subChunk.eid$setB2Low(ensureSubChunkNibbleArray(b2Low)); subChunk.setB2Low(ensureSubChunkNibbleArray(b2Low));
subChunk.eid$setB2High(ensureSubChunkNibbleArray(b2High)); subChunk.setB2High(ensureSubChunkNibbleArray(b2High));
subChunk.eid$setB3(ensureSubChunkByteArray(b3)); subChunk.setB3(ensureSubChunkByteArray(b3));
} }
@Override @Override
@@ -215,10 +213,10 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
val from = (SubChunkBlockHook) fromVanilla; val from = (SubChunkBlockHook) fromVanilla;
val to = (SubChunkBlockHook) toVanilla; val to = (SubChunkBlockHook) toVanilla;
to.eid$setB1(ArrayUtil.copyArray(from.eid$getB1(), to.eid$getB1())); to.setB1(ArrayUtil.copyArray(from.getB1(), to.getB1()));
to.eid$setB2Low(ArrayUtil.copyArray(from.eid$getB2Low(), to.eid$getB2Low())); to.setB2Low(ArrayUtil.copyArray(from.getB2Low(), to.getB2Low()));
to.eid$setB2High(ArrayUtil.copyArray(from.eid$getB2High(), to.eid$getB2High())); to.setB2High(ArrayUtil.copyArray(from.getB2High(), to.getB2High()));
to.eid$setB3(ArrayUtil.copyArray(from.eid$getB3(), to.eid$getB3())); to.setB3(ArrayUtil.copyArray(from.getB3(), to.getB3()));
} }
@Override @Override
@@ -240,24 +238,4 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
public @Nullable String versionChangeMessage(String priorVersion) { public @Nullable String versionChangeMessage(String priorVersion) {
return null; return null;
} }
@Override
public void writeBlockToPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet) {
}
@Override
public void readBlockFromPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet) {
}
@Override
public void writeBlockPacketToBuffer(S23PacketBlockChange packet, PacketBuffer buffer) {
buffer.writeInt(Block.getIdFromBlock(packet.field_148883_d));
}
@Override
public void readBlockPacketFromBuffer(S23PacketBlockChange packet, PacketBuffer buffer) {
packet.field_148883_d = Block.getBlockById(buffer.readInt());
}
} }
@@ -34,8 +34,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray; import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@@ -45,7 +43,7 @@ import java.nio.ByteBuffer;
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk; import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
//NOTE: Also change the save logic in MapWriter mod if changing this //NOTE: Also change the save logic in MapWriter mod if changing this
public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager, DataManager.BlockPacketDataManager { public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
@Override @Override
public String domain() { public String domain() {
@@ -74,18 +72,18 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
} }
val subChunk = (SubChunkBlockHook) subChunkList[i]; val subChunk = (SubChunkBlockHook) subChunkList[i];
storageFlags |= subChunk.eid$getMetadataMask() << (i * 2); storageFlags |= subChunk.getMetadataMask() << (i * 2);
val m1Low = subChunk.eid$getM1Low(); val m1Low = subChunk.getM1Low();
data.put(m1Low.data); data.put(m1Low.data);
val m1High = subChunk.eid$getM1High(); val m1High = subChunk.getM1High();
if (m1High == null) { if (m1High == null) {
continue; continue;
} }
data.put(m1High.data); data.put(m1High.data);
val m2 = subChunk.eid$getM2(); val m2 = subChunk.getM2();
if (m2 != null) { if (m2 != null) {
data.put(m2); data.put(m2);
} }
@@ -103,25 +101,25 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
} }
val subChunk = (SubChunkBlockHook) subChunkList[i]; val subChunk = (SubChunkBlockHook) subChunkList[i];
val storageFlag = (storageFlags >>> (i * 2)) & 3; val storageFlag = (storageFlags >>> (i * 2)) & 3;
val m1Low = subChunk.eid$getM1Low(); val m1Low = subChunk.getM1Low();
buffer.get(m1Low.data); buffer.get(m1Low.data);
if (storageFlag == 0b01) { if (storageFlag == 0b01) {
subChunk.eid$setM1High(null); subChunk.setM1High(null);
subChunk.eid$setM2(null); subChunk.setM2(null);
continue; continue;
} }
var m1High = subChunk.eid$getM1High(); var m1High = subChunk.getM1High();
if (m1High == null) { if (m1High == null) {
m1High = subChunk.eid$createM1High(); m1High = subChunk.createM1High();
} }
buffer.get(m1High.data); buffer.get(m1High.data);
if (storageFlag == 0b10) { if (storageFlag == 0b10) {
subChunk.eid$setM2(null); subChunk.setM2(null);
continue; continue;
} }
var m2 = subChunk.eid$getM2(); var m2 = subChunk.getM2();
if (m2 == null) { if (m2 == null) {
m2 = subChunk.eid$createM2(); m2 = subChunk.createM2();
} }
buffer.get(m2); buffer.get(m2);
} }
@@ -135,9 +133,9 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
@Override @Override
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) { public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla; val subChunk = (SubChunkBlockHook) subChunkVanilla;
val m1Low = subChunk.eid$getM1Low(); val m1Low = subChunk.getM1Low();
val m1High = subChunk.eid$getM1High(); val m1High = subChunk.getM1High();
val m2 = subChunk.eid$getM2(); val m2 = subChunk.getM2();
nbt.setByteArray("Data", m1Low.data); nbt.setByteArray("Data", m1Low.data);
if (m1High != null) { if (m1High != null) {
nbt.setByteArray("Data1High", m1High.data); nbt.setByteArray("Data1High", m1High.data);
@@ -163,9 +161,9 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
m1High[nI] |= (byte) (((s & 0x00F0) >>> 4) << mI); m1High[nI] |= (byte) (((s & 0x00F0) >>> 4) << mI);
m2[i] = (byte) ((s & 0xFF00) >>> 8); m2[i] = (byte) ((s & 0xFF00) >>> 8);
} }
subChunk.eid$setM1Low(new NibbleArray(m1Low, 4)); subChunk.setM1Low(new NibbleArray(m1Low, 4));
subChunk.eid$setM1High(new NibbleArray(m1High, 4)); subChunk.setM1High(new NibbleArray(m1High, 4));
subChunk.eid$setM2(m2); subChunk.setM2(m2);
} }
@Override @Override
@@ -180,9 +178,9 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
final byte[] m1High = nbt.hasKey("Data1High") ? nbt.getByteArray("Data1High") : null; final byte[] m1High = nbt.hasKey("Data1High") ? nbt.getByteArray("Data1High") : null;
final byte[] m2 = nbt.hasKey("Data2") ? nbt.getByteArray("Data2") : null; final byte[] m2 = nbt.hasKey("Data2") ? nbt.getByteArray("Data2") : null;
subChunk.eid$setM1Low(DataUtil.ensureSubChunkNibbleArray(m1Low)); subChunk.setM1Low(DataUtil.ensureSubChunkNibbleArray(m1Low));
subChunk.eid$setM1High(DataUtil.ensureSubChunkNibbleArray(m1High)); subChunk.setM1High(DataUtil.ensureSubChunkNibbleArray(m1High));
subChunk.eid$setM2(DataUtil.ensureSubChunkByteArray(m2)); subChunk.setM2(DataUtil.ensureSubChunkByteArray(m2));
} }
@Override @Override
@@ -190,9 +188,9 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
val from = (SubChunkBlockHook) fromVanilla; val from = (SubChunkBlockHook) fromVanilla;
val to = (SubChunkBlockHook) toVanilla; val to = (SubChunkBlockHook) toVanilla;
to.eid$setM1Low(ArrayUtil.copyArray(from.eid$getM1Low(), to.eid$getM1Low())); to.setM1Low(ArrayUtil.copyArray(from.getM1Low(), to.getM1Low()));
to.eid$setM1High(ArrayUtil.copyArray(from.eid$getM1High(), to.eid$getM1High())); to.setM1High(ArrayUtil.copyArray(from.getM1High(), to.getM1High()));
to.eid$setM2(ArrayUtil.copyArray(from.eid$getM2(), to.eid$getM2())); to.setM2(ArrayUtil.copyArray(from.getM2(), to.getM2()));
} }
@Override @Override
@@ -214,24 +212,4 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
public @Nullable String versionChangeMessage(String priorVersion) { public @Nullable String versionChangeMessage(String priorVersion) {
return null; return null;
} }
@Override
public void writeBlockToPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet) {
}
@Override
public void readBlockFromPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet) {
}
@Override
public void writeBlockPacketToBuffer(S23PacketBlockChange packet, PacketBuffer buffer) {
buffer.writeShort(packet.field_148884_e & 0xFFFF);
}
@Override
public void readBlockPacketFromBuffer(S23PacketBlockChange packet, PacketBuffer buffer) {
packet.field_148884_e = buffer.readUnsignedShort();
}
} }
@@ -1,32 +0,0 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice, this permission notice and the words "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.helpers;
public interface IHBMBiomeSyncPacket {
void eid$setBiome(short biome);
short eid$getBiome();
void eid$setBiomeArray(short[] biomeArray);
short[] eid$getBiomeArray();
}
@@ -26,53 +26,47 @@ package com.falsepattern.endlessids.mixin.helpers;
import net.minecraft.world.chunk.NibbleArray; import net.minecraft.world.chunk.NibbleArray;
public interface SubChunkBlockHook { public interface SubChunkBlockHook {
byte[] eid$getB1(); byte[] getB1();
void eid$setB1(byte[] data); void setB1(byte[] data);
NibbleArray eid$getB2Low(); NibbleArray getB2Low();
void eid$setB2Low(NibbleArray data); void setB2Low(NibbleArray data);
NibbleArray eid$createB2Low(); NibbleArray createB2Low();
NibbleArray eid$getB2High(); NibbleArray getB2High();
void eid$setB2High(NibbleArray data); void setB2High(NibbleArray data);
NibbleArray eid$createB2High(); NibbleArray createB2High();
byte[] eid$getB3(); byte[] getB3();
void eid$setB3(byte[] data); void setB3(byte[] data);
byte[] eid$createB3(); byte[] createB3();
int eid$getBlockMask(); int getMetadataMask();
int eid$getID(int x, int y, int z); int getBlockMask();
void eid$setID(int x, int y, int z, int id); int getID(int x, int y, int z);
NibbleArray eid$getM1Low(); NibbleArray getM1Low();
void eid$setM1Low(NibbleArray m1Low); void setM1Low(NibbleArray m1Low);
NibbleArray eid$getM1High(); NibbleArray getM1High();
void eid$setM1High(NibbleArray m1High); void setM1High(NibbleArray m1High);
NibbleArray eid$createM1High(); NibbleArray createM1High();
byte[] eid$getM2(); byte[] getM2();
void eid$setM2(byte[] m2); void setM2(byte[] m2);
byte[] eid$createM2(); byte[] createM2();
int eid$getMetadataMask();
int eid$getMetadata(int x, int y, int z);
void eid$setMetadata(int x, int y, int z, int id);
} }
@@ -38,6 +38,6 @@ public abstract class ChunkRadiationHandlerPRISMMixin {
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"), target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1) require = 1)
private byte[] extendLSBArray(ExtendedBlockStorage instance) { private byte[] extendLSBArray(ExtendedBlockStorage instance) {
return ((SubChunkBlockHook)instance).eid$getB1(); return ((SubChunkBlockHook)instance).getB1();
} }
} }
@@ -38,6 +38,6 @@ public abstract class ChunkRadiationHandlerPRISM_SubChunkMixin {
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"), target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1) require = 1)
private byte[] extendLSBArray(ExtendedBlockStorage instance) { private byte[] extendLSBArray(ExtendedBlockStorage instance) {
return ((SubChunkBlockHook)instance).eid$getB1(); return ((SubChunkBlockHook)instance).getB1();
} }
} }
@@ -50,7 +50,7 @@ public abstract class BiomeUndergroundDecoratorMixin {
private byte[] returnLSB(ExtendedBlockStorage subChunkVanilla) { private byte[] returnLSB(ExtendedBlockStorage subChunkVanilla) {
SubChunkBlockHook subChunk = (SubChunkBlockHook) subChunkVanilla; SubChunkBlockHook subChunk = (SubChunkBlockHook) subChunkVanilla;
this.subChunk = subChunk; this.subChunk = subChunk;
return subChunk.eid$getB1(); return subChunk.getB1();
} }
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", @Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
@@ -70,7 +70,7 @@ public abstract class BiomeUndergroundDecoratorMixin {
remap = true), remap = true),
require = 2) require = 2)
private int returnRestOfID(NibbleArray instance, int x, int y, int z) { private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
val id = subChunk.eid$getID(x, y, z) >>> 8; val id = subChunk.getID(x, y, z) >>> 8;
subChunk = null; subChunk = null;
return id; return id;
} }
@@ -65,7 +65,7 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
private NibbleArray m1High; private NibbleArray m1High;
private byte[] m2; private byte[] m2;
public int eid$getID(int x, int y, int z) { public int getID(int x, int y, int z) {
int index = y << 8 | z << 4 | x; int index = y << 8 | z << 4 | x;
int id = blockLSBArray[index] & 0xFF; int id = blockLSBArray[index] & 0xFF;
if (blockMSBArray != null) { if (blockMSBArray != null) {
@@ -80,19 +80,19 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
return id; return id;
} }
public void eid$setID(int x, int y, int z, int id) { private void setID(int x, int y, int z, int id) {
int index = y << 8 | z << 4 | x; int index = y << 8 | z << 4 | x;
blockLSBArray[index] = (byte) (id & 0xFF); blockLSBArray[index] = (byte) (id & 0xFF);
if (id > 0xFF) { if (id > 0xFF) {
if (blockMSBArray == null) { if (blockMSBArray == null) {
eid$createB2Low(); createB2Low();
} }
if (id > 0xFFF) { if (id > 0xFFF) {
if (b2High == null) { if (b2High == null) {
eid$createB2High(); createB2High();
} }
if (id > 0xFFFF && b3 == null) { if (id > 0xFFFF && b3 == null) {
eid$createB3(); createB3();
} }
} }
} }
@@ -113,7 +113,7 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
*/ */
@Overwrite @Overwrite
public Block getBlockByExtId(int x, int y, int z) { public Block getBlockByExtId(int x, int y, int z) {
return Block.getBlockById(eid$getID(x, y, z)); return Block.getBlockById(getID(x, y, z));
} }
/** /**
@@ -138,7 +138,7 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
} }
int blockID = Hooks.getIdFromBlockWithCheck(newBlock, oldBlock); int blockID = Hooks.getIdFromBlockWithCheck(newBlock, oldBlock);
eid$setID(x, y, z, blockID); setID(x, y, z, blockID);
} }
/** /**
@@ -166,10 +166,10 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
blockMetadataArray.set(x, y, z, meta & 0xF); blockMetadataArray.set(x, y, z, meta & 0xF);
if (meta > 0xF) { if (meta > 0xF) {
if (m1High == null) { if (m1High == null) {
eid$createM1High(); createM1High();
} }
if (meta > 0xFF && m2 == null) { if (meta > 0xFF && m2 == null) {
eid$createM2(); createM2();
} }
} }
if (m1High != null) { if (m1High != null) {
@@ -180,16 +180,6 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
} }
} }
@Override
public int eid$getMetadata(int x, int y, int z) {
return getExtBlockMetadata(x, y, z);
}
@Override
public void eid$setMetadata(int x, int y, int z, int id) {
setExtBlockMetadata(x, y, z, id);
}
@Redirect(method = "removeInvalidBlocks", @Redirect(method = "removeInvalidBlocks",
at = @At(value = "INVOKE", at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockByExtId(III)Lnet/minecraft/block/Block;"), target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockByExtId(III)Lnet/minecraft/block/Block;"),
@@ -212,102 +202,102 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
} }
@Override @Override
public byte[] eid$getB1() { public byte[] getB1() {
return blockLSBArray; return blockLSBArray;
} }
@Override @Override
public void eid$setB1(byte[] data) { public void setB1(byte[] data) {
blockLSBArray = data; blockLSBArray = data;
} }
@Override @Override
public NibbleArray eid$getB2Low() { public NibbleArray getB2Low() {
return blockMSBArray; return blockMSBArray;
} }
@Override @Override
public void eid$setB2Low(NibbleArray data) { public void setB2Low(NibbleArray data) {
blockMSBArray = data; blockMSBArray = data;
} }
@Override @Override
public NibbleArray eid$createB2Low() { public NibbleArray createB2Low() {
return (blockMSBArray = new NibbleArray(blocksPerSubChunk, 4)); return (blockMSBArray = new NibbleArray(blocksPerSubChunk, 4));
} }
@Override @Override
public NibbleArray eid$getB2High() { public NibbleArray getB2High() {
return b2High; return b2High;
} }
@Override @Override
public void eid$setB2High(NibbleArray data) { public void setB2High(NibbleArray data) {
b2High = data; b2High = data;
} }
@Override @Override
public NibbleArray eid$createB2High() { public NibbleArray createB2High() {
return (b2High = new NibbleArray(blocksPerSubChunk, 4)); return (b2High = new NibbleArray(blocksPerSubChunk, 4));
} }
@Override @Override
public byte[] eid$getB3() { public byte[] getB3() {
return b3; return b3;
} }
@Override @Override
public void eid$setB3(byte[] data) { public void setB3(byte[] data) {
b3 = data; b3 = data;
} }
@Override @Override
public byte[] eid$createB3() { public byte[] createB3() {
return b3 = new byte[blocksPerSubChunk]; return b3 = new byte[blocksPerSubChunk];
} }
@Override @Override
public NibbleArray eid$getM1Low() { public NibbleArray getM1Low() {
return blockMetadataArray; return blockMetadataArray;
} }
@Override @Override
public void eid$setM1Low(NibbleArray m1Low) { public void setM1Low(NibbleArray m1Low) {
blockMetadataArray = m1Low; blockMetadataArray = m1Low;
} }
@Override @Override
public NibbleArray eid$getM1High() { public NibbleArray getM1High() {
return m1High; return m1High;
} }
@Override @Override
public void eid$setM1High(NibbleArray m1High) { public void setM1High(NibbleArray m1High) {
this.m1High = m1High; this.m1High = m1High;
} }
@Override @Override
public NibbleArray eid$createM1High() { public NibbleArray createM1High() {
return (m1High = new NibbleArray(blocksPerSubChunk, 4)); return (m1High = new NibbleArray(blocksPerSubChunk, 4));
} }
@Override @Override
public byte[] eid$getM2() { public byte[] getM2() {
return m2; return m2;
} }
@Override @Override
public void eid$setM2(byte[] m2) { public void setM2(byte[] m2) {
this.m2 = m2; this.m2 = m2;
} }
@Override @Override
public byte[] eid$createM2() { public byte[] createM2() {
return (m2 = new byte[blocksPerSubChunk]); return (m2 = new byte[blocksPerSubChunk]);
} }
@Override @Override
public int eid$getBlockMask() { public int getBlockMask() {
if (blockMSBArray == null) { if (blockMSBArray == null) {
return 0b00; return 0b00;
} }
@@ -321,7 +311,7 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
} }
@Override @Override
public int eid$getMetadataMask() { public int getMetadataMask() {
if (m1High == null) { if (m1High == null) {
return 0b01; return 0b01;
} }
+16
View File
@@ -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 DataWatcher {
public static int maxWatchableID() {
return GeneralConfig.extendDataWatcher ? ExtendedConstants.maxWatchableID : VanillaConstants.maxWatchableID;
}
public static int watchableBits() {
return GeneralConfig.extendDataWatcher ? ExtendedConstants.watchableBits : VanillaConstants.watchableBits;
}
}
+14
View File
@@ -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;
}
}
+16
View File
@@ -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;
+1 -1
View File
@@ -6,7 +6,7 @@
"dependencies": { "dependencies": {
"always": { "always": {
"common": [ "common": [
"it.unimi.dsi:fastutil:8.5.15" "it.unimi.dsi:fastutil:8.5.13"
], ],
"client": [], "client": [],
"server": [] "server": []
+6
View File
@@ -14,5 +14,11 @@
"logoFile": "", "logoFile": "",
"screenshots": [], "screenshots": [],
"dependencies": [] "dependencies": []
},
{
"modid": "idextender",
"name": "ID Extender",
"version": "1.0.0",
"parent": "${modId}"
} }
] ]