Compare commits

...
8 Commits
Author SHA1 Message Date
FalsePattern 2acbb60547 ThutCore/ThutMods compat (#175) 2024-06-09 21:21:48 +02:00
FalsePattern 098254dc82 Nostalgic World Generation / OWG compat (#158, #176) 2024-06-09 21:11:17 +02:00
FalsePattern 0f810afe90 notice to self 2024-06-09 20:52:12 +02:00
FalsePattern fa66c21a8a Matter Overdrive compat 2024-06-09 18:46:56 +02:00
FalsePattern 2b90b7688b better item ID saving in nbt 2024-06-09 18:43:25 +02:00
FalsePattern ca5f27dffc make emergency crash method unique 2024-06-09 13:32:43 +02:00
FalsePattern 6eeafe5a23 null safety in datawatcher 2024-06-08 00:24:52 +02:00
FalsePattern 22d269eda5 small tidy 2024-06-07 20:02:43 +02:00
15 changed files with 321 additions and 27 deletions

No files matched your search

+11 -1
View File
@@ -10,7 +10,7 @@ new limits.
- [UniMixins](https://github.com/LegacyModdingMC/UniMixins)
- [ChunkAPI](https://github.com/FalsePattern/ChunkAPI)
## NotEnoughIDs
## NotEnoughIDs world compatibility
EndlessIDs can open and upgrade worlds created with NotEnoughIDs without any problems (both the original and the Unofficial version).
If you notice any problems when opening NEID worlds with EndlessIDs, please open an issue!
@@ -32,6 +32,9 @@ If you notice any problems when opening NEID worlds with EndlessIDs, please open
This mod also contains patches for the following mods:
<details>
<summary>Mod list</summary>
- AbyssalCraft
- Advanced Rocketry
- Alternate Terrain Generation
@@ -59,22 +62,29 @@ This mod also contains patches for the following mods:
- Highlands
- Immersive Cavegen
- Industrial Revolution by Redstone Rebooted
- Matter Overdrive
- More Fun Quicksand Mod
- Nature's Compass
- Netherlicious
- Nomadic Tents
- Nostalgic World Generation
- Old World Gen
- Random Things
- Restructured
- Realistic Terrain Generation
- Realistic World Generation
- Thaumcraft
- The Lord of the Rings Mod: Legacy
- ThutCore/ThutMods
- Tropicraft
- Twilight Forest
- Underground Biomes Constructs
- Witchery
- WorldEdit
</details>
Mods not listed here may or may not work.
- For item/block IDs:
+11 -1
View File
@@ -119,7 +119,10 @@ dependencies {
compileOnly(deobfCurse("industrialrevolutionbyredstonerebooted-241812:2538035"))
//LOTR Mod 36.15
implementation(deobfCurse("lotrmod-423748:4091561"))
compileOnly(deobfCurse("lotrmod-423748:4091561"))
//Matter Overdrive 0.4.2-hotfix1
compileOnly(deobfCurse("matteroverdrive-229694:2331162"))
//More Fun Quicksands Mod 1.0.8.8-fixed
compileOnly(deobfCurse("more-fun-quicksand-mod-321960:2717318"))
@@ -133,6 +136,9 @@ dependencies {
//Nomadic Tents 1.12.1
compileOnly(deobfCurse("nomadictents-238794:2679476"))
//Nostalgic World Generation 1.0.0
compileOnly(deobfCurse("nostalgiagenerator-927053:4816167"))
//RandomThings 2.2.4
compileOnly(deobfCurse("randomthings-59816:2225310"))
@@ -145,6 +151,10 @@ dependencies {
//Thaumcraft 4.2.3.5
compileOnly(deobfCurse("thaumcraft-223628:2227552"))
//ThutCore 2.0
//Only available on dropbox
compileOnly(deobf("https://mvn.falsepattern.com/releases/mirror/mirror/thutcore-2.0.jar"))
//Tropicraft 6.0.5
//This is from a mirror file, because the file on curseforge is a zip containing other files too.
//Source: https://www.curseforge.com/minecraft/mc-mods/tropicraft/files/2353906
@@ -15,6 +15,7 @@ import net.minecraft.world.chunk.Chunk;
import java.nio.ByteBuffer;
//NOTE: Also change the save logic in MapWriter mod if changing this
public class BiomeManager implements DataManager.PacketDataManager, DataManager.ChunkDataManager {
@Override
@@ -20,6 +20,7 @@ import java.nio.ByteBuffer;
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
import static com.falsepattern.endlessids.util.DataUtil.*;
//NOTE: Also change the save logic in MapWriter mod if changing this
public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
@Override
@@ -19,6 +19,7 @@ import java.nio.ByteBuffer;
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
//NOTE: Also change the save logic in MapWriter mod if changing this
public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
@Override
@@ -0,0 +1,74 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.owg;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import owg.generator.ChunkGeneratorBeta;
import owg.map.MapGenOLD;
import owg.world.ManagerOWG;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.structure.MapGenMineshaft;
import net.minecraft.world.gen.structure.MapGenStronghold;
import java.util.Random;
@Mixin(ChunkGeneratorBeta.class)
public abstract class ChunkGeneratorBetaMixin implements IChunkProvider {
@Shadow private Random rand;
@Shadow private BiomeGenBase[] biomesForGeneration;
@Shadow private World worldObj;
@Shadow public abstract void generateTerrain(int i, int j, Block[] blocks, BiomeGenBase[] abiomegenbase, double[] ad);
@Shadow public abstract void replaceBlocksForBiome(int i, int j, Block[] blocks, byte[] metadata, BiomeGenBase[] abiomegenbase);
@Shadow private MapGenOLD field_902_u;
@Shadow @Final private boolean mapFeaturesEnabled;
@Shadow private MapGenStronghold strongholdGenerator;
@Shadow private MapGenMineshaft mineshaftGenerator;
@Shadow private int biomeSettings;
public Chunk provideChunk(int i, int j) {
this.rand.setSeed((long)i * 341873128712L + (long)j * 132897987541L);
Block[] blocks = new Block[128 * 16 * 16];
byte[] metadata = new byte[128 * 16 * 16];
this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, i * 16, j * 16, 16, 16);
double[] ad = ManagerOWG.temperature;
this.generateTerrain(i, j, blocks, this.biomesForGeneration, ad);
this.replaceBlocksForBiome(i, j, blocks, metadata, this.biomesForGeneration);
this.field_902_u.generate(this, this.worldObj, i, j, blocks);
if (this.mapFeaturesEnabled) {
this.strongholdGenerator.func_151539_a(this, this.worldObj, i, j, blocks);
this.mineshaftGenerator.func_151539_a(this, this.worldObj, i, j, blocks);
}
Chunk chunk = new Chunk(this.worldObj, blocks, metadata, i, j);
short[] abyte1 = ((ChunkBiomeHook)chunk).getBiomeShortArray();
int k;
if (this.biomeSettings == 0) {
for(k = 0; k < abyte1.length; ++k) {
abyte1[k] = (short)this.biomesForGeneration[k].biomeID;
}
} else {
for(k = 0; k < abyte1.length; ++k) {
abyte1[k] = (short)this.biomesForGeneration[(k * 16 & 255) + k / 16].biomeID;
}
}
chunk.generateSkylightMap();
return chunk;
}
}
@@ -0,0 +1,44 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.thut;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import thut.api.maths.Vector3;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
@Mixin(value = Vector3.class,
remap = false)
public abstract class Vector3Mixin {
@Shadow public abstract int intX();
@Shadow public abstract int intZ();
/**
* @author FalsePattern
* @reason ID Extension
*/
@Overwrite
public void setBiome(BiomeGenBase biome, World worldObj) {
int x = this.intX();
int z = this.intZ();
Chunk chunk = worldObj.getChunkFromBlockCoords(x, z);
val chunkHook = (ChunkBiomeHook) chunk;
short[] biomes = chunkHook.getBiomeShortArray();
short newBiome = (short)biome.biomeID;
int chunkX = Math.abs(x & 15);
int chunkZ = Math.abs(z & 15);
int point = chunkX + 16 * chunkZ;
if (biomes[point] != newBiome) {
biomes[point] = newBiome;
chunkHook.setBiomeShortArray(biomes);
chunk.setChunkModified();
}
}
}
@@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -34,18 +35,20 @@ public abstract class ChunkMixin implements ChunkBiomeHook {
public World worldObj;
@Shadow
private byte[] blockBiomeArray;
private short[] blockBiomeShortArray;
@Unique
private short[] eid$blockBiomeShortArray;
@Inject(method = "<init>(Lnet/minecraft/world/World;II)V",
at = @At(value = "RETURN"),
require = 1)
private void initShortArray(World p_i1995_1_, int p_i1995_2_, int p_i1995_3_, CallbackInfo ci) {
blockBiomeArray = null;
blockBiomeShortArray = new short[16 * 16];
Arrays.fill(blockBiomeShortArray, (short) -1);
eid$blockBiomeShortArray = new short[16 * 16];
Arrays.fill(eid$blockBiomeShortArray, (short) -1);
}
private void emergencyCrash() {
@Unique
private void eid$emergencyCrash() {
val crashMSG = "A mod that is incompatible with " + Tags.MODNAME + " has tried to access the biome array of a" +
" chunk like in vanilla! Crashing in fear of potential world corruption!\n" +
"Please report this issue on https://github.com/FalsePattern/EndlessIDs ASAP!";
@@ -57,14 +60,14 @@ public abstract class ChunkMixin implements ChunkBiomeHook {
at = @At(value = "HEAD"),
require = 1)
private void crashSetBiomeArray(byte[] p_76616_1_, CallbackInfo ci) {
emergencyCrash();
eid$emergencyCrash();
}
@Inject(method = "getBiomeArray",
at = @At(value = "HEAD"),
require = 1)
private void crashGetBiomeArray(CallbackInfoReturnable<byte[]> cir) {
emergencyCrash();
eid$emergencyCrash();
}
/**
@@ -73,7 +76,7 @@ public abstract class ChunkMixin implements ChunkBiomeHook {
*/
@Overwrite
public BiomeGenBase getBiomeGenForWorldCoords(int x, int z, WorldChunkManager manager) {
int id = this.blockBiomeShortArray[z << 4 | x] & ExtendedConstants.biomeIDMask;
int id = this.eid$blockBiomeShortArray[z << 4 | x] & ExtendedConstants.biomeIDMask;
if (id == ExtendedConstants.biomeIDNull) {
//Source: https://github.com/embeddedt/ArchaicFix/blob/3d1392f4db5a7221534a6f9b00c0c36a49d9be59/src/main/java/org/embeddedt/archaicfix/mixins/common/core/MixinChunk.java#L52
if (this.worldObj.isRemote) {
@@ -81,7 +84,7 @@ public abstract class ChunkMixin implements ChunkBiomeHook {
}
BiomeGenBase gen = manager.getBiomeGenAt((this.xPosition << 4) + x, (this.zPosition << 4) + z);
id = gen.biomeID;
this.blockBiomeShortArray[z << 4 | x] = (short) (id & ExtendedConstants.biomeIDMask);
this.eid$blockBiomeShortArray[z << 4 | x] = (short) (id & ExtendedConstants.biomeIDMask);
}
return BiomeGenBase.getBiome(id) == null ? BiomeGenBase.plains : BiomeGenBase.getBiome(id);
@@ -89,11 +92,11 @@ public abstract class ChunkMixin implements ChunkBiomeHook {
@Override
public short[] getBiomeShortArray() {
return blockBiomeShortArray;
return eid$blockBiomeShortArray;
}
@Override
public void setBiomeShortArray(short[] data) {
blockBiomeShortArray = data;
eid$blockBiomeShortArray = data;
}
}
@@ -0,0 +1,20 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.matteroverdrive;
import com.falsepattern.endlessids.util.DataUtil;
import matteroverdrive.data.Inventory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.nbt.NBTTagCompound;
@Mixin(Inventory.class)
public abstract class InventoryMixin {
@Redirect(method = "readFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z"),
require = 1)
private boolean fixHasKey(NBTTagCompound instance, String p_150297_1_, int p_150297_2_) {
return DataUtil.nbtHasID(instance);
}
}
@@ -0,0 +1,70 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.matteroverdrive;
import com.falsepattern.endlessids.constants.VanillaConstants;
import io.netty.buffer.ByteBuf;
import matteroverdrive.data.ItemPattern;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.Constants;
@Mixin(value = ItemPattern.class,
remap = false)
public abstract class ItemPatternMixin {
@Shadow private int itemID;
@Shadow private int progress;
@Shadow private int damage;
@Shadow private int count;
@Inject(method = "writeToNBT",
at = @At("RETURN"),
require = 1)
private void writeToNBT$writeInt(NBTTagCompound nbtTagCompound, CallbackInfo ci) {
int id = this.itemID;
if (id > VanillaConstants.maxItemID) {
nbtTagCompound.setShort("id", (short) 0);
}
nbtTagCompound.setInteger("idExt", id);
}
@Inject(method = "readFromNBT",
at = @At("RETURN"),
require = 1)
private void readFromNBT$readInt(NBTTagCompound nbtTagCompound, CallbackInfo ci) {
if (nbtTagCompound.hasKey("idExt", Constants.NBT.TAG_INT))
this.itemID = nbtTagCompound.getInteger("idExt");
}
/**
* @author FalsePattern
* @reason Extend IDs
*/
@Overwrite
public void writeToBuffer(ByteBuf byteBuf) {
byteBuf.writeInt(this.itemID);
byteBuf.writeByte(this.progress);
byteBuf.writeShort(this.damage);
byteBuf.writeByte(this.count);
}
/**
* @author FalsePattern
* @reason Extend IDs
*/
@Overwrite
public void readFromBuffer(ByteBuf byteBuf) {
this.itemID = byteBuf.readInt();
this.progress = byteBuf.readByte();
this.damage = byteBuf.readShort();
this.count = byteBuf.readByte();
}
}
@@ -1,5 +1,7 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.constants.VanillaConstants;
import com.falsepattern.endlessids.util.DataUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@@ -29,7 +31,7 @@ public abstract class ItemStackMixin {
*/
@Overwrite
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
nbt.setInteger("id", Item.getIdFromItem(this.field_151002_e));
DataUtil.writeIDToNBT(nbt, Item.getIdFromItem(this.field_151002_e));
nbt.setByte("Count", (byte) this.stackSize);
nbt.setShort("Damage", (short) this.itemDamage);
@@ -46,7 +48,7 @@ public abstract class ItemStackMixin {
*/
@Overwrite
public void readFromNBT(NBTTagCompound nbt) {
func_150996_a(Item.getItemById(nbt.getInteger("id")));
func_150996_a(Item.getItemById(DataUtil.readIDFromNBT(nbt)));
this.stackSize = nbt.getByte("Count");
this.itemDamage = nbt.getShort("Damage");
@@ -25,11 +25,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Mixin(DataWatcher.class)
@Mixin(value = DataWatcher.class,
priority = 1001)
public abstract class DataWatcherMixin {
@Shadow @Final private Map watchedObjects;
@ModifyConstant(method = {"addObject", "func_151509_a"},
constant = @Constant(intValue = VanillaConstants.maxWatchableID),
require = 2)
@@ -71,16 +69,21 @@ public abstract class DataWatcherMixin {
watchable = new DataWatcher.WatchableObject(type, id, packet.readFloat());
break;
case 4:
watchable = new DataWatcher.WatchableObject(type, id, packet.readStringFromBuffer(32767));
boolean present = packet.readBoolean();
watchable = new DataWatcher.WatchableObject(type, id, present ? packet.readStringFromBuffer(32767) : null);
break;
case 5:
watchable = new DataWatcher.WatchableObject(type, id, packet.readItemStackFromBuffer());
break;
case 6:
int x = packet.readInt();
int y = packet.readInt();
int z = packet.readInt();
watchable = new DataWatcher.WatchableObject(type, id, new ChunkCoordinates(x, y, z));
ChunkCoordinates coords = null;
if (packet.readBoolean()) {
int x = packet.readInt();
int y = packet.readInt();
int z = packet.readInt();
coords = new ChunkCoordinates(x, y, z);
}
watchable = new DataWatcher.WatchableObject(type, id, coords);
}
watchables.add(watchable);
@@ -126,7 +129,13 @@ public abstract class DataWatcherMixin {
buf.writeFloat((float) watcher.getObject());
break;
case 4:
buf.writeStringToBuffer((String) watcher.getObject());
val obj = (String) watcher.getObject();
if (obj == null) {
buf.writeBoolean(false);
} else {
buf.writeBoolean(true);
buf.writeStringToBuffer(obj);
}
break;
case 5:
ItemStack itemstack = (ItemStack) watcher.getObject();
@@ -134,9 +143,14 @@ public abstract class DataWatcherMixin {
break;
case 6:
ChunkCoordinates chunkcoordinates = (ChunkCoordinates) watcher.getObject();
buf.writeInt(chunkcoordinates.posX);
buf.writeInt(chunkcoordinates.posY);
buf.writeInt(chunkcoordinates.posZ);
if (chunkcoordinates == null) {
buf.writeBoolean(false);
} else {
buf.writeBoolean(true);
buf.writeInt(chunkcoordinates.posX);
buf.writeInt(chunkcoordinates.posY);
buf.writeInt(chunkcoordinates.posZ);
}
}
}
}
@@ -137,6 +137,9 @@ public enum Mixin implements IMixin {
//region NomadicTents
NomadicTentsTentChunkProviderMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.NOMADICTENTS)), "biome.nomadictents.TentChunkProviderMixin"),
//endregion NomadicTents
//region OWG
OWGChunkGeneratorBetaMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.OWG)), "biome.owg.ChunkGeneratorBetaMixin"),
//endregion OWG
//region RandomThings
ItemBiomePainterMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RANDOMTHINGS)), "biome.randomthings.ItemBiomePainterMixin"),
MessagePaintBiomeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RANDOMTHINGS)), "biome.randomthings.MessagePaintBiomeMixin"),
@@ -156,6 +159,9 @@ public enum Mixin implements IMixin {
//region Thaumcraft
ThaumcraftUtilsMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.THAUMCRAFT)), "biome.thaumcraft.UtilsMixin"),
//endregion Thaumcraft
//region ThutCore
ThutVector3Mixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.THUTCORE)), "biome.thut.Vector3Mixin"),
//endregion ThutCore
//region Tropicraft
GenLayerTropiVoronoiZoomMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.TROPICRAFT)), "biome.tropicraft.GenLayerTropiVoronoiZoomMixin"),
//endregion Tropicraft
@@ -186,6 +192,10 @@ public enum Mixin implements IMixin {
DragonAPIBlockPropertiesMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.DRAGONAPI)), "blockitem.dragonapi.BlockPropertiesMixin"),
DragonAPIBlockItemIDTypeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.DRAGONAPI)), "blockitem.dragonapi.IDTypeMixin"),
//endregion DragonAPI
//region Matter Overdrive
MOInventoryMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MATTEROVERDRIVE)), "blockitem.matteroverdrive.InventoryMixin"),
MOItemPatternMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MATTEROVERDRIVE)), "blockitem.matteroverdrive.ItemPatternMixin"),
//endregion Matter Overdrive
//region MFQM
MFQMMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MFQM)), "blockitem.mfqm.MFQMMixin"),
//endregion MFQM
@@ -37,15 +37,18 @@ public enum TargetedMod implements ITargetedMod {
ICG("Immersive Cavegen", false, startsWith("immersivecavegen")),
IR3("Industrial Revolution by Redstone Rebooted", false, startsWith("industrialrevolutionbyredstonerebooted-")),
LOTR("LOTR Mod", false, startsWith("lotrmod")),
MATTEROVERDRIVE("Matter Overdrive", false, startsWith("matteroverdrive-")),
MFQM("More Fun Quicksand Mod", false, startsWith("morefunquicksandmod-")),
NATURESCOMPASS("Nature's Compass", false, startsWith("naturescompass")),
NETHERLICIOUS("Netherlicious", false, startsWith("netherlicious-")),
NOMADICTENTS("Nomadic Tents", false, startsWith("nomadictents")),
OWG("Nostalgic world generation", false, startsWith("owg-").or(startsWith("nostalgiagenerator-"))),
RANDOMTHINGS("Random Things", false, startsWith("randomthings-")),
RESTRUCTURED("Restructured", false, startsWith("restructured-")),
RTG("Realistic Terrain Generation", false, startsWith("rtg-")),
RWG("Realistic World Gen", false, startsWith("rwg-")),
THAUMCRAFT("Thaumcraft", false, startsWith("thaumcraft")),
THUTCORE("ThutCore", false, startsWith("thutcore-").or(startsWith("thutmods-"))),
TROPICRAFT("Tropicraft", false, startsWith("tropicraft-")),
TWILIGHTFOREST("Twilight Forest", false, startsWith("twilightforest")),
UBC("Underground Biomes Constructs", false, startsWith("undergroundbiomesconstructs-")),
@@ -1,10 +1,17 @@
package com.falsepattern.endlessids.util;
import com.falsepattern.endlessids.constants.VanillaConstants;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraftforge.common.util.Constants;
import java.util.Arrays;
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
import static net.minecraftforge.common.util.Constants.NBT.TAG_INT;
import static net.minecraftforge.common.util.Constants.NBT.TAG_SHORT;
public class DataUtil {
public static byte[] ensureSubChunkByteArray(byte[] arr) {
@@ -14,4 +21,28 @@ public class DataUtil {
public static NibbleArray ensureSubChunkNibbleArray(byte[] data) {
return data == null ? null : new NibbleArray(data.length == (blocksPerSubChunk >>> 1) ? data : Arrays.copyOf(data, (blocksPerSubChunk >>> 1)), 4);
}
public static int readIDFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey("idExt", TAG_INT))
return nbt.getInteger("idExt");
else if (nbt.hasKey("id", TAG_INT))
return nbt.getInteger("id");
else if (nbt.hasKey("id", TAG_SHORT))
return nbt.getShort("id");
else
return 0;
}
public static void writeIDToNBT(NBTTagCompound nbt, int id) {
if (id > VanillaConstants.maxItemID) {
nbt.setShort("id", (short)0);
nbt.setInteger("idExt", id);
} else {
nbt.setShort("id", (short) id);
}
}
public static boolean nbtHasID(NBTTagCompound nbt) {
return nbt.hasKey("id", TAG_INT) || nbt.hasKey("idExt", TAG_INT) || nbt.hasKey("id", TAG_SHORT);
}
}