Compare commits

...
Author SHA1 Message Date
FalsePattern c1d8e273fc extended entity IDs 2023-09-05 09:59:57 +02:00
FalsePattern 484a9175e7 another dependency update 2023-08-12 15:04:05 +02:00
FalsePattern 1bb71d9448 nicer config printing 2023-08-12 15:04:05 +02:00
FalsePattern 11ff4a4a6a configurable performance tweak 2023-08-12 15:04:05 +02:00
FalsePattern 6b3d872fbd some tweaks 2023-08-12 15:04:04 +02:00
FalsePattern 344b788108 Fixed the registry lag 2023-08-12 15:04:04 +02:00
FalsePattern b61711280b update deps 2023-08-12 15:04:04 +02:00
FalsePattern 67badb8fcb fix dragonapi mixin 2023-07-11 18:08:40 +02:00
FalsePattern e529ad49cb Remove DragonAPI ModList compat hack. Will be fixed upstream. 2023-07-11 18:02:38 +02:00
FalsePattern 10c19feb0c [ci skip] Put dependencies at the top 2023-06-09 17:41:34 +02:00
FalsePattern fb0096350c bump fplib (fixes dev) 2023-05-08 19:17:37 +02:00
FalsePattern 1f726e42d3 update buildscript 2023-05-08 10:43:32 +02:00
FalsePattern 1944aa08f1 damn it 2023-05-08 10:39:37 +02:00
FalsePattern 0dfe4bfc2d update buildscript 2023-05-07 22:54:56 +02:00
FalsePattern fcac948f88 NEID dfu 2023-05-07 22:36:13 +02:00
FalsePattern 04fe960ca4 bump fplib 2023-05-07 22:36:01 +02:00
FalsePattern a1d13d833d cleanup constants but keep some of the informative stuff 2023-04-06 11:44:41 +02:00
FalsePattern 8ae84392ba Fix StatList regression (#114) 2023-04-06 11:42:36 +02:00
FalsePattern 76092e5c4c update buildscript 2023-04-02 14:21:31 +02:00
FalsePattern 0ecadb8563 bump deps 2023-04-02 14:20:38 +02:00
FalsePattern 147099d625 remap fixes 2023-04-02 14:01:31 +02:00
FalsePattern e699d67f4e IR3 compat (#104) 2023-04-02 13:48:06 +02:00
FalsePattern 6101766529 oops, forgot this 2023-04-02 13:22:58 +02:00
FalsePattern 8c715bd579 Restructured compat (#105) 2023-04-02 13:08:27 +02:00
FalsePattern e7340cd9b1 remove LOTR from readme until fixed 2023-04-02 12:54:24 +02:00
FalsePattern 786652504c DimDoors compat (#111) 2023-04-02 12:54:22 +02:00
FalsePattern 4ded45cc5c fix some mixin conflicts (#112) 2023-04-02 12:18:55 +02:00
FalsePattern 16be8d607c [ci skip] update publishing 2023-04-01 11:52:19 +02:00
FalsePattern 775ea5769c bleh 2023-03-31 18:23:56 +02:00
FalsePattern 93e375a07d update readme 2023-03-31 18:23:41 +02:00
FalsePattern a2c0ac2d99 whoops 2023-03-31 18:23:20 +02:00
FalsePattern de5fa2d322 migrate some spaghetti code to ChunkAPI
replaced netcode/saving logic for blocks, metadata, and biomes
2023-03-30 22:50:11 +02:00
FalsePattern 984c976b34 max item id crash fix 2023-03-03 09:38:41 +01:00
45 changed files with 1163 additions and 1242 deletions

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ EndlessIDs
Copyright (C) 2022 FalsePattern
All Rights Reserved
The above copyright notice, this permission notice and the word "SNEED"
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
+19 -16
View File
@@ -1,18 +1,23 @@
EndlessIDs is the unofficial successor of NotEnoughIDs, with more focus on compatibility, stability, and reaching
new limits.
## REQUIRED MODS
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
- [GasStation](https://github.com/FalsePattern/GasStation)
- [ChunkAPI](https://github.com/FalsePattern/ChunkAPI)
Comparison of the known limits:
| | Vanilla | NotEnoughIDs | EndlessIDs |
|-----------------|----------------------------------------------------|--------------|----------------------------------|
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
| Block Metadata | 16 | 16 | 65,536 since 1.5 |
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
| Entity IDs | 256 | 256 | 256 right now, extension planned |
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
| | Vanilla | NotEnoughIDs | EndlessIDs |
|-----------------|----------------------------------------------------|--------------|----------------------|
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
| Block Metadata | 16 | 16 | 65,536 since 1.5 |
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
| Entity IDs | 256 | 256 | 32,768 since 1.5 |
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
This mod also contains patches for the following mods:
@@ -30,6 +35,7 @@ This mod also contains patches for the following mods:
- Compact Machines
- CoFH Lib
- Dark World
- Dimensional Doors
- DragonAPI
- Dynamic Surroundings
- Enderlicious
@@ -41,12 +47,13 @@ This mod also contains patches for the following mods:
- GalactiCraft
- Highlands
- Immersive Cavegen
- LOTR
- Industrial Revolution by Redstone Rebooted
- More Fun Quicksand Mod
- Nature's Compass
- Netherlicious
- Nomadic Tents
- Random Things
- Restructured
- Realistic Terrain Generation
- Realistic World Generation
- Thaumcraft
@@ -65,10 +72,6 @@ Mods not listed here may or may not work.
- If a mod adds a custom world generator, it has a high chance of invoking an old vanilla method in the worldgen code.
To avoid world corruption and broken biomes, this method has been replaced with an instant crash that refers the
user to this github repo.
user to this GitHub repo.
If you find any crashes or incompatibilities, don't hesitate to open an issue.
## Dependencies
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
- [GasStation](https://github.com/FalsePattern/GasStation)
+5 -3
View File
@@ -1,4 +1,4 @@
//version: 1656003793falsepattern63
//version: 1656003793falsepattern67
/*
DO NOT CHANGE THIS FILE!
@@ -670,6 +670,8 @@ def getCredentials = {
}
//Publishing
tasks.publish.dependsOn(build)
publishing {
publications {
maven(MavenPublication) {
@@ -753,7 +755,7 @@ if (curseForgeProjectId != "" && System.getenv("CURSEFORGE_TOKEN") != null) {
addGameVersion project.minecraft.version
addGameVersion "Forge"
mainArtifact(jar) {
displayName = "$modName version: $modVersion"
displayName = "$modName $modVersion"
}
}
options {
@@ -1067,7 +1069,7 @@ def deobf(String sourceURL, String rawFileName) {
}
download.run {
src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar"
src "https://github.com/FalsePattern/ExampleMod1.7.10/raw/main/blobs/BON2-2.5.1.jar"
dest bon2File
quiet true
overwrite false
+16 -5
View File
@@ -16,12 +16,14 @@ def deobfCurse(curseDep) {
dependencies {
////////////////Our dependencies////////////////
compileOnly("org.projectlombok:lombok:1.18.24") {
compileOnly("org.projectlombok:lombok:1.18.28") {
transitive = false
}
annotationProcessor("org.projectlombok:lombok:1.18.24")
annotationProcessor("org.projectlombok:lombok:1.18.28")
compile("com.falsepattern:falsepatternlib-mc1.7.10:0.10.15:dev")
implementation("com.falsepattern:falsepatternlib-mc1.7.10:0.12.1:dev")
implementation("com.falsepattern:chunkapi-mc1.7.10:0.3.2:dev")
////////////////Patched mods////////////////
@@ -68,8 +70,11 @@ dependencies {
//Dark World 0.2
compileOnly(deobfCurse("darkworld-225075:2225172"))
//DragonAPI V31b
compileOnly(deobfCurse("dragonapi-235591:3574508"))
//DimDoors 2.2.5-test9
compileOnly(deobf("https://github.com/CannibalVox/DimDoors/releases/download/2.2.5-test9/DimensionalDoors-2.2.5-test9.jar"))
//DragonAPI V32a
compileOnly(deobfCurse("dragonapi-235591:4611379"))
//Dynamic Surroundings 1.0.6.4
compileOnly(deobfCurse("dynamicsurrounding-238891:2642381"))
@@ -105,6 +110,9 @@ dependencies {
//Immersive Cavegen 1.2g
compileOnly(deobfCurse("immersivecavegen-521557:3649411"))
//Industrial Revolution by Redstone Rebooted 1.1.1
compileOnly(deobfCurse("industrialrevolutionbyredstonerebooted-241812:2538035"))
//LOTR Mod 36.14
compileOnly(deobfCurse("lotrmod-423748:3646430"))
@@ -126,6 +134,9 @@ dependencies {
//Realistic Terrain Generation 1.1.1.7
compileOnly(deobfCurse("rtg-237989:2521557"))
//Restructured 1.0.4.2
compileOnly(deobfCurse("restructured-230570:2276784"))
//Thaumcraft 4.2.3.5
compileOnly(deobfCurse("thaumcraft-223628:2227552"))
+2 -2
View File
@@ -72,7 +72,7 @@ modrinthProjectId = qGHY4QGo
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:spongemixin1710;incompatible-project:gregtech
modrinthDependencies = required-project:fplib
modrinthDependencies = required-project:fplib;required-project:chunkapi
#endregion modrinth
@@ -90,7 +90,7 @@ curseForgeProjectId = 665730
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project id of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
curseForgeRelations = requiredDependency:fplib
curseForgeRelations = requiredDependency:fplib;requiredDependency:chunkapi
#endregion curseforge
@@ -1,5 +1,10 @@
package com.falsepattern.endlessids;
import com.falsepattern.chunk.api.ChunkDataRegistry;
import com.falsepattern.endlessids.config.GeneralConfig;
import com.falsepattern.endlessids.managers.BiomeManager;
import com.falsepattern.endlessids.managers.BlockIDManager;
import com.falsepattern.endlessids.managers.BlockMetaManager;
import com.falsepattern.endlessids.patching.CommonManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -15,7 +20,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
version = Tags.VERSION,
name = Tags.MODNAME,
acceptedMinecraftVersions = "[1.7.10]",
dependencies = "required-after:falsepatternlib@[0.10.13,);required-after:gasstation@[0.5.0,);after:antiidconflict")
dependencies = "required-after:chunkapi@[0.3.2,);required-after:falsepatternlib@[0.12.1,);required-after:gasstation@[0.5.0,);after:antiidconflict")
public class EndlessIDs {
public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
public static final byte[] FAKE_BIOME_ARRAY_PLACEHOLDER = new byte[256];
@@ -33,16 +38,59 @@ public class EndlessIDs {
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
LOG.info("---------------------------------------------------------");
LOG.info("Current EndlessIDs configuration:");
logConfig(" Biome Extension", GeneralConfig.extendBiome);
logConfig(" Block/Item Extension", GeneralConfig.extendBlockItem);
if (GeneralConfig.extendBlockItem) {
logConfig(" Extra Item Bits", GeneralConfig.extraItemIDBits);
logConfig(" Extra Block Bits", GeneralConfig.extraBlockIDBits);
}
logConfig(" DataWatcher Extension", GeneralConfig.extendDataWatcher);
logConfig(" Enchantment Extension", GeneralConfig.extendEnchantment);
logConfig(" Potion Extension", GeneralConfig.extendPotion);
logConfig(" Redstone Extension", GeneralConfig.extendRedstone);
if (GeneralConfig.extendRedstone) {
LOG.warn(" (Redstone extension is an experimental and dangerous feature, and should NEVER be used in worlds that you worry about getting corrupted!)");
logConfig(" Max redstone level", GeneralConfig.maxRedstone);
}
logConfig(" Registry performance tweak", GeneralConfig.enableRegistryPerformanceTweak);
if (GeneralConfig.enableRegistryPerformanceTweak) {
LOG.warn(" (This tweak has not gone through proper testing yet, so it might corrupt worlds. USE BACKUPS!)");
}
LOG.info("---------------------------------------------------------");
patchManager.preInit();
}
private static void logConfig(String name, boolean value) {
LOG.info(name + (value ? ": ENABLED" : ": disabled"));
}
private static void logConfig(String name, int value) {
LOG.info(name + ": " + value);
}
@Mod.EventHandler
public void init(FMLInitializationEvent e) {
patchManager.init();
if (GeneralConfig.extendBiome) {
ChunkDataRegistry.registerDataManager(new BiomeManager());
}
if (GeneralConfig.extendBlockItem) {
ChunkDataRegistry.registerDataManager(new BlockIDManager());
ChunkDataRegistry.registerDataManager(new BlockMetaManager());
}
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) {
patchManager.postInit();
if (GeneralConfig.extendBiome) {
ChunkDataRegistry.disableDataManager("minecraft", "biome");
}
if (GeneralConfig.extendBlockItem) {
ChunkDataRegistry.disableDataManager("minecraft", "blockid");
ChunkDataRegistry.disableDataManager("minecraft", "metadata");
}
}
}
@@ -2,184 +2,10 @@ package com.falsepattern.endlessids;
import com.falsepattern.endlessids.config.GeneralConfig;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import lombok.val;
import lombok.var;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
public class Hooks {
public static int getBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset) {
val b1 = ebs.getB1();
System.arraycopy(b1, 0, data, offset, b1.length);
offset += b1.length;
val b2Low = ebs.getB2Low();
if (b2Low != null) {
System.arraycopy(b2Low.data, 0, data, offset, b2Low.data.length);
offset += b2Low.data.length;
val b2High = ebs.getB2High();
if (b2High != null) {
System.arraycopy(b2High.data, 0, data, offset, b2High.data.length);
offset += b2High.data.length;
val b3 = ebs.getB3();
if (b3 != null) {
System.arraycopy(b3, 0, data, offset, b3.length);
}
}
}
return ebs.getEBSMSBMask();
}
public static void setBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset, final int storageFlag) {
val b1 = ebs.getB1();
System.arraycopy(data, offset, b1, 0, b1.length);
offset += b1.length;
if (storageFlag == 0b00) {
ebs.clearB2Low();
ebs.clearB2High();
ebs.clearB3();
return;
}
var b2Low = ebs.getB2Low();
if (b2Low == null) {
b2Low = ebs.createB2Low();
}
System.arraycopy(data, offset, b2Low.data, 0, b2Low.data.length);
offset += b2Low.data.length;
if (storageFlag == 0b01) {
ebs.clearB2High();
ebs.clearB3();
return;
}
var b2High = ebs.getB2High();
if (b2High == null) {
b2High = ebs.createB2High();
}
System.arraycopy(data, offset, b2High.data, 0, b2High.data.length);
offset += b2High.data.length;
if (storageFlag == 0b10) {
ebs.clearB3();
return;
}
var b3 = ebs.getB3();
if (b3 == null) {
b3 = ebs.createB3();
}
System.arraycopy(data, offset, b3, 0, b3.length);
}
public static void writeBlockDataToNBT(final NBTTagCompound nbt, final IExtendedBlockStorageMixin ebs) {
val b1 = ebs.getB1();
val b2Low = ebs.getB2Low();
val b2High = ebs.getB2High();
val b3 = ebs.getB3();
nbt.setByteArray("Blocks", b1);
if (b2Low != null) {
nbt.setByteArray("Add", b2Low.data);
}
if (b2High != null) {
nbt.setByteArray("BlocksB2Hi", b2High.data);
}
if (b3 != null) {
nbt.setByteArray("BlocksB3", b3);
}
}
public static void readBlockDataFromNBT(final IExtendedBlockStorageMixin ebs, final NBTTagCompound nbt) {
assert nbt.hasKey("Blocks");
val b1 = nbt.getByteArray("Blocks");
final byte[] b2Low = nbt.hasKey("Add") ? nbt.getByteArray("Add") : null;
final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
ebs.setB1(b1);
if (b2Low == null) {
ebs.clearB2Low();
} else {
ebs.setB2Low(new NibbleArray(b2Low, 4));
}
if (b2High == null) {
ebs.clearB2High();
} else {
ebs.setB2High(new NibbleArray(b2High, 4));
}
ebs.setB3(b3);
}
public static int getBlockMeta(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset) {
val m1Low = ebs.getM1Low();
System.arraycopy(m1Low.data, 0, data, offset, m1Low.data.length);
offset += m1Low.data.length;
val m1High = ebs.getM1High();
if (m1High != null) {
System.arraycopy(m1High.data, 0, data, offset, m1High.data.length);
offset += m1High.data.length;
val m2 = ebs.getM2();
if (m2 != null) {
System.arraycopy(m2, 0, data, offset, m2.length);
}
}
return ebs.getEBSMask();
}
public static void setBlockMeta(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset, final int storageFlag) {
val m1Low = ebs.getM1Low();
System.arraycopy(data, offset, m1Low.data, 0, m1Low.data.length);
offset += m1Low.data.length;
if (storageFlag == 0b01) {
ebs.clearM1High();
ebs.clearM2();
return;
}
var m1High = ebs.getM1High();
if (m1High == null) {
m1High = ebs.createM1High();
}
System.arraycopy(data, offset, m1High.data, 0, m1High.data.length);
if (storageFlag == 0b10) {
ebs.clearM2();
return;
}
var m2 = ebs.getM2();
if (m2 == null) {
m2 = ebs.createM2();
}
System.arraycopy(data, offset, m2, 0, m2.length);
}
public static void writeBlockMetaToNBT(IExtendedBlockStorageMixin ebs, NBTTagCompound nbt) {
val m1Low = ebs.getM1Low();
val m1High = ebs.getM1High();
val m2 = ebs.getM2();
nbt.setByteArray("Data", m1Low.data);
if (m1High != null) {
nbt.setByteArray("Data1High", m1High.data);
}
if (m2 != null) {
nbt.setByteArray("Data2", m2);
}
}
public static void readBlockMetaFromNBT(IExtendedBlockStorageMixin ebs, NBTTagCompound nbt) {
assert nbt.hasKey("Data");
val m1Low = nbt.getByteArray("Data");
final byte[] m1High = nbt.hasKey("Data1High") ? nbt.getByteArray("Data1High") : null;
final byte[] m2 = nbt.hasKey("Data2") ? nbt.getByteArray("Data2") : null;
ebs.setM1Low(new NibbleArray(m1Low, 4));
if (m1High == null) {
ebs.clearM1High();
} else {
ebs.setM1High(new NibbleArray(m1High, 4));
}
ebs.setM2(m2);
}
public static int getIdFromBlockWithCheck(final Block block, final Block oldBlock) {
final int id = Block.getIdFromBlock(block);
if (GeneralConfig.catchUnregisteredBlocks && id == -1) {
@@ -230,47 +56,9 @@ public class Hooks {
}
}
private static void scatter(byte[] byteArray, short[] shortArray) {
public static void scatter(byte[] byteArray, short[] shortArray) {
for (int i = 0; i < byteArray.length; i++) {
shortArray[i] = (short) (byteArray[i] & 0xff);
}
}
public static int readBiomeArrayFromPacket(Chunk chunk, byte[] array, int offset) {
short[] biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
byteToShortArray(array, offset, biomeArray, 0, biomeArray.length * 2);
return biomeArray.length * 2;
}
public static int writeBiomeArrayToPacket(Chunk chunk, byte[] array, int offset) {
short[] biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
shortToByteArray(biomeArray, 0, array, offset, biomeArray.length);
return biomeArray.length * 2;
}
public static void writeChunkBiomeArrayToNbt(Chunk chunk, NBTTagCompound nbt) {
byte[] byteArray = shortToByteArray(((IChunkMixin) chunk).getBiomeShortArray());
nbt.setByteArray("Biomes16v2", byteArray);
}
public static void readChunkBiomeArrayFromNbt(Chunk chunk, NBTTagCompound nbt) {
short[] data = ((IChunkMixin) chunk).getBiomeShortArray();
boolean put = false;
if (data == null) {
data = new short[16 * 16];
put = true;
}
if (nbt.hasKey("Biomes16v2", 7)) {
byteToShortArray(nbt.getByteArray("Biomes16v2"), 0, data, 0, data.length * 2);
} else if (nbt.hasKey("Biomes16", 7)) { //NotEnoughBiomes DFU
byteToShortArrayLegacy(nbt.getByteArray("Biomes16"), data);
} else if (nbt.hasKey("Biomes", 7)) { //Vanilla DFU
scatter(nbt.getByteArray("Biomes"), data);
} else {
put = false;
}
if (put) {
((IChunkMixin) chunk).setBiomeShortArray(data);
}
}
}
@@ -1,48 +0,0 @@
package com.falsepattern.endlessids.asm;
import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
import com.falsepattern.endlessids.asm.stubpackage.Reika.DragonAPI.ModList;
import lombok.SneakyThrows;
import cpw.mods.fml.common.Loader;
public class ASMHooks {
@SneakyThrows
public static void DragonAPIModListConstructorTweak(ModList list) {
list.successful = false;
DragonAPIModListTryLoad(list);
}
public static boolean DragonAPIModListTryLoad(ModList list) {
if (!list.successful) {
try {
list.condition = Loader.isModLoaded(list.modLabel);
list.successful = true;
if (list.condition) {
ReikaJavaLibrary.pConsole(
"DRAGONAPI: " + list + " detected in the MC installation. Adjusting behavior accordingly.");
} else {
ReikaJavaLibrary.pConsole(
"DRAGONAPI: " + list + " not detected in the MC installation. No special action taken.");
}
if (list.condition) {
ReikaJavaLibrary.pConsole("DRAGONAPI: Attempting to load data from " + list);
if (list.blockClasses == null) {
ReikaJavaLibrary.pConsole("DRAGONAPI: Could not block class for " + list +
": Specified class was null. This may not be an error.");
}
if (list.itemClasses == null) {
ReikaJavaLibrary.pConsole("DRAGONAPI: Could not item class for " + list +
": Specified class was null. This may not be an error.");
}
}
} catch (NullPointerException e) {
list.condition = list.successful = false;
}
}
return list.condition;
}
public static void DragonAPIModListSuppressLogging(Object obj) {
}
}
@@ -1,33 +1,38 @@
package com.falsepattern.endlessids.asm;
import com.falsepattern.endlessids.asm.transformer.ChunkProviderSuperPatcher;
import com.falsepattern.endlessids.asm.transformer.DragonAPIModList;
import com.falsepattern.endlessids.asm.transformer.FmlRegistry;
import com.falsepattern.endlessids.asm.transformer.GameDataAccelerator;
import com.falsepattern.endlessids.asm.transformer.SpaceCoreModInfoGenerator;
import com.falsepattern.endlessids.config.GeneralConfig;
import lombok.val;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BooleanSupplier;
import java.util.stream.Collectors;
public enum ClassEdit {
ChunkProviderSuperPatcher(new ChunkProviderSuperPatcher(), () -> GeneralConfig.extendBiome),
DragonAPIModList(new DragonAPIModList(), () -> true, "Reika.DragonAPI.ModList"),
FmlRegistry(new FmlRegistry(),
() -> GeneralConfig.extendBlockItem,
"cpw.mods.fml.common.registry.GameData",
"cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry"),
SpaceCoreModInfoGenerator(new SpaceCoreModInfoGenerator(), () -> true,
"com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator");
"com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator"),
GameDataAccelerator(new GameDataAccelerator(), () -> GeneralConfig.enableRegistryPerformanceTweak, "cpw.mods.fml.common.registry.GameData"),
;
private static final Map<String, ClassEdit> editMap;
private static final Map<String, List<ClassEdit>> editMap;
static {
editMap = new HashMap<>();
for (final ClassEdit edit : values()) {
for (final String name : edit.classNames) {
ClassEdit.editMap.put(name, edit);
ClassEdit.editMap.computeIfAbsent(name, (ignored) -> new ArrayList<>()).add(edit);
}
}
}
@@ -42,9 +47,14 @@ public enum ClassEdit {
this.classNames = classNames;
}
public static ClassEdit get(final String className) {
val ret = ClassEdit.editMap.get(className);
return ret != null && ret.cond.getAsBoolean() ? ret : null;
public static List<ClassEdit> get(final String className) {
val edit = ClassEdit.editMap.get(className);
if (edit == null) {
return Collections.emptyList();
}
return edit.stream()
.filter(r -> r.cond.getAsBoolean())
.collect(Collectors.toList());
}
public String getName() {
@@ -0,0 +1,38 @@
package com.falsepattern.endlessids.asm;
import com.falsepattern.endlessids.asm.stubpackage.cpw.mods.fml.common.registry.GameData;
import com.falsepattern.endlessids.util.WeakIdentityHashMap;
import lombok.var;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.WeakHashMap;
public class GameDataHooks {
private static WeakIdentityHashMap<Block, WeakReference<ItemBlock>> forGameData(GameData gameData) {
if (gameData.endlessIDsItemBlockCache == null) {
gameData.endlessIDsItemBlockCache = new WeakIdentityHashMap<>();
}
return gameData.endlessIDsItemBlockCache;
}
public static void cacheItemBlock(ItemBlock itemBlock, GameData gameData) {
forGameData(gameData).put(itemBlock.field_150939_a, new WeakReference<>(itemBlock));
}
public static ItemBlock fetchCachedItemBlock(Block block, GameData gameData) {
var weakItem = forGameData(gameData).get(block);
if (weakItem != null) {
return weakItem.get();
}
return null;
}
public static Iterable<Item> fakeIterable() {
return Collections.emptyList();
}
}
@@ -4,6 +4,7 @@ import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.asm.transformer.ChunkProviderSuperPatcher;
import com.falsepattern.endlessids.asm.transformer.DevFixer;
import lombok.val;
import lombok.var;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.ClassReader;
@@ -37,8 +38,7 @@ public class IETransformer implements IClassTransformer {
if (blacklist.contains(transformedName)) {
return bytes;
}
ClassEdit[] edits = new ClassEdit[2];
edits[0] = ClassEdit.get(transformedName);
var edits = new ArrayList<ClassEdit>(ClassEdit.get(transformedName));
ClassNode cn = new ClassNode(Opcodes.ASM5);
{
val reader = new ClassReader(bytes);
@@ -52,20 +52,15 @@ public class IETransformer implements IClassTransformer {
val reader = new ClassReader(bytes);
reader.accept(cn, ClassReader.EXPAND_FRAMES);
}
if (edits[0] == null) {
edits[0] = ClassEdit.ChunkProviderSuperPatcher;
} else {
edits[1] = ClassEdit.ChunkProviderSuperPatcher;
}
edits.add(ClassEdit.ChunkProviderSuperPatcher);
}
if (edits[0] == null) {
if (edits.size() == 0) {
return isObfuscated ? bytes : DevFixer.fixDev(bytes);
}
if (!isObfuscated) {
DevFixer.transform(cn);
}
for (int i = 0; i < edits.length; i++) {
val edit = edits[i];
for (final ClassEdit edit : edits) {
if (edit == null) {
continue;
}
@@ -1,9 +0,0 @@
package com.falsepattern.endlessids.asm.stubpackage.Reika.DragonAPI;
public class ModList {
public String modLabel;
public boolean condition;
public boolean successful;
public String[] itemClasses;
public String[] blockClasses;
}
@@ -0,0 +1,12 @@
package com.falsepattern.endlessids.asm.stubpackage.cpw.mods.fml.common.registry;
import com.falsepattern.endlessids.util.WeakIdentityHashMap;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import java.lang.ref.WeakReference;
public class GameData {
public WeakIdentityHashMap<Block, WeakReference<ItemBlock>> endlessIDsItemBlockCache;
}
@@ -1,140 +0,0 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.asm.ASMHooks;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
import lombok.val;
import lombok.var;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.FrameNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.LineNumberNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import java.util.Arrays;
import java.util.List;
public class DragonAPIModList implements IClassNodeTransformer {
private static final List<String> fields = Arrays.asList("condition", "itemClasses", "blockClasses");
private static void tweakIsLoaded(MethodNode method) {
val iterator = method.instructions.iterator();
iterator.next();
iterator.next();
iterator.next();
iterator.next();
iterator.set(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ASMHooks.class),
"DragonAPIModListTryLoad", "(LReika/DragonAPI/ModList;)Z", false));
}
private static void tweakInit(MethodNode method) {
val iterator = method.instructions.iterator();
while (iterator.hasNext()) {
var insn = iterator.next();
if (insn instanceof LineNumberNode && ((LineNumberNode) insn).line == 154) {
//SRC:
// L3
// LINENUMBER 154 L3
// ALOAD 0
// ALOAD 0
// GETFIELD Reika/DragonAPI/ModList.modLabel : Ljava/lang/String;
// INVOKESTATIC cpw/mods/fml/common/Loader.isModLoaded (Ljava/lang/String;)Z
// PUTFIELD Reika/DragonAPI/ModList.condition : Z
//TGT:
// L3
// LINENUMBER 154 L3
// ALOAD 0
// ALOAD 5
// PUTFIELD Reika/DragonAPI/ModList.itemClasses : [Ljava/lang/String;
// ALOAD 0
// ALOAD 4
// PUTFIELD Reika/DragonAPI/ModList.blockClasses : [Ljava/lang/String;
// ALOAD 0
// INVOKESTATIC ASMHooks.isModLoaded (LReika/DragonAPI/ModList;)V
// FRAME FULL [Reika/DragonAPI/ModList java/lang/String I java/lang/String [Ljava/lang/String; [Ljava/lang/String;] []
// RETURN
iterator.add(new VarInsnNode(Opcodes.ALOAD, 0));
iterator.add(new VarInsnNode(Opcodes.ALOAD, 5));
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD, "Reika/DragonAPI/ModList", "itemClasses",
"[Ljava/lang/String;"));
iterator.add(new VarInsnNode(Opcodes.ALOAD, 0));
iterator.add(new VarInsnNode(Opcodes.ALOAD, 4));
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD, "Reika/DragonAPI/ModList", "blockClasses",
"[Ljava/lang/String;"));
iterator.next();
iterator.remove();
iterator.next();
iterator.next();
iterator.remove();
var methodInsn = (MethodInsnNode) iterator.next();
methodInsn.owner = Type.getInternalName(ASMHooks.class);
methodInsn.name = "DragonAPIModListConstructorTweak";
methodInsn.desc = "(LReika/DragonAPI/ModList;)V";
iterator.add(new FrameNode(Opcodes.F_FULL, 6,
new Object[]{"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER,
"java/lang/String", "[Ljava/lang/String;",
"[Ljava/lang/String;"}, 0, new Object[]{}));
iterator.add(new InsnNode(Opcodes.RETURN));
iterator.add(new FrameNode(Opcodes.F_FULL, 6,
new Object[]{"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER,
"java/lang/String", "[Ljava/lang/String;",
"[Ljava/lang/String;"}, 0, new Object[]{}));
iterator.next();
iterator.remove();
break;
}
}
}
private void crash() {
throw new IllegalStateException("Tweaking failed!");
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
int state = 0;
for (val field : cn.fields) {
if (field.name.equals("__MARKER__FALSEPATTERN__MIXINPATCH__")) {
return;
}
}
for (val field : cn.fields) {
if (field.name.equals("condition") && field.desc.equals("Z")) {
field.access &= ~Opcodes.ACC_FINAL;
state++;
}
if (fields.contains(field.name)) {
field.access &= ~Opcodes.ACC_PRIVATE;
field.access &= ~Opcodes.ACC_PROTECTED;
field.access |= Opcodes.ACC_PUBLIC;
state++;
}
}
if (state != 4) {
crash();
}
cn.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "successful", "Z", null, 0));
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "__MARKER__FALSEPATTERN__MIXINPATCH__", "Z", null, 0));
int state2 = 0;
for (val method : cn.methods) {
if ((state2 & 1) == 0 && method.name.equals("<init>") &&
method.desc.equals("(Ljava/lang/String;ILjava/lang/String;[Ljava/lang/String;[Ljava/lang/String;)V")) {
tweakInit(method);
state2 |= 1;
}
if ((state2 & 2) == 0 && method.name.equals("isLoaded") && method.desc.equals("()Z")) {
tweakIsLoaded(method);
state2 |= 2;
}
}
if (state2 != 3) {
crash();
}
}
}
@@ -22,7 +22,7 @@ public class FmlRegistry implements IClassNodeTransformer {
}
field = AsmUtil.findField(cn, "MAX_ITEM_ID", true);
if (field != null) {
field.value = ExtendedConstants.maxBlockID;
field.value = ExtendedConstants.maxItemID;
}
boolean found = false;
for (final MethodNode method : cn.methods) {
@@ -30,7 +30,7 @@ public class FmlRegistry implements IClassNodeTransformer {
ExtendedConstants.maxBlockID, true)) {
found = true;
}
AsmUtil.transformInlinedSizeMethod(cn, method, 31999, ExtendedConstants.maxBlockID, true);
AsmUtil.transformInlinedSizeMethod(cn, method, 31999, ExtendedConstants.maxItemID, true);
}
if (!found) {
throw new AsmTransformException("can't find 4095 constant in any method");
@@ -0,0 +1,97 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
import com.falsepattern.endlessids.asm.IETransformer;
import lombok.val;
import lombok.var;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
public class GameDataAccelerator implements IClassNodeTransformer {
private static final int MASK_REGISTER_BLOCK = 0b1;
private static final int MASK_REGISTER_ITEM = 0b10;
@Override
public void transform(ClassNode classNode, boolean obfuscated) {
var cacheField = new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "endlessIDsItemBlockCache", "Lcom/falsepattern/endlessids/util/WeakIdentityHashMap;", null, null);
classNode.fields.add(cacheField);
int tweaksLeft = MASK_REGISTER_BLOCK | MASK_REGISTER_ITEM;
for (val method: classNode.methods) {
if ((tweaksLeft & MASK_REGISTER_BLOCK) != 0 &&
method.name.equals("registerBlock") &&
method.desc.equals("(Lnet/minecraft/block/Block;Ljava/lang/String;I)I")) {
transformRegisterBlock(method);
tweaksLeft &= ~MASK_REGISTER_BLOCK;
}
if ((tweaksLeft & MASK_REGISTER_ITEM) != 0 &&
method.name.equals("registerItem") &&
method.desc.equals("(Lnet/minecraft/item/Item;Ljava/lang/String;I)I")) {
transformRegisterItem(method);
tweaksLeft &= ~MASK_REGISTER_ITEM;
}
if (tweaksLeft == 0) {
break;
}
}
if (tweaksLeft != 0) {
IETransformer.logger.error("Could not accelerate block registration!");
}
}
private void transformRegisterItem(MethodNode method) {
var iter = method.instructions.iterator();
while (iter.hasNext()) {
var insn = iter.next();
if (!(insn instanceof FieldInsnNode))
continue;
var typeInsn = (FieldInsnNode) insn;
if (!(typeInsn.owner.equals("net/minecraft/item/ItemBlock") &&
typeInsn.name.equals("field_150939_a") &&
typeInsn.desc.equals("Lnet/minecraft/block/Block;")))
continue;
iter.previous();
iter.add(new InsnNode(Opcodes.DUP));
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "cacheItemBlock", "(Lnet/minecraft/item/ItemBlock;Lcpw/mods/fml/common/registry/GameData;)V", false));
return;
}
transformError(method);
}
private static void transformError(MethodNode method) {
IETransformer.logger.error("Could not add caching code to GameData." + method.name + method.desc);
}
private void transformRegisterBlock(MethodNode method) {
var iter = method.instructions.iterator();
while (iter.hasNext()) {
var insn = iter.next();
if (!(insn instanceof FieldInsnNode))
continue;
var fieldInsn = (FieldInsnNode) insn;
if (!(fieldInsn.owner.equals("cpw/mods/fml/common/registry/GameData") &&
fieldInsn.name.equals("iItemRegistry") &&
fieldInsn.desc.equals("Lcpw/mods/fml/common/registry/FMLControlledNamespacedRegistry;")))
continue;
iter.previous();
iter.previous();
iter.remove();
iter.next();
iter.remove();
iter.next();
iter.remove();
iter.add(new VarInsnNode(Opcodes.ALOAD, 1));
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "fetchCachedItemBlock", "(Lnet/minecraft/block/Block;Lcpw/mods/fml/common/registry/GameData;)Lnet/minecraft/item/ItemBlock;", false));
iter.add(new VarInsnNode(Opcodes.ASTORE, 4));
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "fakeIterable", "()Ljava/lang/Iterable;", false));
return;
}
transformError(method);
}
}
@@ -38,6 +38,16 @@ public class GeneralConfig {
@Config.Comment("Extend Potion IDs. Vanilla limit is 32, new limit is 65536.")
@Config.DefaultBoolean(true)
public static boolean extendPotion;
@Config.Comment("Extend Entity IDs. Vanilla limit is 256, new limit is 32768.")
@Config.DefaultBoolean(true)
public static boolean extendEntity;
@Config.Comment("Improves the speed of the block registry by multiple orders of magnitudes. (not thoroughly tested yet)\n" +
"It's highly recommended to leave this enabled, especially when using a lot of IDs.\n" +
"With this disabled, registering 1 million blocks on a test system took 80 minutes\n" +
"With this enabled, registering the same million blocks took 7 seconds")
@Config.DefaultBoolean(true)
public static boolean enableRegistryPerformanceTweak;
@Config.Comment(
"Extends the maximum redstone signal strength.\n" + "Only has effect with extendBlockItem enabled.\n" +
"WARNING: THIS IS HERE ONLY FOR FUN, IT WILL DEFINITELY CORRUPT YOUR WORLD!")
@@ -56,10 +66,30 @@ public class GeneralConfig {
"The default setting sets it to 4k (vanilla).\n" +
"increase if necessary (when running out of BLOCK IDs in your modpack)\n" +
"Only effective if extendBlockItem is enabled.\n" +
"(0: 16M, 1: 8M, 2: 4M, 3: 2M, 4: 1M, 5: 512K, 6: 256K, 7: 128K, 8: 64K, 9: 32K, 10: 16K, 11: 8K, 12: 4K)\n")
"Effective values: (0: 4k, 1: 8k, 2: 16k, 3: 32k, 4: 64k, 5: 128k, 6: 256k, 7: 512k, 8: 1M, 9: 2M, 10: 4M, 11: 8M, 12: 16M)\n" +
"The effective value of this variable must always be smaller or equal to the effective value of extraItemIDBits")
@Config.RangeInt(min = 0,
max = 12)
@Config.DefaultInt(12)
@Config.DefaultInt(0)
public static int extraBlockIDBits;
@Config.Comment("Use this to tune the amount of available item IDs.\n" +
"The vanilla default is 32k item IDs, while the maximum is 16 million.\n" +
"The default setting sets it to 32k (vanilla).\n" +
"increase if necessary (when running out of ITEM IDs in your modpack)\n" +
"Only effective if extendBlockItem is enabled.\n" +
"Effective values: (0: 32k, 1: 64k, 2: 128k, 3: 256k, 4: 512k, 5: 1M, 6: 2M, 7: 4M, 8: 8M, 9: 16M)\n" +
"The effective value of this variable must always be equal or larger than the effective value of extraBlockIDBits")
@Config.RangeInt(min = 0,
max = 9)
@Config.DefaultInt(0)
public static int extraItemIDBits;
@Config.Comment("DEPRECATED, will be removed in the next version of EndlessIDs!\n" +
"This property does nothing.\n" +
"Use extraBlockIDBits and extraItemIDBits instead.")
@Config.DefaultInt(0)
@Deprecated
public static int countCorrectionBits;
static {
@@ -2,11 +2,13 @@ package com.falsepattern.endlessids.constants;
import com.falsepattern.endlessids.config.GeneralConfig;
@SuppressWarnings("unused")
public class ExtendedConstants {
//Tunables
public static final int bitsPerID = 24;
public static final int bitsPerMetadata = 16;
public static final int countCorrectionBits = GeneralConfig.countCorrectionBits;
public static final int countCorrectionItemBits = 9 - GeneralConfig.extraItemIDBits;
public static final int countCorrectionBlockBits = 12 - GeneralConfig.extraBlockIDBits;
public static final int watchableBits = 7;
public static final int bitsPerBiome = 16;
@@ -14,6 +16,9 @@ public class ExtendedConstants {
public static final int maximumPotionIDs = 65536;
public static final int maximumEnchantmentIDs = 32768;
//Align with max item metadata for spawn eggs. Will be treated as short in netcode
public static final int bitsPerEntity = 15;
//BlockItemIDs
public static final int nibblesPerID = bitsPerID / 4;
public static final int bytesPerID = (nibblesPerID + 1) / 2;
@@ -21,9 +26,12 @@ public class ExtendedConstants {
public static final int bytesPerIDPlusMetadata = (nibblesPerID + nibblesPerMetadata + 1) / 2;
public static final int blockIDMask = (1 << bitsPerID) - 1;
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBits);
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBlockBits);
public static final int maxBlockID = blockIDCount - 1;
public static final int itemIDCount = 1 << (bitsPerID - countCorrectionItemBits);
public static final int maxItemID = itemIDCount - 1;
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
public static final int nibblesPerBlock = bitsPerBlock / 4;
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
@@ -34,12 +42,14 @@ public class ExtendedConstants {
public static final int biomeIDMask = biomeIDCount - 1;
public static final int biomeIDNull = biomeIDMask;
public static final int bytesPerBiome = (bitsPerBiome + 7) / 8;
//Chunk
public static final int bytesPerChunk =
(GeneralConfig.extendBiome ? bytesPerBiome : VanillaConstants.bytesPerBiome) * 256 +
(GeneralConfig.extendBlockItem ? bytesPerEBS : VanillaConstants.bytesPerEBS) * 16;
//DataWatcher
public static final int watchableCount = 1 << watchableBits;
public static final int maxWatchableID = watchableCount - 1;
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
//EntityIDs
public static final int entityIDCount = 1 << bitsPerEntity;
public static final int entityIDMask = entityIDCount - 1;
public static final int maxEntityID = entityIDMask;
}
@@ -1,5 +1,6 @@
package com.falsepattern.endlessids.constants;
@SuppressWarnings("unused")
public class VanillaConstants {
//Tunables
public static final int bitsPerID = 12;
@@ -9,6 +10,8 @@ public class VanillaConstants {
public static final int watchableBits = 5;
public static final int bitsPerBiome = 8;
public static final int bitsPerEntity = 8;
//BlockItemIDs
public static final int nibblesPerID = bitsPerID / 4;
public static final int bytesPerID = (nibblesPerID + 1) / 2;
@@ -19,6 +22,9 @@ public class VanillaConstants {
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBits);
public static final int maxBlockID = blockIDCount - 1;
public static final int itemIDCount = 32000;
public static final int maxItemID = itemIDCount - 1;
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
public static final int nibblesPerBlock = bitsPerBlock / 4;
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
@@ -29,10 +35,13 @@ public class VanillaConstants {
public static final int biomeIDMask = biomeIDCount - 1;
public static final int biomeIDNull = biomeIDMask;
public static final int bytesPerBiome = (bitsPerBiome + 7) / 8;
//Chunk
public static final int bytesPerChunk = bytesPerBiome * 256 + bytesPerEBS * 16;
//DataWatcher
public static final int watchableCount = 1 << watchableBits;
public static final int maxWatchableID = watchableCount - 1;
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
//EntityIDs
public static final int entityIDCount = 1 << bitsPerEntity;
public static final int maxEntityID = entityIDCount - 1;
}
@@ -0,0 +1,75 @@
package com.falsepattern.endlessids.managers;
import com.falsepattern.chunk.api.ChunkDataManager;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import lombok.var;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import java.nio.ByteBuffer;
public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.ChunkNBTDataManager {
@Override
public String domain() {
return Tags.MODID;
}
@Override
public String id() {
return "biome";
}
@Override
public int maxPacketSize() {
return 2 * 16 * 16;
}
@Override
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
data.asShortBuffer().put(((IChunkMixin)chunk).getBiomeShortArray());
data.position(data.position() + maxPacketSize());
}
@Override
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
var arr = ((IChunkMixin)chunk).getBiomeShortArray();
if (arr == null) {
arr = new short[16 * 16];
((IChunkMixin)chunk).setBiomeShortArray(arr);
}
buffer.asShortBuffer().get(arr);
buffer.position(buffer.position() + maxPacketSize());
}
@Override
public boolean chunkPrivilegedAccess() {
return true;
}
@Override
public void writeChunkToNBT(Chunk chunk, NBTTagCompound nbt) {
byte[] arr = Hooks.shortToByteArray(((IChunkMixin)chunk).getBiomeShortArray());
nbt.setByteArray("Biomes16v2", arr);
}
@Override
public void readChunkFromNBT(Chunk chunk, NBTTagCompound nbt) {
var data = ((IChunkMixin) chunk).getBiomeShortArray();
if (data == null) {
data = new short[16 * 16];
((IChunkMixin)chunk).setBiomeShortArray(data);
}
if (nbt.hasKey("Biomes16v2", 7)) {
Hooks.byteToShortArray(nbt.getByteArray("Biomes16v2"), 0, data, 0, data.length * 2);
} else if (nbt.hasKey("Biomes16", 7)) { //NotEnoughBiomes DFU
Hooks.byteToShortArrayLegacy(nbt.getByteArray("Biomes16"), data);
} else if (nbt.hasKey("Biomes", 7)) { //Vanilla DFU
Hooks.scatter(nbt.getByteArray("Biomes"), data);
}
}
}
@@ -0,0 +1,186 @@
package com.falsepattern.endlessids.managers;
import com.falsepattern.chunk.api.ChunkDataManager;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import lombok.val;
import lombok.var;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.nio.ByteBuffer;
public class BlockIDManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.SectionNBTDataManager {
@Override
public String domain() {
return Tags.MODID;
}
@Override
public String id() {
return "blockid";
}
@Override
public int maxPacketSize() {
return 3 * 16 * 16 * 16 * 16 + 4;
}
@Override
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
val ebsList = chunk.getBlockStorageArray();
int storageFlags = 0;
val start = data.position() + 4;
data.position(start);
for (int i = 0; i < 16; i++) {
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
continue;
}
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
storageFlags |= ebs.getEBSMSBMask() << (i * 2);
val b1 = ebs.getB1();
data.put(b1);
val b2Low = ebs.getB2Low();
if (b2Low == null) {
continue;
}
data.put(b2Low.data);
val b2High = ebs.getB2High();
if (b2High == null) {
continue;
}
data.put(b2High.data);
val b3 = ebs.getB3();
if (b3 != null) {
data.put(b3);
}
}
data.putInt(start - 4, storageFlags);
}
@Override
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
val ebsList = chunk.getBlockStorageArray();
val storageFlags = buffer.getInt();
for (int i = 0; i < 16; i++) {
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
continue;
}
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
val storageFlag = (storageFlags >>> (i * 2)) & 3;
val b1 = ebs.getB1();
buffer.get(b1);
if (storageFlag == 0b00) {
ebs.clearB2Low();
ebs.clearB2High();
ebs.clearB3();
continue;
}
var b2Low = ebs.getB2Low();
if (b2Low == null) {
b2Low = ebs.createB2Low();
}
buffer.get(b2Low.data);
if (storageFlag == 0b01) {
ebs.clearB2High();
ebs.clearB3();
continue;
}
var b2High = ebs.getB2High();
if (b2High == null) {
b2High = ebs.createB2High();
}
buffer.get(b2High.data);
if (storageFlag == 0b10) {
ebs.clearB3();
continue;
}
var b3 = ebs.getB3();
if (b3 == null) {
b3 = ebs.createB3();
}
buffer.get(b3);
}
}
@Override
public boolean sectionPrivilegedAccess() {
return true;
}
@Override
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
val b1 = ebs.getB1();
val b2Low = ebs.getB2Low();
val b2High = ebs.getB2High();
val b3 = ebs.getB3();
section.setByteArray("Blocks", b1);
if (b2Low != null) {
section.setByteArray("Add", b2Low.data);
}
if (b2High != null) {
section.setByteArray("BlocksB2Hi", b2High.data);
}
if (b3 != null) {
section.setByteArray("BlocksB3", b3);
}
}
//NotEnoughIDs world compatibility
public static void readSectionFromNBTNotEnoughIDsDFU(IExtendedBlockStorageMixin ebs, NBTTagCompound section) {
val data = section.getByteArray("Blocks16");
val dataShort = new short[data.length >>> 1];
ByteBuffer.wrap(data).asShortBuffer().get(dataShort);
val b1 = new byte[dataShort.length];
val b2L = new byte[dataShort.length >>> 1];
val b2H = new byte[dataShort.length >>> 1];
for (int i = 0; i < dataShort.length; i++) {
val s = dataShort[i];
val nI = i >>> 1;
val mI = (i & 1) * 4;
b1[i] = (byte) (s & 0x00FF);
b2L[nI] |= ((s & 0x0F00) >>> 8) << mI;
b2H[nI] |= ((s & 0xF000) >>> 12) << mI;
}
ebs.setB1(b1);
ebs.setB2Low(new NibbleArray(b2L, 4));
ebs.setB2High(new NibbleArray(b2H, 4));
}
@Override
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
if (section.hasKey("Blocks16")) {
readSectionFromNBTNotEnoughIDsDFU(ebs, section);
return;
}
assert section.hasKey("Blocks");
val b1 = section.getByteArray("Blocks");
final byte[] b2Low = section.hasKey("Add") ? section.getByteArray("Add") : null;
final byte[] b2High = section.hasKey("BlocksB2Hi") ? section.getByteArray("BlocksB2Hi") : null;
final byte[] b3 = section.hasKey("BlocksB3") ? section.getByteArray("BlocksB3") : null;
ebs.setB1(b1);
if (b2Low == null) {
ebs.clearB2Low();
} else {
ebs.setB2Low(new NibbleArray(b2Low, 4));
}
if (b2High == null) {
ebs.clearB2High();
} else {
ebs.setB2High(new NibbleArray(b2High, 4));
}
ebs.setB3(b3);
}
}
@@ -0,0 +1,134 @@
package com.falsepattern.endlessids.managers;
import com.falsepattern.chunk.api.ChunkDataManager;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import lombok.val;
import lombok.var;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.nio.ByteBuffer;
public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.SectionNBTDataManager {
@Override
public String domain() {
return Tags.MODID;
}
@Override
public String id() {
return "metadata";
}
@Override
public int maxPacketSize() {
return 2 * 16 * 16 * 16 * 16 + 4;
}
@Override
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
val ebsList = chunk.getBlockStorageArray();
int storageFlags = 0;
val start = data.position() + 4;
data.position(start);
for (int i = 0; i < 16; i++) {
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
continue;
}
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
storageFlags |= ebs.getEBSMask() << (i * 2);
val m1Low = ebs.getM1Low();
data.put(m1Low.data);
val m1High = ebs.getM1High();
if (m1High == null) {
continue;
}
data.put(m1High.data);
val m2 = ebs.getM2();
if (m2 != null) {
data.put(m2);
}
}
data.putInt(start - 4, storageFlags);
}
@Override
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
val ebsList = chunk.getBlockStorageArray();
val storageFlags = buffer.getInt();
for (int i = 0; i < 16; i++) {
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
continue;
}
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
val storageFlag = (storageFlags >>> (i * 2)) & 3;
val m1Low = ebs.getM1Low();
buffer.get(m1Low.data);
if (storageFlag == 0b01) {
ebs.clearM1High();
ebs.clearM2();
continue;
}
var m1High = ebs.getM1High();
if (m1High == null) {
m1High = ebs.createM1High();
}
buffer.get(m1High.data);
if (storageFlag == 0b10) {
ebs.clearM2();
continue;
}
var m2 = ebs.getM2();
if (m2 == null) {
m2 = ebs.createM2();
}
buffer.get(m2);
}
}
@Override
public boolean sectionPrivilegedAccess() {
return true;
}
@Override
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
val m1Low = ebs.getM1Low();
val m1High = ebs.getM1High();
val m2 = ebs.getM2();
section.setByteArray("Data", m1Low.data);
if (m1High != null) {
section.setByteArray("Data1High", m1High.data);
}
if (m2 != null) {
section.setByteArray("Data2", m2);
}
}
@Override
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
assert section.hasKey("Data");
val m1Low = section.getByteArray("Data");
final byte[] m1High = section.hasKey("Data1High") ? section.getByteArray("Data1High") : null;
final byte[] m2 = section.hasKey("Data2") ? section.getByteArray("Data2") : null;
ebs.setM1Low(new NibbleArray(m1Low, 4));
if (m1High == null) {
ebs.clearM1High();
} else {
ebs.setM1High(new NibbleArray(m1High, 4));
}
ebs.setM2(m2);
}
}
@@ -1,49 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.client.biome.vanilla;
import com.falsepattern.endlessids.Hooks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.world.chunk.Chunk;
import java.util.Iterator;
@Mixin(Chunk.class)
public abstract class ChunkMixin {
@SuppressWarnings("rawtypes")
@Inject(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;clearMSBArray()V")),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private void biomeData(byte[] p_76607_1_, int p_76607_2_, int p_76607_3_, boolean p_76607_4_, CallbackInfo ci, Iterator iterator, int k, boolean flag1, int l) {
Hooks.readBiomeArrayFromPacket((Chunk) (Object) this, p_76607_1_, k);
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;clearMSBArray()V")),
require = 1)
private void noCopyBiome(Object src, int srcPos, Object dest, int destPos, int length) {
}
@Redirect(method = "fillChunk",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/Chunk;blockBiomeArray:[B",
args = "array=length"),
require = 1)
private int noBiomeArrayLength(byte[] array) {
return 0;
}
}
@@ -1,141 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.client.blockitem.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
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.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.util.Iterator;
@Mixin(Chunk.class)
public abstract class ChunkMixin {
//This is needed because the array is not a field, but a local, and local arraylength overriding does not exist
private static byte[][] fakeArrays;
private static NibbleArray[] fakeNarrays;
@Shadow
private ExtendedBlockStorage[] storageArrays;
private int ebsData;
@ModifyVariable(method = "fillChunk",
at = @At("HEAD"),
ordinal = 0,
argsOnly = true)
private int extractEBSData(int ebs) {
ebsData = ebs;
int result = 0;
for (int i = 0; i < 16; i++) {
result |= ((ebs >>> (i << 1)) & 0b11) > 0 ? 1 << i : 0;
}
return result;
}
@Redirect(method = "fillChunk",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/Chunk;storageArrays:[Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;",
args = "array=length",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getSkylightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private int noMSBLoop(ExtendedBlockStorage[] array) {
return 0;
}
@SuppressWarnings("rawtypes")
@Inject(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private void blockData(byte[] p_76607_1_, int p_76607_2_, int p_76607_3_, boolean p_76607_4_, CallbackInfo ci, Iterator iterator, int k, boolean flag1, int l) {
val storageFlag = (p_76607_3_ >>> (l << 1)) & 0b11;
Hooks.setBlockData((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k, storageFlag);
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private byte[] fakeLSBArray(ExtendedBlockStorage instance) {
if (fakeArrays == null) {
fakeArrays = new byte[4][];
fakeArrays[0] = new byte[16 * 16 * 16 * 2 / 2];
fakeArrays[1] = new byte[16 * 16 * 16 * 3 / 2];
fakeArrays[2] = new byte[16 * 16 * 16 * 4 / 2];
fakeArrays[3] = new byte[16 * 16 * 16 * 6 / 2];
}
return fakeArrays[((IExtendedBlockStorageMixin) instance).getEBSMSBMask()];
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B")),
require = 1)
private void noCopy(Object src, int srcPos, Object dest, int destPos, int length) {
}
@Inject(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private void hookSetBlockMeta(byte[] p_76607_1_, int p_76607_2_, int p_76607_3_, boolean p_76607_4_, CallbackInfo ci, Iterator iterator, int k, boolean flag1, int l) {
val storageFlag = (ebsData >>> (l << 1)) & 0b11;
Hooks.setBlockMeta((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k, storageFlag);
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 1)
private NibbleArray hookSetBlockMetaNoArray(ExtendedBlockStorage instance) {
if (fakeNarrays == null) {
fakeNarrays = new NibbleArray[3];
fakeNarrays[0] = new NibbleArray(new byte[]{(byte)0b01}, 0);
fakeNarrays[1] = new NibbleArray(new byte[]{(byte)0b10}, 0);
fakeNarrays[2] = new NibbleArray(new byte[]{(byte)0b100}, 0);
}
return fakeNarrays[((IExtendedBlockStorageMixin)instance).getEBSMask() - 1];
}
@Redirect(method = "fillChunk",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/NibbleArray;data:[B",
args = "array=length"),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
to = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlocklightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
expect = 2,
require = 2)
private int hookSetBlockMetaFakeBytesLength(byte[] array) {
return 16 * 16 * 16 * (array[0] & 0xFF) / 2;
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private void hookSetBlockMetaNoCopy(Object src, int srcPos, Object dest, int destPos, int length) {
}
}
@@ -0,0 +1,33 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.dimdoors;
import StevenDimDoors.mod_pocketDim.world.DDBiomeGenBase;
import com.falsepattern.endlessids.PlaceholderBiome;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import net.minecraft.world.biome.BiomeGenBase;
@Mixin(value = DDBiomeGenBase.class,
priority = 999,
remap = false)
public abstract class DDBiomeGenBaseMixin extends BiomeGenBase {
private DDBiomeGenBaseMixin(int p_i1971_1_) {
super(p_i1971_1_);
}
/**
* @author FalsePattern
* @reason Compat patch
*/
@Overwrite
public static void checkBiomes(int[] biomes) {
val arr = getBiomeGenArray();
for(int k = 0; k < biomes.length; ++k) {
val b = arr[biomes[k]];
if (b != null && !(b instanceof DDBiomeGenBase || b instanceof PlaceholderBiome)) {
throw new IllegalStateException("There is a biome ID conflict between a biome from Dimensional Doors and another biome type. Fix your configuration!");
}
}
}
}
@@ -44,7 +44,7 @@ public abstract class ReikaWorldHelperMixin {
remap = true),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private static void customLogicSetBiome(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
private static void customLogicSetBiome(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
((IChunkMixin) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
}
@@ -54,7 +54,7 @@ public abstract class ReikaWorldHelperMixin {
remap = true),
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
require = 1)
private static void captureIndexSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
private static void captureIndexSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
fromBiomeID = ((IChunkMixin) ch).getBiomeShortArray()[index];
}
@@ -71,7 +71,7 @@ public abstract class ReikaWorldHelperMixin {
remap = true),
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
require = 1)
private static void customLogicSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index, BiomeGenBase from) {
private static void customLogicSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index, BiomeGenBase from) {
((IChunkMixin) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
}
}
@@ -5,7 +5,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(BiomeIDs.class)
@Mixin(value = BiomeIDs.class,
remap = false)
public abstract class BiomeIDsMixin {
@ModifyConstant(method = "<clinit>",
constant = @Constant(intValue = 39),
@@ -6,7 +6,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(BiomeGenSpace.class)
@Mixin(value = BiomeGenSpace.class,
remap = false)
public abstract class BiomeGenSpaceMixin {
@ModifyConstant(method = "<clinit>",
constant = @Constant(intValue = 97),
@@ -0,0 +1,86 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.ir3;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import jp.plusplus.ir2.IR2;
import jp.plusplus.ir2.blocks.BlockCore;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.event.terraingen.OreGenEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@Mixin(value = IR2.class,
priority = 999,
remap = false)
public abstract class IR2Mixin {
@Shadow public static boolean oresAreGenerated;
@Shadow public static boolean generateTinOre;
@Shadow public static boolean generateCopperOre;
@Shadow public static boolean generateSilverOre;
@Shadow public static boolean generateManganeseCrust;
@Shadow public static boolean generateCobaltCrust;
/**
* @author FalsePattern
* @reason Compat
*/
@SubscribeEvent
@Overwrite
public void generateOrePre(OreGenEvent.Pre event) {
if (oresAreGenerated) {
WorldGenerator genTin = new WorldGenMinable(BlockCore.ore, 0, 8, Blocks.stone);
WorldGenerator genCopper = new WorldGenMinable(BlockCore.ore, 1, 8, Blocks.stone);
WorldGenerator genSilver = new WorldGenMinable(BlockCore.ore, 2, 8, Blocks.stone);
WorldGenerator genManganese = new WorldGenMinable(BlockCore.crust, 0, 16, Blocks.gravel);
WorldGenerator genCobalt = new WorldGenMinable(BlockCore.crust, 1, 16, Blocks.gravel);
if (generateTinOre && TerrainGen.generateOre(event.world, event.rand, genTin, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 14; ++i) {
genTin.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 30 + event.rand.nextInt(20), event.worldZ + event.rand.nextInt(16));
}
}
if (generateCopperOre && TerrainGen.generateOre(event.world, event.rand, genCopper, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 10; ++i) {
genCopper.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 20 + event.rand.nextInt(20), event.worldZ + event.rand.nextInt(16));
}
}
if (generateSilverOre && TerrainGen.generateOre(event.world, event.rand, genSilver, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 4; ++i) {
genSilver.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 1 + event.rand.nextInt(29), event.worldZ + event.rand.nextInt(16));
}
}
short[] bIds = ((IChunkMixin)event.world.getChunkFromBlockCoords(event.worldX, event.worldZ)).getBiomeShortArray();
for(int k = 0; k < bIds.length; ++k) {
if (bIds[k] == BiomeGenBase.ocean.biomeID || bIds[k] == BiomeGenBase.deepOcean.biomeID) {
if (generateManganeseCrust && TerrainGen.generateOre(event.world, event.rand, genSilver, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 7; ++i) {
genManganese.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 16 + event.rand.nextInt(48), event.worldZ + event.rand.nextInt(16));
}
}
if (generateCobaltCrust && TerrainGen.generateOre(event.world, event.rand, genSilver, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 7; ++i) {
genCobalt.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 16 + event.rand.nextInt(48), event.worldZ + event.rand.nextInt(16));
}
}
break;
}
}
}
}
}
@@ -0,0 +1,39 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.restructured;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import org.blockartistry.mod.Restructured.world.BiomeHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import java.util.Random;
@Mixin(value = BiomeHelper.class,
priority = 999,
remap = false)
public abstract class BiomeHelperMixin {
/**
* @author FalsePattern
* @reason Compat
*/
@Overwrite
public static BiomeGenBase chunkBiomeSurvey(World world, Chunk chunk, Random rand) {
short[] biomes = ((IChunkMixin)chunk).getBiomeShortArray();
int[] counts = new int[biomes.length];
int highIndex = BiomeGenBase.plains.biomeID;
int highCount = -1;
for(int i = 0; i < 32; ++i) {
int id = biomes[rand.nextInt(biomes.length)] & 65535;
if (id != 65535 && ++counts[id] > highCount) {
highIndex = id;
highCount = counts[id];
}
}
return BiomeGenBase.getBiome(highIndex);
}
}
@@ -1,65 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
import com.falsepattern.endlessids.Hooks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
@Mixin(AnvilChunkLoader.class)
public abstract class AnvilChunkLoaderMixin {
//TODO not thread safe
private Chunk chunk;
private NBTTagCompound nbt;
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B"),
require = 1)
private byte[] grabChunkBiomeDataWrite(Chunk instance) {
chunk = instance;
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V"),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Sections"),
to = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/Chunk;hasEntities:Z",
ordinal = 0)),
require = 1)
private void redirectBiomeDataWrite(NBTTagCompound instance, String p_74773_1_, byte[] p_74773_2_) {
Hooks.writeChunkBiomeArrayToNbt(chunk, instance);
chunk = null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Biomes",
ordinal = 0)),
require = 1)
private boolean grabBiomeNBTRead(NBTTagCompound instance, String p_150297_1_, int p_150297_2_) {
nbt = instance;
return true;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V"),
require = 1)
private void redirectBiomeDataRead(Chunk instance, byte[] p_76616_1_) {
Hooks.readChunkBiomeArrayFromNbt(instance, nbt);
nbt = null;
}
}
@@ -1,21 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.network.play.server.S21PacketChunkData;
import net.minecraft.world.chunk.Chunk;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B"),
require = 1)
private static byte[] getBiomesArrayShort(Chunk instance) {
return Hooks.shortToByteArray(((IChunkMixin) instance).getBiomeShortArray());
}
}
@@ -1,138 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(AnvilChunkLoader.class)
public abstract class AnvilChunkLoaderMixin {
//TODO not thread safe
private IExtendedBlockStorageMixin ebs;
private NBTTagCompound nbt;
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private byte[] grabEBSBlockDataWrite(ExtendedBlockStorage instance) {
ebs = (IExtendedBlockStorageMixin) instance;
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V"),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getYLocation()I"),
to = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private void redirectBlockDataWrite(NBTTagCompound instance, String key, byte[] value) {
Hooks.writeBlockDataToNBT(instance, ebs);
ebs = null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 1)
private NibbleArray suppressVanillaBlockDataWrite(ExtendedBlockStorage instance) {
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 1)
private NibbleArray grabEBSBlockMetaWrite(ExtendedBlockStorage instance) {
ebs = (IExtendedBlockStorageMixin) instance;
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/NibbleArray;data:[B",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private byte[] suppressEBSBlockMetaNibbleArrayAccess(NibbleArray instance) {
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Data")),
require = 1)
private void redirectBlockMetaWrite(NBTTagCompound instance, String p_74773_1_, byte[] p_74773_2_) {
Hooks.writeBlockMetaToNBT(ebs, instance);
ebs = null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Blocks")),
require = 1)
private byte[] grabNBTBlockDataRead(NBTTagCompound instance, String key) {
nbt = instance;
return null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;setBlockLSBArray([B)V"),
require = 1)
private void redirectBlockDataRead(ExtendedBlockStorage instance, byte[] p_76664_1_) {
Hooks.readBlockDataFromNBT((IExtendedBlockStorageMixin) instance, nbt);
nbt = null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Add",
ordinal = 0)),
require = 1)
private boolean suppressVanillaBlockDataRead(NBTTagCompound instance, String key, int type) {
return false;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Data")),
require = 1)
private byte[] grabNBTBlockMetaRead(NBTTagCompound instance, String key) {
nbt = instance;
return null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;setBlockMetadataArray(Lnet/minecraft/world/chunk/NibbleArray;)V"),
require = 1)
private void redirectBlockMetaRead(ExtendedBlockStorage instance, NibbleArray p_76668_1_) {
Hooks.readBlockMetaFromNBT((IExtendedBlockStorageMixin) instance, nbt);
nbt = null;
}
}
@@ -12,7 +12,7 @@ import net.minecraft.network.PacketBuffer;
import java.io.IOException;
@Mixin(PacketBuffer.class)
@Mixin(value = PacketBuffer.class, priority = 999)
public abstract class PacketBufferMixin {
@Shadow
@@ -1,120 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
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.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.network.play.server.S21PacketChunkData;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
private static byte[][] fakeArrays;
private static NibbleArray[] fakeNarrays;
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;",
ordinal = 0),
require = 1)
private static NibbleArray noMSB(ExtendedBlockStorage instance) {
return null;
}
@Inject(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private static void hookGetBlockData(Chunk p_149269_0_, boolean p_149269_1_, int p_149269_2_, CallbackInfoReturnable<S21PacketChunkData.Extracted> cir, int j, ExtendedBlockStorage[] aextendedblockstorage, int k, S21PacketChunkData.Extracted extracted, byte[] abyte, int l) {
val ebs = (IExtendedBlockStorageMixin) aextendedblockstorage[l];
extracted.field_150281_c |= Hooks.getBlockData(ebs, abyte, j) << (l << 1);
}
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private static byte[] hookGetBlockDataFakeArray(ExtendedBlockStorage instance) {
if (fakeArrays == null) {
fakeArrays = new byte[4][];
fakeArrays[0] = new byte[16 * 16 * 16 * 2 / 2];
fakeArrays[1] = new byte[16 * 16 * 16 * 3 / 2];
fakeArrays[2] = new byte[16 * 16 * 16 * 4 / 2];
fakeArrays[3] = new byte[16 * 16 * 16 * 6 / 2];
}
return fakeArrays[((IExtendedBlockStorageMixin) instance).getEBSMSBMask()];
}
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B")),
require = 1)
private static void hookGetBlockDataNoCopy(Object src, int srcPos, Object dest, int destPos, int length) {
}
@Inject(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private static void hookGetBlockMeta(Chunk p_149269_0_, boolean p_149269_1_, int p_149269_2_, CallbackInfoReturnable<S21PacketChunkData.Extracted> cir, int j, ExtendedBlockStorage[] aextendedblockstorage, int k, S21PacketChunkData.Extracted extracted, byte[] abyte, int l) {
if (l == 0) {
extracted.field_150280_b = 0;
}
extracted.field_150280_b |= Hooks.getBlockMeta((IExtendedBlockStorageMixin) aextendedblockstorage[l], abyte, j) << (l << 1);
}
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 1)
private static NibbleArray hookGetBlockMetaNoArray(ExtendedBlockStorage instance) {
if (fakeNarrays == null) {
fakeNarrays = new NibbleArray[3];
fakeNarrays[0] = new NibbleArray(new byte[]{(byte)0b01}, 0);
fakeNarrays[1] = new NibbleArray(new byte[]{(byte)0b10}, 0);
fakeNarrays[2] = new NibbleArray(new byte[]{(byte)0b100}, 0);
}
return fakeNarrays[((IExtendedBlockStorageMixin)instance).getEBSMask() - 1];
}
@Redirect(method = "func_149269_a",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/NibbleArray;data:[B",
args = "array=length"),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
to = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlocklightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
expect = 2,
require = 2)
private static int hookGetBlockMetaFakeBytesLength(byte[] array) {
return 16 * 16 * 16 * (array[0] & 0xFF) / 2;
}
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private static void hookGetBlockMetaNoCopy(Object src, int srcPos, Object dest, int destPos, int length) {
}
}
@@ -11,10 +11,17 @@ import net.minecraft.stats.StatList;
@Mixin(StatList.class)
public abstract class StatListMixin {
@ModifyConstant(method = "<clinit>",
constant = {@Constant(intValue = VanillaConstants.blockIDCount), @Constant(intValue = 32000)},
require = 4)
constant = {@Constant(intValue = VanillaConstants.blockIDCount)},
require = 1)
private static int modifyMineBlockStatArraySize(int constant) {
return ExtendedConstants.blockIDCount;
}
@ModifyConstant(method = "<clinit>",
constant = {@Constant(intValue = VanillaConstants.itemIDCount)},
require = 3)
private static int modifyItemStatArraysSize(int constant) {
return ExtendedConstants.itemIDCount;
}
}
@@ -0,0 +1,49 @@
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.entity.EntityList;
@Mixin(EntityList.class)
public abstract class EntityListMixin {
@Shadow
public static void addMapping(Class p_75618_0_, String p_75618_1_, int p_75618_2_) {
}
@Shadow
public static void addMapping(Class p_75614_0_, String p_75614_1_, int p_75614_2_, int p_75614_3_, int p_75614_4_) {
}
@ModifyConstant(method = "addMapping(Ljava/lang/Class;Ljava/lang/String;I)V",
constant = @Constant(intValue = VanillaConstants.maxEntityID),
require = 1)
private static int extendRange(int constant) {
return ExtendedConstants.maxEntityID;
}
@Redirect(method = "<clinit>",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/entity/EntityList;addMapping(Ljava/lang/Class;Ljava/lang/String;I)V"),
require = 1)
private static void messUpMappings1(Class p_75618_0_, String p_75618_1_, int p_75618_2_) {
addMapping(p_75618_0_, p_75618_1_, p_75618_2_ * 100);
}
@Redirect(method = "<clinit>",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/entity/EntityList;addMapping(Ljava/lang/Class;Ljava/lang/String;III)V"),
require = 1)
private static void messUpMappings2(Class p_75614_0_, String p_75614_1_, int p_75614_2_, int p_75614_3_, int p_75614_4_) {
addMapping(p_75614_0_, p_75614_1_, p_75614_2_ * 100, p_75614_3_, p_75614_4_);
}
}
@@ -0,0 +1,66 @@
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.apache.logging.log4j.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.EntityRegistry;
import java.util.BitSet;
@Mixin(value = EntityRegistry.class,
remap = false)
public abstract class EntityRegistryMixin {
@Shadow private BitSet availableIndicies;
@ModifyConstant(method = "<init>",
constant = @Constant(intValue = VanillaConstants.entityIDCount),
require = 1)
private int extendIDs1(int constant) {
return ExtendedConstants.entityIDCount;
}
@ModifyConstant(method = "<init>",
constant = @Constant(intValue = VanillaConstants.maxEntityID),
require = 1)
private int extendIDs2(int constant) {
return ExtendedConstants.maxEntityID;
}
/**
* @author FalsePattern
* @reason Extended IDs
*/
@Overwrite
private int validateAndClaimId(int id) {
//Keeping the legacy sub-0 id workaround here...
// workaround for broken ML
int realId = id;
if (id < Byte.MIN_VALUE) {
realId += 3000;
FMLLog.warning("Compensating for modloader out of range compensation by mod : entityId %d for mod %s is now %d", id, Loader.instance().activeModContainer().getModId(), realId);
}
if (realId < 0) {
realId += Byte.MAX_VALUE;
}
if ((realId & ~ExtendedConstants.entityIDMask) != 0) {
FMLLog.log(Level.ERROR, "The entity ID %d for mod %s is not in the range 1-" + ExtendedConstants.entityIDMask + " and may not work", id, Loader.instance().activeModContainer().getModId());
}
if (!availableIndicies.get(realId)) {
FMLLog.severe("The mod %s has attempted to register an entity ID %d which is already reserved. This could cause severe problems", Loader.instance().activeModContainer().getModId(), id);
}
availableIndicies.clear(realId);
return realId;
}
}
@@ -0,0 +1,63 @@
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import io.netty.buffer.ByteBuf;
import org.spongepowered.asm.mixin.Mixin;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S0FPacketSpawnMob;
@Mixin(S0FPacketSpawnMob.class)
public abstract class S0FPacketSpawnMobMixin {
@Shadow private int field_149040_b;
@Inject(method = "<init>(Lnet/minecraft/entity/EntityLivingBase;)V",
at = @At("RETURN"),
require = 1)
private void unClampType(EntityLivingBase entity, CallbackInfo ci) {
field_149040_b = EntityList.getEntityID(entity);
}
@Redirect(method = "readPacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
ordinal = 0),
require = 1)
private byte noReadByte(PacketBuffer data) {
return 0;
}
@Inject(method = "readPacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
ordinal = 0),
require = 1)
private void readType(PacketBuffer data, CallbackInfo ci) {
field_149040_b = data.readShort() & ExtendedConstants.entityIDMask;
}
@Redirect(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
ordinal = 0),
require = 1)
private ByteBuf noWriteByte(PacketBuffer data, int theByte) {
return null;
}
@Inject(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
ordinal = 0),
require = 1)
private void writeType(PacketBuffer data, CallbackInfo ci) {
data.writeShort(field_149040_b & ExtendedConstants.entityIDMask);
}
}
@@ -1,121 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.vanilla;
import com.falsepattern.endlessids.config.GeneralConfig;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import io.netty.buffer.ByteBuf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S21PacketChunkData;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
@Shadow
private static byte[] field_149286_i;
@Shadow
private int field_149280_d;
@Shadow
private byte[] field_149278_f;
@Shadow
private int field_149284_a;
@Shadow
private int field_149282_b;
@Shadow
private boolean field_149279_g;
@Shadow
private int field_149283_c;
@Shadow
private int field_149285_h;
@ModifyConstant(method = {"<clinit>", "func_149275_c"},
constant = @Constant(intValue = VanillaConstants.bytesPerChunk),
require = 1)
private static int increasePacketSize(int constant) {
return ExtendedConstants.bytesPerChunk;
}
@Inject(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
ordinal = 0),
require = 1)
private void extendWrite(PacketBuffer p_148840_1_, CallbackInfo ci) {
if (GeneralConfig.extendBlockItem) {
p_148840_1_.writeInt(this.field_149283_c);
p_148840_1_.writeInt(this.field_149280_d);
} else {
p_148840_1_.writeShort((short)(this.field_149283_c & 65535));
p_148840_1_.writeShort((short)(this.field_149280_d & 65535));
}
p_148840_1_.writeInt(this.field_149278_f.length);
}
@Redirect(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
ordinal = 0),
require = 1)
private ByteBuf suppressOldWrite1(PacketBuffer instance, int p_writeShort_1_) {
return null;
}
@Redirect(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
ordinal = 1),
require = 1)
private ByteBuf suppressOldWrite2(PacketBuffer instance, int p_writeShort_1_) {
return null;
}
@Inject(method = "readPacketData",
at = @At("HEAD"),
require = 1,
cancellable = true)
private void customRead(PacketBuffer data, CallbackInfo ci) throws IOException {
this.field_149284_a = data.readInt();
this.field_149282_b = data.readInt();
this.field_149279_g = data.readBoolean();
if (GeneralConfig.extendBlockItem) {
this.field_149283_c = data.readInt();
this.field_149280_d = data.readInt();
} else {
this.field_149283_c = data.readShort();
this.field_149280_d = data.readShort();
}
int length = data.readInt();
this.field_149285_h = data.readInt();
if (field_149286_i.length < this.field_149285_h) {
field_149286_i = new byte[this.field_149285_h];
}
data.readBytes(field_149286_i, 0, this.field_149285_h);
this.field_149278_f = new byte[length];
Inflater inflater = new Inflater();
inflater.setInput(field_149286_i, 0, this.field_149285_h);
try {
inflater.inflate(this.field_149278_f);
} catch (DataFormatException dataformatexception) {
throw new IOException("Bad compressed data format");
} finally {
inflater.end();
}
ci.cancel();
}
}
@@ -1,97 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.vanilla;
import com.falsepattern.endlessids.config.GeneralConfig;
import io.netty.buffer.ByteBuf;
import org.spongepowered.asm.mixin.Mixin;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S26PacketMapChunkBulk;
import java.util.zip.Inflater;
@Mixin(S26PacketMapChunkBulk.class)
public abstract class S26PacketMapChunkBulkMixin {
@Shadow
private int[] field_149262_d;
@Shadow
private byte[][] field_149260_f;
@Shadow
private int[] field_149266_a;
@Shadow
private int[] field_149264_b;
@Shadow
private int[] field_149265_c;
@Inject(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
ordinal = 1),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private void extendWrite(PacketBuffer p_148840_1_, CallbackInfo ci, int i) {
if (GeneralConfig.extendBlockItem) {
p_148840_1_.writeInt(this.field_149265_c[i]);
p_148840_1_.writeInt(this.field_149262_d[i]);
} else {
p_148840_1_.writeShort((short)(this.field_149265_c[i] & 65535));
p_148840_1_.writeShort((short)(this.field_149262_d[i] & 65535));
}
p_148840_1_.writeInt(this.field_149260_f[i].length);
}
@Redirect(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
ordinal = 1),
require = 1)
private ByteBuf suppressOldWrite1(PacketBuffer instance, int p_writeShort_1_) {
return null;
}
@Redirect(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
ordinal = 2),
require = 1)
private ByteBuf suppressOldWrite2(PacketBuffer instance, int p_writeShort_1_) {
return null;
}
@Inject(method = "readPacketData",
at = @At(value = "INVOKE",
target = "Ljava/util/zip/Inflater;inflate([B)I",
shift = At.Shift.AFTER),
require = 1,
locals = LocalCapture.CAPTURE_FAILHARD,
cancellable = true)
private void customRead(PacketBuffer data, CallbackInfo ci, short short1, byte[] abyte, Inflater inflater) {
int i = 0;
for (int j = 0; j < short1; ++j) {
this.field_149266_a[j] = data.readInt();
this.field_149264_b[j] = data.readInt();
if (GeneralConfig.extendBlockItem) {
this.field_149265_c[j] = data.readInt();
this.field_149262_d[j] = data.readInt();
} else {
this.field_149265_c[j] = data.readShort();
this.field_149262_d[j] = data.readShort();
}
byte[] dataBytes = new byte[data.readInt()];
this.field_149260_f[j] = dataBytes;
System.arraycopy(abyte, i, dataBytes, 0, dataBytes.length);
i += dataBytes.length;
}
ci.cancel();
}
}
@@ -9,7 +9,6 @@ import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.function.Predicate;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.always;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.avoid;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.condition;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.require;
@@ -17,10 +16,6 @@ import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.require;
@RequiredArgsConstructor
public enum Mixin implements IMixin {
//region common
//region vanilla
S21PacketChunkDataMixin(Side.COMMON, always(), "vanilla.S21PacketChunkDataMixin"),
S26PacketMapChunkBulkMixin(Side.COMMON, always(), "vanilla.S26PacketMapChunkBulkMixin"),
//endregion vanilla
//region AntiIDConflict
AIDCAntiIdConflictBaseMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.AntiIdConflictBaseMixin"),
AIDCBiomesGenBasePlaceholderMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.BiomeGenBasePlaceholderMixin"),
@@ -32,13 +27,11 @@ public enum Mixin implements IMixin {
//endregion AntiIDConflict
//region biome
//region vanilla
AnvilChunkLoaderMixinBiome(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.AnvilChunkLoaderMixin"),
BiomeDictionaryMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.BiomeDictionaryMixin"),
BiomeGenBaseMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.BiomeGenBaseMixin"),
ChunkMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.ChunkMixin"),
GenLayerRiverMixMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(avoid(TargetedMod.DRAGONAPI)), "biome.vanilla.GenLayerRiverMixMixin"),
GenLayerVoronoiZoomMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.GenLayerVoronoiZoomMixin"),
S21PacketChunkDataMixinBiome(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.S21PacketChunkDataMixin"),
//endregion vanilla
//region AbyssalCraft
AbyssalCraftMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.ABYSSALCRAFT)), "biome.abyssalcraft.AbyssalCraftMixin"),
@@ -75,6 +68,9 @@ public enum Mixin implements IMixin {
//region DarkWorld
DarkWorldModBiomesMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.DARKWORLD)), "biome.darkworld.ModBiomesMixin"),
//endregion DarkWorld
//region DimDoors
DDBiomeGenBaseMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.DIMDOORS)), "biome.dimdoors.DDBiomeGenBaseMixin"),
//endregion DimDoors
//region DragonAPI
DragonAPIGenLayerRiverMixVanillaMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.DRAGONAPI)), "biome.dragonapi.vanilla.GenLayerRiverMixMixin"),
DragonAPIGenLayerRiverEventMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.DRAGONAPI)), "biome.dragonapi.GenLayerRiverEventMixin"),
@@ -120,6 +116,9 @@ public enum Mixin implements IMixin {
//region ICG
ICGMysteriumPatchesFixesCaveMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.ICG)), "biome.icg.MysteriumPatchesFixesCaveMixin"),
//endregion ICG
//region Industrial Revolution by Redstone Rebooted
IR3IR2Mixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.IR3)), "biome.ir3.IR2Mixin"),
//endregion Industrial Revolution by Redstone Rebooted
//region LOTR
LOTRBiomeVariantStorageMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRBiomeVariantStorageMixin"),
LOTRChunkProviderMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRChunkProviderMixin"),
@@ -140,6 +139,9 @@ public enum Mixin implements IMixin {
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"),
//endregion RandomThings
//region Restructured
RSBiomeHelperMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RESTRUCTURED)), "biome.restructured.BiomeHelperMixin"),
//endregion Restructured
//region RTG
RTGChunkProviderRTGMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RTG)), "biome.rtg.ChunkProviderRTGMixin"),
RTGLandscapeGeneratorMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RTG)), "biome.rtg.LandscapeGeneratorMixin"),
@@ -164,13 +166,11 @@ public enum Mixin implements IMixin {
//endregion biome
//region blockitem
//region vanilla
AnvilChunkLoaderMixinBlockItem(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.AnvilChunkLoaderMixin"),
BlockFireMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.BlockFireMixin"),
ExtendedBlockStorageMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ExtendedBlockStorageMixin"),
ItemInWorldManagerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemInWorldManagerMixin"),
ItemStackMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemStackMixin"),
PacketBufferMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.PacketBufferMixin"),
S21PacketChunkDataMixinBlockItem(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.S21PacketChunkDataMixin"),
S22PacketMultiBlockChangeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.S22PacketMultiBlockChangeMixin"),
S24PacketBlockActionMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.S24PacketBlockActionMixin"),
StatListMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.StatListMixin"),
@@ -215,20 +215,23 @@ public enum Mixin implements IMixin {
S1EPacketRemoveEntityEffectMixin(Side.COMMON, condition(() -> GeneralConfig.extendPotion), "potion.vanilla.network.S1EPacketRemoveEntityEffectMixin"),
//endregion vanilla
//endregion potion
//region entity
//region vanilla
EntityListMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.EntityListMixin"),
EntityRegistryMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.EntityRegistryMixin"),
S0FPacketSpawnMobMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.S0FPacketSpawnMobMixin"),
//endregion vanilla
//endregion entity
//endregion common
//region client
//region biome
//region vanilla
ChunkMixinClientBiome(Side.CLIENT, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.ChunkMixin"),
//endregion vanilla
//region Biome Wand
BiomeWandItemClientMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.BIOMEWAND)), "biome.biomewand.BiomeWandItemMixin"),
//endregion Biome Wand
//endregion biome
//region blockitem
//region vanilla
ChunkMixinClientBlockItem(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ChunkMixin"),
NetHandlerPlayClientMixinBlockItem(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.NetHandlerPlayClientMixin"),
PlayerControllerMPMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.PlayerControllerMPMixin"),
RenderGlobalMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.RenderGlobalMixin"),
@@ -23,6 +23,7 @@ public enum TargetedMod implements ITargetedMod {
COFHLIB("CoFH Lib", false, startsWith("cofhlib-")),
COMPACTMACHINES("Compact Machines", false, startsWith("compactmachines-")),
DARKWORLD("Dark World", false, startsWith("darkworld-")),
DIMDOORS("Dimensional Doors", false, startsWith("dimensionaldoors-").or(startsWith("dimdoors-"))),
DRAGONAPI("DragonAPI", false, startsWith("dragonapi")),
EB("Enhanced Biomes", false, startsWith("Enhanced Biomes").or(startsWith("enhancedbiomes"))),
ENDERLICIOUS("Enderlicious", false, startsWith("enderlicious-")),
@@ -34,12 +35,14 @@ public enum TargetedMod implements ITargetedMod {
GALAXYSPACE("GalaxySpace", false, startsWith("galaxyspace-")),
HIGHLANDS("Highlands", false, startsWith("highlands")),
ICG("Immersive Cavegen", false, startsWith("immersivecavegen")),
IR3("Industrial Revolution by Redstone Rebooted", false, startsWith("industrialrevolutionbyredstonerebooted-")),
LOTR("LOTR Mod", false, startsWith("lotrmod")),
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")),
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")),
@@ -0,0 +1,71 @@
package com.falsepattern.endlessids.util;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Like WeakHashMap, but uses identity instead of equality when comparing keys.
*/
public class WeakIdentityHashMap<K,V> {
private final HashMap<WeakReference<K>,V> mMap = new HashMap<>();
private final ReferenceQueue<Object> mRefQueue = new ReferenceQueue<>();
private void cleanUp() {
Reference<?> ref;
while ((ref = mRefQueue.poll()) != null) {
mMap.remove(ref);
}
}
public void put(K key, V value) {
cleanUp();
mMap.put(new CmpWeakReference<>(key, mRefQueue), value);
}
public V get(K key) {
cleanUp();
return mMap.get(new CmpWeakReference<>(key));
}
public Collection<V> values() {
cleanUp();
return mMap.values();
}
public Set<Map.Entry<WeakReference<K>, V>> entrySet() {
return mMap.entrySet();
}
public int size() {
cleanUp();
return mMap.size();
}
public boolean isEmpty() {
cleanUp();
return mMap.isEmpty();
}
private static class CmpWeakReference<K> extends WeakReference<K> {
private final int mHashCode;
public CmpWeakReference(K key) {
super(key);
mHashCode = System.identityHashCode(key);
}
public CmpWeakReference(K key, ReferenceQueue<Object> refQueue) {
super(key, refQueue);
mHashCode = System.identityHashCode(key);
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
K k = get();
if (k != null && o instanceof CmpWeakReference) {
return ((CmpWeakReference) o).get() == k;
}
return false;
}
@Override
public int hashCode() {
return mHashCode;
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ EndlessIDs
Copyright (C) 2022 FalsePattern
All Rights Reserved
The above copyright notice, this permission notice and the word "SNEED"
The above copyright notice, this permission notice and the word "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