mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-24 10:34:29 +00:00
Compare commits
39
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
484a9175e7 | ||
|
|
1bb71d9448 | ||
|
|
11ff4a4a6a | ||
|
|
6b3d872fbd | ||
|
|
344b788108 | ||
|
|
b61711280b | ||
|
|
67badb8fcb | ||
|
|
e529ad49cb | ||
|
|
10c19feb0c | ||
|
|
fb0096350c | ||
|
|
1f726e42d3 | ||
|
|
1944aa08f1 | ||
|
|
0dfe4bfc2d | ||
|
|
fcac948f88 | ||
|
|
04fe960ca4 | ||
|
|
a1d13d833d | ||
|
|
8ae84392ba | ||
|
|
76092e5c4c | ||
|
|
0ecadb8563 | ||
|
|
147099d625 | ||
|
|
e699d67f4e | ||
|
|
6101766529 | ||
|
|
8c715bd579 | ||
|
|
e7340cd9b1 | ||
|
|
786652504c | ||
|
|
4ded45cc5c | ||
|
|
16be8d607c | ||
|
|
775ea5769c | ||
|
|
93e375a07d | ||
|
|
a2c0ac2d99 | ||
|
|
de5fa2d322 | ||
|
|
984c976b34 | ||
|
|
0e58bf113d | ||
|
|
0b968923df | ||
|
|
f98d2c98e3 | ||
|
|
bf52cfaadf | ||
|
|
c321707f0e | ||
|
|
c8e076f6d2 | ||
|
|
6f832f4905 |
No files matched your search
Generated
+7
@@ -1,5 +1,6 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="FORMATTER_TAGS_ENABLED" value="true" />
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="ANNOTATION_PARAMETER_WRAP" value="2" />
|
||||
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
|
||||
@@ -25,6 +26,9 @@
|
||||
<option name="JD_ADD_BLANK_AFTER_PARM_COMMENTS" value="true" />
|
||||
<option name="JD_ADD_BLANK_AFTER_RETURN" value="true" />
|
||||
</JavaCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
@@ -62,5 +66,8 @@
|
||||
<option name="ENUM_CONSTANTS_WRAP" value="2" />
|
||||
<option name="WRAP_ON_TYPING" value="0" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
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 |
|
||||
@@ -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
@@ -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
@@ -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
@@ -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,141 +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 net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class Hooks {
|
||||
|
||||
public static void getBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, final int offset) {
|
||||
val lsb = ebs.getLSB();
|
||||
val msb = ebs.getMSB();
|
||||
Unsafer.arraycopy(lsb, 0, data, offset, lsb.length);
|
||||
System.arraycopy(msb, 0, data, offset + lsb.length * 2, msb.length);
|
||||
}
|
||||
|
||||
public static void setBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, final int offset) {
|
||||
val lsb = ebs.getLSB();
|
||||
val msb = ebs.getMSB();
|
||||
Unsafer.arraycopy(data, offset, lsb, 0, lsb.length);
|
||||
System.arraycopy(data, offset + lsb.length * 2, msb, 0, msb.length);
|
||||
}
|
||||
|
||||
public static void getBlockMeta(final IExtendedBlockStorageMixin ebs, final byte[] data, final int offset) {
|
||||
val meta = ebs.getMetaArray();
|
||||
Unsafer.arraycopy(meta, 0, data, offset, meta.length);
|
||||
}
|
||||
|
||||
public static void setBlockMeta(final IExtendedBlockStorageMixin ebs, final byte[] data, final int offset) {
|
||||
val meta = ebs.getMetaArray();
|
||||
Unsafer.arraycopy(data, offset, meta, 0, meta.length);
|
||||
}
|
||||
|
||||
public static void writeBlockDataToNBT(final NBTTagCompound nbt, final IExtendedBlockStorageMixin ebs) {
|
||||
val ebsLSB = ebs.getLSB();
|
||||
val ebsMSB = ebs.getMSB();
|
||||
|
||||
val byte1Data = new byte[ebsLSB.length];
|
||||
byte[] byte2BottomNibbleData = null;
|
||||
byte[] byte2TopNibbleData = null;
|
||||
byte[] byte3Data = null;
|
||||
for (int i = 0; i < ebsLSB.length; ++i) {
|
||||
if (ebsMSB[i] != 0) {
|
||||
if (byte3Data == null) {
|
||||
byte3Data = new byte[ebsLSB.length];
|
||||
}
|
||||
byte3Data[i] = ebsMSB[i];
|
||||
}
|
||||
val idLSB = (ebsLSB[i] & 0xFFFF);
|
||||
byte1Data[i] = (byte) (idLSB & 0xFF);
|
||||
|
||||
if (idLSB <= 0xFF) {
|
||||
continue;
|
||||
}
|
||||
val nibbleIndex = i >> 1;
|
||||
val nibbleShift = (i & 1) * 4;
|
||||
if (byte2BottomNibbleData == null) {
|
||||
byte2BottomNibbleData = new byte[ebsLSB.length / 2];
|
||||
}
|
||||
byte2BottomNibbleData[nibbleIndex] |= ((idLSB >>> 8) & 0xF) << nibbleShift;
|
||||
|
||||
if (idLSB <= 0xFFF) {
|
||||
continue;
|
||||
}
|
||||
if (byte2TopNibbleData == null) {
|
||||
byte2TopNibbleData = new byte[ebsLSB.length / 2];
|
||||
}
|
||||
byte2TopNibbleData[nibbleIndex] |= ((idLSB >>> 12) & 0xF) << nibbleShift;
|
||||
|
||||
}
|
||||
nbt.setByteArray("Blocks", byte1Data);
|
||||
if (byte2BottomNibbleData != null) {
|
||||
nbt.setByteArray("Add", byte2BottomNibbleData);
|
||||
}
|
||||
if (byte2TopNibbleData != null) {
|
||||
nbt.setByteArray("BlocksB2Hi", byte2TopNibbleData);
|
||||
}
|
||||
if (byte3Data != null) {
|
||||
nbt.setByteArray("BlocksB3", byte3Data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void readBlockDataFromNBT(final IExtendedBlockStorageMixin ebs, final NBTTagCompound nbt) {
|
||||
assert nbt.hasKey("Blocks");
|
||||
val byte1Data = nbt.getByteArray("Blocks");
|
||||
val byte2BottomNibbleData = nbt.hasKey("Add") ? nbt.getByteArray("Add") : null;
|
||||
val byte2TopNibbleData = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
|
||||
val byte3Data = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
|
||||
|
||||
val lsb = ebs.getLSB();
|
||||
val msb = ebs.getMSB();
|
||||
for (int i = 0; i < lsb.length; i++) {
|
||||
if (byte3Data != null) {
|
||||
msb[i] = byte3Data[i];
|
||||
}
|
||||
int nibbleShift = (i & 1) * 4;
|
||||
int id = byte1Data[i] & 0xFF;
|
||||
if (byte2BottomNibbleData != null) {
|
||||
id |= ((byte2BottomNibbleData[i >> 1] >> nibbleShift) & 0xF) << 8;
|
||||
}
|
||||
if (byte2TopNibbleData != null) {
|
||||
id |= ((byte2TopNibbleData[i >> 1] >> nibbleShift) & 0xF) << 12;
|
||||
}
|
||||
lsb[i] = (short) id;
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeInvalidBlocksHook(final IExtendedBlockStorageMixin ebs) {
|
||||
val blkIdsLSB = ebs.getLSB();
|
||||
val blkIdsMSB = ebs.getMSB();
|
||||
int cntNonEmpty = 0;
|
||||
int cntTicking = 0;
|
||||
for (int off = 0; off < blkIdsLSB.length; ++off) {
|
||||
final int id =
|
||||
((blkIdsLSB[off] & 0xFFFF) | ((blkIdsMSB[off] & 0xFF) << 16)) & ExtendedConstants.blockIDMask;
|
||||
if (id > 0) {
|
||||
final Block block = (Block) Block.blockRegistry.getObjectById(id);
|
||||
if (block == null) {
|
||||
if (GeneralConfig.removeInvalidBlocks) {
|
||||
blkIdsLSB[off] = 0;
|
||||
}
|
||||
} else if (block != Blocks.air) {
|
||||
++cntNonEmpty;
|
||||
if (block.getTickRandomly()) {
|
||||
++cntTicking;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ebs.setBlockRefCount(cntNonEmpty);
|
||||
ebs.setTickRefCount(cntTicking);
|
||||
}
|
||||
|
||||
public static int getIdFromBlockWithCheck(final Block block, final Block oldBlock) {
|
||||
final int id = Block.getIdFromBlock(block);
|
||||
if (GeneralConfig.catchUnregisteredBlocks && id == -1) {
|
||||
@@ -155,8 +24,8 @@ public class Hooks {
|
||||
public static void shortToByteArray(short[] shortArray, int shortOffset, byte[] byteArray, int byteOffset, int shortCount) {
|
||||
for (int i = 0; i < shortCount; i++) {
|
||||
short s = shortArray[shortOffset + i];
|
||||
byteArray[byteOffset + i * 2] = (byte)(s & 255);
|
||||
byteArray[byteOffset + i * 2 + 1] = (byte)((s >>> 8) & 255);
|
||||
byteArray[byteOffset + i * 2] = (byte) (s & 255);
|
||||
byteArray[byteOffset + i * 2 + 1] = (byte) ((s >>> 8) & 255);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,60 +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)) {
|
||||
byteToShortArrayLegacy(nbt.getByteArray("Biomes16"), data);
|
||||
} else if (nbt.hasKey("Biomes", 7)) {
|
||||
scatter(nbt.getByteArray("Biomes"), data);
|
||||
} else {
|
||||
put = false;
|
||||
}
|
||||
if (put) {
|
||||
((IChunkMixin) chunk).setBiomeShortArray(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void readBlockMetaFromNBT(IExtendedBlockStorageMixin instance, NBTTagCompound nbt) {
|
||||
short[] data = instance.getMetaArray();
|
||||
if (nbt.hasKey("Data16", 7)) {
|
||||
byteToShortArray(nbt.getByteArray("Data16"), 0, data, 0, data.length * 2);
|
||||
} else {
|
||||
scatter(nbt.getByteArray("Data"), data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeBlockMetaToNBT(IExtendedBlockStorageMixin instance, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("Data16", shortToByteArray(instance.getMetaArray()));
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,13 @@ import java.nio.ShortBuffer;
|
||||
|
||||
public class Unsafer {
|
||||
public static final Unsafe UNSAFE;
|
||||
|
||||
static {
|
||||
Field unsafeField = null;
|
||||
Unsafe unsafe = null;
|
||||
for (val field: Unsafe.class.getDeclaredFields()) {
|
||||
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.getType().equals(Unsafe.class)) {
|
||||
for (val field : Unsafe.class.getDeclaredFields()) {
|
||||
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) &&
|
||||
field.getType().equals(Unsafe.class)) {
|
||||
unsafeField = field;
|
||||
break;
|
||||
}
|
||||
@@ -40,9 +42,12 @@ public class Unsafer {
|
||||
val sourceOffsetBytes = sourceOffset * 2;
|
||||
val arrayOffsetSource = UNSAFE.arrayBaseOffset(source.getClass());
|
||||
val arrayOffsetTarget = UNSAFE.arrayBaseOffset(target.getClass());
|
||||
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffsetBytes, target, arrayOffsetTarget + targetOffset, (long)shorts << 1);
|
||||
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffsetBytes, target, arrayOffsetTarget + targetOffset,
|
||||
(long) shorts << 1);
|
||||
} else {
|
||||
ByteBuffer.wrap(target, targetOffset, target.length - targetOffset).asShortBuffer().put(source, sourceOffset, shorts);
|
||||
ByteBuffer.wrap(target, targetOffset, target.length - targetOffset)
|
||||
.asShortBuffer()
|
||||
.put(source, sourceOffset, shorts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +56,11 @@ public class Unsafer {
|
||||
val targetOffsetBytes = targetOffset * 2;
|
||||
val arrayOffsetSource = UNSAFE.arrayBaseOffset(source.getClass());
|
||||
val arrayOffsetTarget = UNSAFE.arrayBaseOffset(target.getClass());
|
||||
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffset, target, arrayOffsetTarget + targetOffsetBytes, (long)shorts << 1);
|
||||
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffset, target, arrayOffsetTarget + targetOffsetBytes,
|
||||
(long) shorts << 1);
|
||||
} else {
|
||||
ShortBuffer.wrap(target, targetOffset, target.length - targetOffset).put(ByteBuffer.wrap(source, sourceOffset, shorts * 2).asShortBuffer());
|
||||
ShortBuffer.wrap(target, targetOffset, target.length - targetOffset)
|
||||
.put(ByteBuffer.wrap(source, sourceOffset, shorts * 2).asShortBuffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,32 +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");
|
||||
SpaceCoreModInfoGenerator(new SpaceCoreModInfoGenerator(), () -> true,
|
||||
"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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,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;
|
||||
@@ -18,9 +19,8 @@ import java.util.List;
|
||||
|
||||
public class IETransformer implements IClassTransformer {
|
||||
public static final Logger logger;
|
||||
public static boolean isObfuscated;
|
||||
|
||||
private static final List<String> blacklist = new ArrayList<>();
|
||||
public static boolean isObfuscated;
|
||||
|
||||
static {
|
||||
logger = LogManager.getLogger(Tags.MODNAME + " ASM");
|
||||
@@ -38,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);
|
||||
@@ -53,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;
|
||||
}
|
||||
+12
@@ -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;
|
||||
}
|
||||
+119
-130
@@ -123,87 +123,6 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
public static final String[] CLASS_Chunk;
|
||||
public static final String[] FIELD_biomeID;
|
||||
public static final String[] METHOD_getBiomeArray;
|
||||
|
||||
static {
|
||||
if (IETransformer.isObfuscated) {
|
||||
CLASS_BiomeGenBase = new String[]{"ahu", "net/minecraft/world/biome/BiomeGenBase"};
|
||||
CLASS_IChunkProvider = new String[]{"apu", "net/minecraft/world/chunk/IChunkProvider"};
|
||||
CLASS_ChunkProviderGenerate = new String[]{"aqz", "net/minecraft/world/gen/ChunkProviderGenerate"};
|
||||
CLASS_Chunk = new String[]{"apx", "net/minecraft/world/chunk/Chunk"};
|
||||
FIELD_biomeID = new String[]{"ay", "field_76756_M"};
|
||||
METHOD_getBiomeArray = new String[]{"m", "func_76605_m"};
|
||||
} else {
|
||||
CLASS_BiomeGenBase = new String[]{"net/minecraft/world/biome/BiomeGenBase"};
|
||||
CLASS_IChunkProvider = new String[]{"net/minecraft/world/chunk/IChunkProvider"};
|
||||
CLASS_ChunkProviderGenerate = new String[]{"net/minecraft/world/gen/ChunkProviderGenerate"};
|
||||
CLASS_Chunk = new String[]{"net/minecraft/world/chunk/Chunk"};
|
||||
FIELD_biomeID = new String[]{"biomeID"};
|
||||
METHOD_getBiomeArray = new String[]{"getBiomeArray"};
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldPatch(final ClassNode cn) {
|
||||
if (!GeneralConfig.extendBiome) {
|
||||
return false;
|
||||
}
|
||||
for (MethodNode method : cn.methods) {
|
||||
if (scanForBrokenCall(method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean scanForBrokenCall(MethodNode method) {
|
||||
val instructions = method.instructions;
|
||||
val insnCount = instructions.size();
|
||||
for (int i = 0; i < insnCount; i++) {
|
||||
val insn = instructions.get(i);
|
||||
if (insn.getOpcode() != Opcodes.INVOKEVIRTUAL) {
|
||||
continue;
|
||||
}
|
||||
val invoke = (MethodInsnNode) insn;
|
||||
|
||||
if (anyMatch(invoke.owner, CLASS_Chunk) &&
|
||||
anyMatch(invoke.name, METHOD_getBiomeArray) &&
|
||||
invoke.desc.equals("()[B")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean anyMatch(List<String> str, String[] candidates) {
|
||||
for (val s: str) {
|
||||
for (val candidate: candidates) {
|
||||
if (s.equals(candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean anyMatch(String str, String[] candidates) {
|
||||
for (val candidate: candidates) {
|
||||
if (str.equals(candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean anyMatch(String str, String[] candidates, String prefix, String suffix) {
|
||||
for (val candidate: candidates) {
|
||||
if (str.equals(prefix + candidate + suffix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public interface State<T extends AbstractInsnNode> extends BiFunction<T, Memory, State<AbstractInsnNode>> {}
|
||||
|
||||
private static State<AbstractInsnNode> STATE0 = null;
|
||||
private static State<AbstractInsnNode> STATE1 = null;
|
||||
private static State<AbstractInsnNode> STATE2 = null;
|
||||
@@ -228,6 +147,25 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
private static State<AbstractInsnNode> STATE16 = null;
|
||||
private static State<AbstractInsnNode> STATE17 = null;
|
||||
private static State<AbstractInsnNode> STATE_FINAL = null;
|
||||
|
||||
static {
|
||||
if (IETransformer.isObfuscated) {
|
||||
CLASS_BiomeGenBase = new String[]{"ahu", "net/minecraft/world/biome/BiomeGenBase"};
|
||||
CLASS_IChunkProvider = new String[]{"apu", "net/minecraft/world/chunk/IChunkProvider"};
|
||||
CLASS_ChunkProviderGenerate = new String[]{"aqz", "net/minecraft/world/gen/ChunkProviderGenerate"};
|
||||
CLASS_Chunk = new String[]{"apx", "net/minecraft/world/chunk/Chunk"};
|
||||
FIELD_biomeID = new String[]{"ay", "field_76756_M"};
|
||||
METHOD_getBiomeArray = new String[]{"m", "func_76605_m"};
|
||||
} else {
|
||||
CLASS_BiomeGenBase = new String[]{"net/minecraft/world/biome/BiomeGenBase"};
|
||||
CLASS_IChunkProvider = new String[]{"net/minecraft/world/chunk/IChunkProvider"};
|
||||
CLASS_ChunkProviderGenerate = new String[]{"net/minecraft/world/gen/ChunkProviderGenerate"};
|
||||
CLASS_Chunk = new String[]{"net/minecraft/world/chunk/Chunk"};
|
||||
FIELD_biomeID = new String[]{"biomeID"};
|
||||
METHOD_getBiomeArray = new String[]{"getBiomeArray"};
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
STATE_FINAL = (insn, memory) -> STATE_FINAL;
|
||||
|
||||
@@ -276,7 +214,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
STATE6 = typeCheck(LabelNode.class, () -> STATE7);
|
||||
|
||||
STATE7 = casting(FrameNode.class, (insn, memory) ->
|
||||
anyMatch((String)memory.locals.get(memory.chunkIndex), CLASS_Chunk) &&
|
||||
anyMatch((String) memory.locals.get(memory.chunkIndex), CLASS_Chunk) &&
|
||||
memory.locals.get(memory.biomeArrayIndex).equals("[B") &&
|
||||
memory.locals.get(memory.iteratorIndex).equals(1)
|
||||
? STATE8 : STATE0);
|
||||
@@ -291,13 +229,9 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
&& insn.var == memory.biomeArrayIndex
|
||||
? STATE10 : STATE0);
|
||||
|
||||
STATE10 = casting(InsnNode.class, (insn) ->
|
||||
insn.getOpcode() == Opcodes.ARRAYLENGTH
|
||||
? STATE11 : STATE0);
|
||||
STATE10 = casting(InsnNode.class, (insn) -> insn.getOpcode() == Opcodes.ARRAYLENGTH ? STATE11 : STATE0);
|
||||
|
||||
STATE11 = casting(JumpInsnNode.class, (insn) ->
|
||||
insn.getOpcode() == Opcodes.IF_ICMPGE
|
||||
? STATE12 : STATE0);
|
||||
STATE11 = casting(JumpInsnNode.class, (insn) -> insn.getOpcode() == Opcodes.IF_ICMPGE ? STATE12 : STATE0);
|
||||
|
||||
STATE12 = typeCheck(LabelNode.class, () -> STATE13);
|
||||
|
||||
@@ -307,8 +241,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
? STATE14 : STATE0);
|
||||
|
||||
STATE14 = casting(VarInsnNode.class, (insn, memory) -> {
|
||||
if (insn.getOpcode() == Opcodes.ILOAD &&
|
||||
insn.var == memory.iteratorIndex) {
|
||||
if (insn.getOpcode() == Opcodes.ILOAD && insn.var == memory.iteratorIndex) {
|
||||
if (insn.getNext() instanceof FieldInsnNode) {
|
||||
return STATE14_C1;
|
||||
} else {
|
||||
@@ -320,7 +253,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
|
||||
STATE14_ABD1 = casting(VarInsnNode.class, (insn, memory) -> {
|
||||
if (insn.getOpcode() == Opcodes.ALOAD) {
|
||||
if (anyMatch((String)memory.locals.get(insn.var), CLASS_BiomeGenBase, "[L", ";")) {
|
||||
if (anyMatch((String) memory.locals.get(insn.var), CLASS_BiomeGenBase, "[L", ";")) {
|
||||
return STATE14_ABD1_BA2;
|
||||
} else {
|
||||
return STATE14_ABD1_BD1;
|
||||
@@ -341,17 +274,12 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
});
|
||||
|
||||
STATE14_ABD1_BA2 = casting(VarInsnNode.class, (insn, memory) ->
|
||||
insn.getOpcode() == Opcodes.ILOAD &&
|
||||
insn.var == memory.iteratorIndex
|
||||
? STATE14_ABD1_BA3 : STATE0);
|
||||
insn.getOpcode() == Opcodes.ILOAD && insn.var == memory.iteratorIndex ? STATE14_ABD1_BA3 : STATE0);
|
||||
|
||||
STATE14_ABD1_BA3 = casting(InsnNode.class, (insn) ->
|
||||
insn.getOpcode() == Opcodes.AALOAD
|
||||
? STATE15 : STATE0);
|
||||
STATE14_ABD1_BA3 = casting(InsnNode.class, (insn) -> insn.getOpcode() == Opcodes.AALOAD ? STATE15 : STATE0);
|
||||
|
||||
STATE14_C1 = casting(FieldInsnNode.class, (insn, memory) -> {
|
||||
if (insn.getOpcode() == Opcodes.GETSTATIC &&
|
||||
anyMatch(insn.desc, CLASS_BiomeGenBase, "L", ";")) {
|
||||
if (insn.getOpcode() == Opcodes.GETSTATIC && anyMatch(insn.desc, CLASS_BiomeGenBase, "L", ";")) {
|
||||
return STATE15;
|
||||
}
|
||||
return STATE0;
|
||||
@@ -381,6 +309,65 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean shouldPatch(final ClassNode cn) {
|
||||
if (!GeneralConfig.extendBiome) {
|
||||
return false;
|
||||
}
|
||||
for (MethodNode method : cn.methods) {
|
||||
if (scanForBrokenCall(method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean scanForBrokenCall(MethodNode method) {
|
||||
val instructions = method.instructions;
|
||||
val insnCount = instructions.size();
|
||||
for (int i = 0; i < insnCount; i++) {
|
||||
val insn = instructions.get(i);
|
||||
if (insn.getOpcode() != Opcodes.INVOKEVIRTUAL) {
|
||||
continue;
|
||||
}
|
||||
val invoke = (MethodInsnNode) insn;
|
||||
|
||||
if (anyMatch(invoke.owner, CLASS_Chunk) && anyMatch(invoke.name, METHOD_getBiomeArray) &&
|
||||
invoke.desc.equals("()[B")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean anyMatch(List<String> str, String[] candidates) {
|
||||
for (val s : str) {
|
||||
for (val candidate : candidates) {
|
||||
if (s.equals(candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean anyMatch(String str, String[] candidates) {
|
||||
for (val candidate : candidates) {
|
||||
if (str.equals(candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean anyMatch(String str, String[] candidates, String prefix, String suffix) {
|
||||
for (val candidate : candidates) {
|
||||
if (str.equals(prefix + candidate + suffix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static <T extends AbstractInsnNode> State<AbstractInsnNode> typeCheck(Class<T> clazz, Supplier<State<AbstractInsnNode>> okState) {
|
||||
return casting(clazz, (insn, memory) -> okState.get());
|
||||
}
|
||||
@@ -401,33 +388,6 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
boolean patched = false;
|
||||
for (val method: cn.methods) {
|
||||
val memory = findTheTarget(method);
|
||||
if (memory != null) {
|
||||
patched = true;
|
||||
IETransformer.logger.debug("[ChunkProvider patcher]: Match found in method " + method.name);
|
||||
val insnList = method.instructions;
|
||||
for (val node: method.localVariables) {
|
||||
if (node.desc.equals("[B") && node.index == memory.biomeArrayIndex) {
|
||||
node.desc = "[S";
|
||||
}
|
||||
}
|
||||
val getBiomeArray = (MethodInsnNode) insnList.get(memory.getBiomeArrayInsn);
|
||||
insnList.set(getBiomeArray, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, getBiomeArray.owner, "getBiomeShortArray", "()[S", false));
|
||||
insnList.set(insnList.get(memory.castInsn), new InsnNode(Opcodes.I2S));
|
||||
insnList.set(insnList.get(memory.arrayStoreInsn), new InsnNode(Opcodes.SASTORE));
|
||||
}
|
||||
}
|
||||
if (!patched) {
|
||||
IETransformer.logger.debug("[ChunkProvider patcher]: No matches found in class! This is not explicitly " +
|
||||
"an error, because the patch might be applied by a mixin instead!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Memory findTheTarget(MethodNode method) {
|
||||
val insnList = method.instructions;
|
||||
var currentState = STATE0;
|
||||
@@ -453,20 +413,49 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
boolean patched = false;
|
||||
for (val method : cn.methods) {
|
||||
val memory = findTheTarget(method);
|
||||
if (memory != null) {
|
||||
patched = true;
|
||||
IETransformer.logger.debug("[ChunkProvider patcher]: Match found in method " + method.name);
|
||||
val insnList = method.instructions;
|
||||
for (val node : method.localVariables) {
|
||||
if (node.desc.equals("[B") && node.index == memory.biomeArrayIndex) {
|
||||
node.desc = "[S";
|
||||
}
|
||||
}
|
||||
val getBiomeArray = (MethodInsnNode) insnList.get(memory.getBiomeArrayInsn);
|
||||
insnList.set(getBiomeArray,
|
||||
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, getBiomeArray.owner, "getBiomeShortArray",
|
||||
"()[S", false));
|
||||
insnList.set(insnList.get(memory.castInsn), new InsnNode(Opcodes.I2S));
|
||||
insnList.set(insnList.get(memory.arrayStoreInsn), new InsnNode(Opcodes.SASTORE));
|
||||
}
|
||||
}
|
||||
if (!patched) {
|
||||
IETransformer.logger.debug("[ChunkProvider patcher]: No matches found in class! This is not explicitly " +
|
||||
"an error, because the patch might be applied by a mixin instead!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface State<T extends AbstractInsnNode> extends BiFunction<T, Memory, State<AbstractInsnNode>> {
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class Memory {
|
||||
|
||||
final List<Object> locals = new ArrayList<>();
|
||||
int currentInsn;
|
||||
|
||||
int startingInsn;
|
||||
int getBiomeArrayInsn;
|
||||
int castInsn;
|
||||
int arrayStoreInsn;
|
||||
|
||||
int chunkIndex;
|
||||
int biomeArrayIndex;
|
||||
int iteratorIndex;
|
||||
|
||||
final List<Object> locals = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.asm.ClassEdit;
|
||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
||||
import com.falsepattern.endlessids.asm.IETransformer;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -21,6 +19,7 @@ import java.io.IOException;
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class DevFixer {
|
||||
private static final ClassNode blocks;
|
||||
|
||||
static {
|
||||
if (IETransformer.isObfuscated) {
|
||||
blocks = null;
|
||||
@@ -62,7 +61,7 @@ public final class DevFixer {
|
||||
}
|
||||
|
||||
private static void biomeTweakerCompat(final ClassNode cn) {
|
||||
for (val field: cn.fields) {
|
||||
for (val field : cn.fields) {
|
||||
if (field.name.startsWith("spawnable")) {
|
||||
field.access &= ~Opcodes.ACC_PROTECTED;
|
||||
field.access |= Opcodes.ACC_PUBLIC;
|
||||
@@ -71,18 +70,16 @@ public final class DevFixer {
|
||||
}
|
||||
|
||||
private static void remapBlocks(final ClassNode cn) {
|
||||
for (val method: cn.methods) {
|
||||
for (val method : cn.methods) {
|
||||
val instructions = method.instructions;
|
||||
int insnCount = instructions.size();
|
||||
for (int i = 0; i < insnCount; i++) {
|
||||
val insn = instructions.get(i);
|
||||
if (insn instanceof FieldInsnNode) {
|
||||
val field = (FieldInsnNode) insn;
|
||||
if (field.getOpcode() == Opcodes.GETSTATIC &&
|
||||
field.owner.equals("net/minecraft/init/Blocks")) {
|
||||
for (val blockField: blocks.fields) {
|
||||
if (blockField.name.equals(field.name) &&
|
||||
!blockField.desc.equals(field.desc)) {
|
||||
if (field.getOpcode() == Opcodes.GETSTATIC && field.owner.equals("net/minecraft/init/Blocks")) {
|
||||
for (val blockField : blocks.fields) {
|
||||
if (blockField.name.equals(field.name) && !blockField.desc.equals(field.desc)) {
|
||||
field.desc = blockField.desc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class SpaceCoreModInfoGenerator implements IClassNodeTransformer {
|
||||
if (obfuscated) {
|
||||
return;
|
||||
}
|
||||
for (val method: cn.methods) {
|
||||
for (val method : cn.methods) {
|
||||
if (method.name.equals("generate")) {
|
||||
val iterator = method.instructions.iterator();
|
||||
iterator.add(new InsnNode(Opcodes.RETURN));
|
||||
|
||||
@@ -5,45 +5,48 @@ import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.config.ConfigurationManager;
|
||||
|
||||
@Config(modid = Tags.MODID, category = "darkworld")
|
||||
@Config(modid = Tags.MODID,
|
||||
category = "darkworld")
|
||||
public class DarkWorldIDConfig {
|
||||
static {
|
||||
ConfigurationManager.selfInit();
|
||||
}
|
||||
@Config.Comment("Original: 100")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.RangeInt(min = 40,
|
||||
max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(1100)
|
||||
public static int darkOceanID;
|
||||
|
||||
@Config.Comment("Original: 101")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.RangeInt(min = 40,
|
||||
max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(1101)
|
||||
public static int darkPlainsID;
|
||||
|
||||
@Config.Comment("Original: 102")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.RangeInt(min = 40,
|
||||
max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(1102)
|
||||
public static int darkDesertID;
|
||||
|
||||
@Config.Comment("Original: 103")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.RangeInt(min = 40,
|
||||
max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(1103)
|
||||
public static int darkHillsID;
|
||||
|
||||
@Config.Comment("Original: 104")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.RangeInt(min = 40,
|
||||
max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(1104)
|
||||
public static int darkForestID;
|
||||
|
||||
@Config.Comment("Original: 105")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.RangeInt(min = 40,
|
||||
max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(1105)
|
||||
public static int darkTaigaID;
|
||||
|
||||
@Config.Comment("Original: 106")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.RangeInt(min = 40,
|
||||
max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(1106)
|
||||
public static int darkSwampID;
|
||||
|
||||
static {
|
||||
ConfigurationManager.selfInit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,13 +5,16 @@ import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.config.ConfigurationManager;
|
||||
|
||||
@Config(modid = Tags.MODID, category = "futurepack")
|
||||
@Config(modid = Tags.MODID,
|
||||
category = "futurepack")
|
||||
public class FuturepackIDConfig {
|
||||
@Config.Comment("Original: 97")
|
||||
@Config.RangeInt(min = 40,
|
||||
max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(2097)
|
||||
public static int spaceID;
|
||||
|
||||
static {
|
||||
ConfigurationManager.selfInit();
|
||||
}
|
||||
@Config.Comment("Original: 97")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(2097)
|
||||
public static int spaceID;
|
||||
}
|
||||
@@ -6,72 +6,90 @@ import com.falsepattern.lib.config.ConfigurationManager;
|
||||
|
||||
@Config(modid = Tags.MODID)
|
||||
public class GeneralConfig {
|
||||
static {
|
||||
ConfigurationManager.selfInit();
|
||||
}
|
||||
@Config.Comment("WARNING: THIS CONFIG IS EXTREMELY SENSITIVE TO CHANGES, DISABLING STUFF ONCE THEY HAVE BEEN ENABLED\n" +
|
||||
"CAN CORRUPT YOUR WORLD! ONLY TOUCH THIS FILE IF YOU KNOW WHAT YOU'RE DOING!\n" +
|
||||
"This file should only be edited by modpack developers to finetune it for the modpack. Once an option\n" +
|
||||
"has been enabled, it modifies the chunk save data format, which is (partially) compatible with\n" +
|
||||
"vanilla, but removing the mod might cause block/item corruption for higher IDs.\n" +
|
||||
"Additional note: Every client and server must have the exact same config, this also affects netcode.")
|
||||
@Config.Comment(
|
||||
"WARNING: THIS CONFIG IS EXTREMELY SENSITIVE TO CHANGES, DISABLING STUFF ONCE THEY HAVE BEEN ENABLED\n" +
|
||||
"CAN CORRUPT YOUR WORLD! ONLY TOUCH THIS FILE IF YOU KNOW WHAT YOU'RE DOING!\n" +
|
||||
"This file should only be edited by modpack developers to finetune it for the modpack. Once an option\n" +
|
||||
"has been enabled, it modifies the chunk save data format, which is (partially) compatible with\n" +
|
||||
"vanilla, but removing the mod might cause block/item corruption for higher IDs.\n" +
|
||||
"Additional note: Every client and server must have the exact same config, this also affects netcode.")
|
||||
@Config.DefaultString("")
|
||||
public static String __NOTICE__;
|
||||
@Config.Comment("Throw an exception when an invalid block is registered. FOR DEBUGGING PURPOSES")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean catchUnregisteredBlocks;
|
||||
|
||||
@Config.Comment("Remove invalid (corrupted) blocks from the game. FOR DEBUGGING PURPOSES")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean removeInvalidBlocks;
|
||||
|
||||
@Config.Comment("Extend Biome IDs. Vanilla limit is 256, new limit is 65536.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendBiome;
|
||||
|
||||
@Config.Comment("Extend Block and Item IDs. Vanilla limit is 4096/32000, new limit is 16777216 for both.\n" +
|
||||
"See also: countCorrectionBits")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendBlockItem;
|
||||
|
||||
@Config.Comment("Extend DataWatcher IDs. Vanilla limit is 31, new limit is 127.\n" +
|
||||
"Disabled by default because of uncertain/weak implementation (taken from NotEnoughIDs)")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean extendDataWatcher;
|
||||
|
||||
@Config.Comment("Extend Enchantment IDs. Vanilla limit is 256, new limit is 32768.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendEnchantment;
|
||||
|
||||
@Config.Comment("Extend Potion IDs. Vanilla limit is 32, new limit is 65536.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendPotion;
|
||||
|
||||
@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!")
|
||||
@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!")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean extendRedstone;
|
||||
|
||||
@Config.Comment("Increases the max signal strength of redstone.\n" +
|
||||
"Only has effect with both extendBlockItem and extendRedstone enabled.\n" +
|
||||
"Vanilla value is 15.")
|
||||
"Only has effect with both extendBlockItem and extendRedstone enabled.\n" + "Vanilla value is 15.")
|
||||
@Config.RangeInt(min = 15,
|
||||
max = 127)
|
||||
@Config.DefaultInt(15)
|
||||
public static int maxRedstone;
|
||||
|
||||
@Config.Comment(
|
||||
"Use this to tune the amount of available block IDs.\n" +
|
||||
"Minecraft contains some internal code that uses a HUGE amount of RAM with too many block IDs available.\n" +
|
||||
"Notice: This does not affect ITEM IDs.\n" +
|
||||
"The vanilla default is 4k block IDs, while the maximum is 16 million.\n" +
|
||||
"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")
|
||||
@Config.Comment("Use this to tune the amount of available block IDs.\n" +
|
||||
"Minecraft contains some internal code that uses a HUGE amount of RAM with too many block IDs available.\n" +
|
||||
"Notice: This does not affect ITEM IDs.\n" +
|
||||
"The vanilla default is 4k block IDs, while the maximum is 16 million.\n" +
|
||||
"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" +
|
||||
"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 {
|
||||
ConfigurationManager.selfInit();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -21,9 +23,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;
|
||||
@@ -39,9 +44,4 @@ public class ExtendedConstants {
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
|
||||
//Chunk
|
||||
public static final int bytesPerChunk =
|
||||
(GeneralConfig.extendBiome ? bytesPerBiome : VanillaConstants.bytesPerBiome) * 256
|
||||
+ (GeneralConfig.extendBlockItem ? bytesPerEBS : VanillaConstants.bytesPerEBS) * 16;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.falsepattern.endlessids.constants;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class VanillaConstants {
|
||||
//Tunables
|
||||
public static final int bitsPerID = 12;
|
||||
@@ -19,6 +20,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,8 +33,7 @@ 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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class GalaxySpaceHelper {
|
||||
private static final Field GSSpaceField;
|
||||
|
||||
static {
|
||||
Class<?> clazz;
|
||||
try {
|
||||
|
||||
+51
-5
@@ -1,13 +1,59 @@
|
||||
package com.falsepattern.endlessids.mixin.helpers;
|
||||
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
|
||||
public interface IExtendedBlockStorageMixin {
|
||||
void setBlockRefCount(int value);
|
||||
byte[] getB1();
|
||||
|
||||
void setTickRefCount(int value);
|
||||
void setB1(byte[] data);
|
||||
|
||||
short[] getLSB();
|
||||
NibbleArray getB2Low();
|
||||
|
||||
byte[] getMSB();
|
||||
void setB2Low(NibbleArray data);
|
||||
|
||||
short[] getMetaArray();
|
||||
void clearB2Low();
|
||||
|
||||
NibbleArray createB2Low();
|
||||
|
||||
NibbleArray getB2High();
|
||||
|
||||
void setB2High(NibbleArray data);
|
||||
|
||||
void clearB2High();
|
||||
|
||||
NibbleArray createB2High();
|
||||
|
||||
byte[] getB3();
|
||||
|
||||
void setB3(byte[] data);
|
||||
|
||||
void clearB3();
|
||||
|
||||
byte[] createB3();
|
||||
|
||||
int getEBSMask();
|
||||
|
||||
int getEBSMSBMask();
|
||||
|
||||
int getID(int x, int y, int z);
|
||||
|
||||
NibbleArray getM1Low();
|
||||
|
||||
void setM1Low(NibbleArray m1Low);
|
||||
|
||||
NibbleArray getM1High();
|
||||
|
||||
void setM1High(NibbleArray m1High);
|
||||
|
||||
void clearM1High();
|
||||
|
||||
NibbleArray createM1High();
|
||||
|
||||
byte[] getM2();
|
||||
|
||||
void setM2(byte[] m2);
|
||||
|
||||
void clearM2();
|
||||
|
||||
byte[] createM2();
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public final class ShortUtil {
|
||||
public static int[] unsignedShortToIntArray(short[] shorts) {
|
||||
int[] ints = new int[shorts.length];
|
||||
|
||||
for(int i = 0; i < shorts.length; ++i) {
|
||||
for (int i = 0; i < shorts.length; ++i) {
|
||||
ints[i] = unsignedShortToInt(shorts[i]);
|
||||
}
|
||||
|
||||
|
||||
-48
@@ -1,48 +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;
|
||||
}
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.client.blockitem.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.Hooks;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
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.CallbackInfo;
|
||||
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;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@Mixin(Chunk.class)
|
||||
public abstract class ChunkMixin {
|
||||
@Shadow
|
||||
private ExtendedBlockStorage[] storageArrays;
|
||||
|
||||
//This is needed because the array is not a field, but a local, and local arraylength overriding does not exist
|
||||
private static byte[] fakeArray;
|
||||
|
||||
@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) {
|
||||
Hooks.setBlockData((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k);
|
||||
}
|
||||
|
||||
@Redirect(method = "fillChunk",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
|
||||
require = 1)
|
||||
private byte[] fakeLSBArray(ExtendedBlockStorage instance) {
|
||||
return fakeArray != null ? fakeArray : (fakeArray = new byte[16 * 16 * 16 * ExtendedConstants.bytesPerID]);
|
||||
}
|
||||
|
||||
@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) {
|
||||
Hooks.setBlockMeta((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k);
|
||||
}
|
||||
|
||||
private static NibbleArray fakeNarray;
|
||||
|
||||
@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) {
|
||||
return fakeNarray != null ? fakeNarray : (fakeNarray = new NibbleArray(null, 0));
|
||||
}
|
||||
|
||||
@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 * (ExtendedConstants.nibblesPerMetadata >>> 1);
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -44,7 +44,8 @@ public abstract class NetHandlerPlayClientMixin {
|
||||
int y = pos & 255;
|
||||
this.clientWorldController.func_147492_c(x + chunkX, y, z + chunkZ, Block.getBlockById(id), meta);
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,7 @@ public abstract class NetHandlerPlayClientMixin {
|
||||
at = @At("HEAD"),
|
||||
require = 1)
|
||||
private void grabID(S1DPacketEntityEffect packetIn, CallbackInfo ci) {
|
||||
theID = ((IS1DPacketEntityEffectMixin)packetIn).getIDExtended();
|
||||
theID = ((IS1DPacketEntityEffectMixin) packetIn).getIDExtended();
|
||||
}
|
||||
|
||||
@Redirect(method = "handleEntityEffect",
|
||||
|
||||
+1
-2
@@ -56,8 +56,7 @@ public abstract class BiomesManagerMixin {
|
||||
}
|
||||
|
||||
@ModifyConstant(method = {"preinit", "setUpBiomesFolder"},
|
||||
constant = {@Constant(stringValue = "\\biomes"),
|
||||
@Constant(stringValue = "\\main.cfg")})
|
||||
constant = {@Constant(stringValue = "\\biomes"), @Constant(stringValue = "\\main.cfg")})
|
||||
private static String fixPaths(String original) {
|
||||
return AIDCStringFixer.fixString(original);
|
||||
}
|
||||
|
||||
+19
-19
@@ -44,25 +44,6 @@ public abstract class AbyssalCraftMixin {
|
||||
@Shadow
|
||||
public static int configBiomeId13;
|
||||
|
||||
@Inject(method = "checkBiomeIds",
|
||||
at = @At("HEAD"),
|
||||
require = 1)
|
||||
private void cleanupBiomeArrayForAssignment(CallbackInfo ci) {
|
||||
val bga = BiomeGenBase.getBiomeGenArray();
|
||||
|
||||
int[] biomes = new int[]{configBiomeId1, configBiomeId2, configBiomeId3, configBiomeId4, configBiomeId5,
|
||||
configBiomeId6, configBiomeId7, configBiomeId8, configBiomeId9, configBiomeId10,
|
||||
configBiomeId11, configBiomeId12, configBiomeId13};
|
||||
for (val biome : biomes) {
|
||||
if (biome < 0 || biome >= ExtendedConstants.biomeIDCount) {
|
||||
continue;
|
||||
}
|
||||
if (bga[biome] instanceof PlaceholderBiome) {
|
||||
bga[biome] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "syncConfig",
|
||||
constant = {@Constant(intValue = 100, ordinal = 0),
|
||||
@Constant(intValue = 101, ordinal = 0),
|
||||
@@ -81,4 +62,23 @@ public abstract class AbyssalCraftMixin {
|
||||
private static int shiftBiomeIDsUp(int constant) {
|
||||
return constant + 8000;
|
||||
}
|
||||
|
||||
@Inject(method = "checkBiomeIds",
|
||||
at = @At("HEAD"),
|
||||
require = 1)
|
||||
private void cleanupBiomeArrayForAssignment(CallbackInfo ci) {
|
||||
val bga = BiomeGenBase.getBiomeGenArray();
|
||||
|
||||
int[] biomes = new int[]{configBiomeId1, configBiomeId2, configBiomeId3, configBiomeId4, configBiomeId5,
|
||||
configBiomeId6, configBiomeId7, configBiomeId8, configBiomeId9, configBiomeId10,
|
||||
configBiomeId11, configBiomeId12, configBiomeId13};
|
||||
for (val biome : biomes) {
|
||||
if (biome < 0 || biome >= ExtendedConstants.biomeIDCount) {
|
||||
continue;
|
||||
}
|
||||
if (bga[biome] instanceof PlaceholderBiome) {
|
||||
bga[biome] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,6 +16,8 @@ import net.minecraft.world.chunk.Chunk;
|
||||
@Mixin(value = BiomeDetectorBase.class,
|
||||
remap = false)
|
||||
public abstract class BiomeDetectorBaseMixin {
|
||||
private Chunk chunk;
|
||||
|
||||
@ModifyConstant(method = "<clinit>",
|
||||
constant = @Constant(intValue = VanillaConstants.biomeIDCount),
|
||||
require = 2)
|
||||
@@ -23,8 +25,6 @@ public abstract class BiomeDetectorBaseMixin {
|
||||
return ExtendedConstants.biomeIDCount;
|
||||
}
|
||||
|
||||
private Chunk chunk;
|
||||
|
||||
@Redirect(method = "getBiomeID",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B",
|
||||
@@ -41,7 +41,7 @@ public abstract class BiomeDetectorBaseMixin {
|
||||
require = 1)
|
||||
private int[] biomeIDs(byte[] i) {
|
||||
try {
|
||||
return ShortUtil.unsignedShortToIntArray(((IChunkMixin)chunk).getBiomeShortArray());
|
||||
return ShortUtil.unsignedShortToIntArray(((IChunkMixin) chunk).getBiomeShortArray());
|
||||
} finally {
|
||||
chunk = null;
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public abstract class BiomeDetectorNetherMixin {
|
||||
require = 1)
|
||||
private int[] biomeIDs(byte[] i) {
|
||||
try {
|
||||
return ShortUtil.unsignedShortToIntArray(((IChunkMixin)chunk).getBiomeShortArray());
|
||||
return ShortUtil.unsignedShortToIntArray(((IChunkMixin) chunk).getBiomeShortArray());
|
||||
} finally {
|
||||
chunk = null;
|
||||
}
|
||||
|
||||
+8
-8
@@ -30,14 +30,6 @@ public abstract class BiomeEventHandlerMixin {
|
||||
return ExtendedConstants.biomeIDCount;
|
||||
}
|
||||
|
||||
@Inject(method = "<init>",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void extendIDs2(CallbackInfo ci) {
|
||||
colorCache = new int[ExtendedConstants.biomeIDCount * 3];
|
||||
Arrays.fill(colorCache, -2);
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "onGetFoliageColor",
|
||||
constant = @Constant(intValue = VanillaConstants.biomeIDCount),
|
||||
require = 1)
|
||||
@@ -51,4 +43,12 @@ public abstract class BiomeEventHandlerMixin {
|
||||
private static int extendIDs4(int constant) {
|
||||
return ExtendedConstants.biomeIDCount * 2;
|
||||
}
|
||||
|
||||
@Inject(method = "<init>",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void extendIDs2(CallbackInfo ci) {
|
||||
colorCache = new int[ExtendedConstants.biomeIDCount * 3];
|
||||
Arrays.fill(colorCache, -2);
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -42,17 +42,17 @@ public abstract class BiomeWandItemMixin {
|
||||
int relBlockX = blockX & 15;
|
||||
int relBlockZ = blockZ & 15;
|
||||
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
||||
short biome = ((IChunkMixin)chunk).getBiomeShortArray()[relBlockZ * 16 + relBlockX];
|
||||
short biome = ((IChunkMixin) chunk).getBiomeShortArray()[relBlockZ * 16 + relBlockX];
|
||||
tag.setShort("sampledBiomeS", biome);
|
||||
} else {
|
||||
short biome = tag.getShort("sampledBiomeS");
|
||||
|
||||
for(int ix = blockX - 3; ix <= blockX + 3; ++ix) {
|
||||
for(int iz = blockZ - 3; iz <= blockZ + 3; ++iz) {
|
||||
for (int ix = blockX - 3; ix <= blockX + 3; ++ix) {
|
||||
for (int iz = blockZ - 3; iz <= blockZ + 3; ++iz) {
|
||||
int relBlockX = ix & 15;
|
||||
int relBlockZ = iz & 15;
|
||||
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
||||
((IChunkMixin)chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
|
||||
((IChunkMixin) chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
|
||||
chunk.isModified = true;
|
||||
BiomeWandMod.proxy.updateRendererAt(ix, iz);
|
||||
}
|
||||
@@ -96,12 +96,12 @@ public abstract class BiomeWandItemMixin {
|
||||
*/
|
||||
@Overwrite
|
||||
public void getSubItems(Item item, CreativeTabs tabs, List list) {
|
||||
list.add(new ItemStack((BiomeWandItem)(Object)this, 1));
|
||||
list.add(new ItemStack((BiomeWandItem) (Object) this, 1));
|
||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
|
||||
if (biome != null && !(biome instanceof PlaceholderBiome)) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setShort("sampledBiomeS", (short) biome.biomeID);
|
||||
ItemStack wand = new ItemStack((BiomeWandItem)(Object)this, 1);
|
||||
ItemStack wand = new ItemStack((BiomeWandItem) (Object) this, 1);
|
||||
wand.setTagCompound(compound);
|
||||
list.add(wand);
|
||||
}
|
||||
|
||||
+10
-8
@@ -27,10 +27,10 @@ public abstract class CubeToolsMixin {
|
||||
WorldServer machineWorld = MinecraftServer.getServer().worldServerForDimension(ConfigurationHandler.dimensionId);
|
||||
Chunk chunk = machineWorld.getChunkFromBlockCoords(coords * ConfigurationHandler.cubeDistance, 0);
|
||||
if (chunk != null && chunk.isChunkLoaded) {
|
||||
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
for(int x = 0; x < 15; ++x) {
|
||||
for(int z = 0; z < 15; ++z) {
|
||||
biomeArray[z << 4 | x] = (short)biome.biomeID;
|
||||
short[] biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
for (int x = 0; x < 15; ++x) {
|
||||
for (int z = 0; z < 15; ++z) {
|
||||
biomeArray[z << 4 | x] = (short) biome.biomeID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,10 +43,12 @@ public abstract class CubeToolsMixin {
|
||||
*/
|
||||
@Overwrite
|
||||
public static BiomeGenBase getMachineBiome(TileEntityMachine machine) {
|
||||
short[] biomeArray = ((IChunkMixin)machine.getWorldObj().getChunkFromBlockCoords(machine.xCoord, machine.zCoord)).getBiomeShortArray();
|
||||
short[] biomeArray = ((IChunkMixin) machine.getWorldObj()
|
||||
.getChunkFromBlockCoords(machine.xCoord,
|
||||
machine.zCoord)).getBiomeShortArray();
|
||||
int biomeId = biomeArray[(machine.zCoord & 15) << 4 | machine.xCoord & 15];
|
||||
return biomeId > 0 && biomeId < BiomeGenBase.getBiomeGenArray().length && BiomeDictionary.isBiomeRegistered(biomeId)
|
||||
? BiomeGenBase.getBiome(biomeId)
|
||||
: WorldUtils.getBiomeByName(ConfigurationHandler.defaultBiome);
|
||||
return biomeId > 0 && biomeId < BiomeGenBase.getBiomeGenArray().length &&
|
||||
BiomeDictionary.isBiomeRegistered(biomeId) ? BiomeGenBase.getBiome(biomeId) : WorldUtils.getBiomeByName(
|
||||
ConfigurationHandler.defaultBiome);
|
||||
}
|
||||
}
|
||||
+33
@@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -13,13 +13,14 @@ import net.minecraft.world.chunk.Chunk;
|
||||
remap = false)
|
||||
public abstract class ReikaChunkHelperMixin {
|
||||
private static short[] biomeArray;
|
||||
|
||||
@Redirect(method = "copyChunk",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V",
|
||||
remap = true),
|
||||
require = 1)
|
||||
private static void customSet(Chunk chunk, byte[] p_76616_1_) {
|
||||
((IChunkMixin)chunk).setBiomeShortArray(biomeArray);
|
||||
((IChunkMixin) chunk).setBiomeShortArray(biomeArray);
|
||||
biomeArray = null;
|
||||
}
|
||||
|
||||
@@ -29,7 +30,7 @@ public abstract class ReikaChunkHelperMixin {
|
||||
remap = true),
|
||||
require = 1)
|
||||
private static byte[] customGet(Chunk chunk) {
|
||||
biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
return EndlessIDs.ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER;
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -18,6 +18,8 @@ import net.minecraft.world.chunk.Chunk;
|
||||
@Mixin(value = ReikaWorldHelper.class,
|
||||
remap = false)
|
||||
public abstract class ReikaWorldHelperMixin {
|
||||
private static int fromBiomeID;
|
||||
|
||||
@Redirect(method = {"setBiomeForXZ", "setBiomeAndBlocksForXZ"},
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B",
|
||||
@@ -42,20 +44,18 @@ 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) {
|
||||
((IChunkMixin)ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||
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;
|
||||
}
|
||||
|
||||
private static int fromBiomeID;
|
||||
|
||||
@Inject(method = "setBiomeAndBlocksForXZ",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/world/biome/BiomeGenBase;biomeList:[Lnet/minecraft/world/biome/BiomeGenBase;",
|
||||
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) {
|
||||
fromBiomeID = ((IChunkMixin)ch).getBiomeShortArray()[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];
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "setBiomeAndBlocksForXZ",
|
||||
@@ -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) {
|
||||
((IChunkMixin)ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||
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;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -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),
|
||||
|
||||
+1
-2
@@ -9,8 +9,7 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
remap = false)
|
||||
public abstract class BiomeConfigurationMixin {
|
||||
@ModifyConstant(method = "init",
|
||||
constant = {@Constant(intValue = 200),
|
||||
@Constant(intValue = 210)},
|
||||
constant = {@Constant(intValue = 200), @Constant(intValue = 210)},
|
||||
require = 2)
|
||||
private static int shiftBiomeIDsUp(int id) {
|
||||
return id + 3000;
|
||||
|
||||
+2
-2
@@ -40,11 +40,11 @@ public abstract class EndChunkProviderMixin {
|
||||
require = 1)
|
||||
private byte[] setBiomesTweaked(Chunk chunk) {
|
||||
val chunkBiomes = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
for(int k = 0; k < chunkBiomes.length; ++k) {
|
||||
for (int k = 0; k < chunkBiomes.length; ++k) {
|
||||
if (Math.abs(xx) < 160 && Math.abs(zz) < 160) {
|
||||
chunkBiomes[k] = 9;
|
||||
} else {
|
||||
chunkBiomes[k] = (short)this.biomesForGeneration[k].biomeID;
|
||||
chunkBiomes[k] = (short) this.biomesForGeneration[k].biomeID;
|
||||
}
|
||||
}
|
||||
return ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER;
|
||||
|
||||
+3
-2
@@ -71,7 +71,8 @@ public abstract class ModBiomesMixin {
|
||||
constant = @Constant(stringValue = "Erebus biome IDs cannot be higher than 127 or smaller than 0!"),
|
||||
require = 1)
|
||||
private static String modifyWarning(String str) {
|
||||
return "Erebus biome IDs cannot be higher than " + (ExtendedConstants.biomeIDCount - 129) + " or smaller than 0!";
|
||||
return "Erebus biome IDs cannot be higher than " + (ExtendedConstants.biomeIDCount - 129) +
|
||||
" or smaller than 0!";
|
||||
}
|
||||
|
||||
@Inject(method = "init",
|
||||
@@ -84,7 +85,7 @@ public abstract class ModBiomesMixin {
|
||||
ulteriorOutbackID, fungalForestID, submergedSwampID, fieldsSubForestID,
|
||||
jungleSubLakeID, jungleSubAsperGroveID, desertSubCharredForestID,
|
||||
savannahSubRockyWastelandID, savannahSubAsperGroveID, savannahSubSteppeID};
|
||||
for (val biome: biomes) {
|
||||
for (val biome : biomes) {
|
||||
if (biome <= 0 || biome >= ExtendedConstants.biomeIDCount - 129) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+2
-1
@@ -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),
|
||||
|
||||
+1
@@ -16,6 +16,7 @@ public abstract class ConfigManagerCoreMixin {
|
||||
private static int shiftBiomeIDsUp(int id) {
|
||||
return id + 18000;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "syncConfig",
|
||||
constant = @Constant(stringValue = "Biome ID for Moon (Mars will be this + 1, Asteroids + 2 etc). Allowed range 40-250."),
|
||||
require = 1)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -9,8 +9,7 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
remap = false)
|
||||
public abstract class BiomeConfigurationMixin {
|
||||
@ModifyConstant(method = "init",
|
||||
constant = {@Constant(intValue = 170),
|
||||
@Constant(intValue = 175)},
|
||||
constant = {@Constant(intValue = 170), @Constant(intValue = 175)},
|
||||
require = 2)
|
||||
private static int shiftBiomeIDsUp(int id) {
|
||||
return id + 3000;
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ public abstract class TentChunkProviderMixin {
|
||||
require = 1)
|
||||
private void setBiomesTweaked(Chunk chunk, byte[] p_76616_1_) {
|
||||
short[] biomeMap = new short[256];
|
||||
Arrays.fill(biomeMap, (short)BiomeGenBase.ocean.biomeID);
|
||||
((IChunkMixin)chunk).setBiomeShortArray(biomeMap);
|
||||
Arrays.fill(biomeMap, (short) BiomeGenBase.ocean.biomeID);
|
||||
((IChunkMixin) chunk).setBiomeShortArray(biomeMap);
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -28,7 +28,7 @@ public abstract class ItemBiomePainterMixin {
|
||||
} else if (par3World.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
for(int i = 0; i < par2EntityPlayer.inventory.getSizeInventory(); ++i) {
|
||||
for (int i = 0; i < par2EntityPlayer.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack is = par2EntityPlayer.inventory.getStackInSlot(i);
|
||||
if (is != null && is.getItem() instanceof ItemBiomeCapsule && is.getItemDamage() != 0) {
|
||||
NBTTagCompound nbt = is.stackTagCompound;
|
||||
@@ -40,16 +40,18 @@ public abstract class ItemBiomePainterMixin {
|
||||
if (charges > 0 || par2EntityPlayer.capabilities.isCreativeMode) {
|
||||
Chunk c = par3World.getChunkFromBlockCoords(par4, par6);
|
||||
int biomeID = is.getItemDamage() - 1;
|
||||
short[] biomeArray = ((IChunkMixin)c).getBiomeShortArray(); //changed
|
||||
short[] biomeArray = ((IChunkMixin) c).getBiomeShortArray(); //changed
|
||||
if ((biomeArray[(par6 & 15) << 4 | par4 & 15] & 255) != biomeID) {
|
||||
biomeArray[(par6 & 15) << 4 | par4 & 15] = (short)(biomeID & 0xFFFF); //changed
|
||||
((IChunkMixin)c).setBiomeShortArray(biomeArray); //changed
|
||||
biomeArray[(par6 & 15) << 4 | par4 & 15] = (short) (biomeID & 0xFFFF); //changed
|
||||
((IChunkMixin) c).setBiomeShortArray(biomeArray); //changed
|
||||
if (!par2EntityPlayer.capabilities.isCreativeMode) {
|
||||
nbt.setInteger("charges", charges - 1);
|
||||
par2EntityPlayer.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessagePaintBiome(par4, par5, par6, par3World.provider.dimensionId, biomeID), par3World.provider.dimensionId);
|
||||
PacketHandler.INSTANCE.sendToDimension(
|
||||
new MessagePaintBiome(par4, par5, par6, par3World.provider.dimensionId, biomeID),
|
||||
par3World.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-12
@@ -24,15 +24,20 @@ import java.util.Random;
|
||||
remap = false)
|
||||
public abstract class MessagePaintBiomeMixin {
|
||||
|
||||
@Shadow private int posZ;
|
||||
@Shadow
|
||||
private int posZ;
|
||||
|
||||
@Shadow private int posX;
|
||||
@Shadow
|
||||
private int posX;
|
||||
|
||||
@Shadow private int biomeID;
|
||||
@Shadow
|
||||
private int biomeID;
|
||||
|
||||
@Shadow private int dimensionID;
|
||||
@Shadow
|
||||
private int dimensionID;
|
||||
|
||||
@Shadow private int posY;
|
||||
@Shadow
|
||||
private int posY;
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
@@ -44,18 +49,25 @@ public abstract class MessagePaintBiomeMixin {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null && player.worldObj.provider.dimensionId == this.dimensionID) {
|
||||
Chunk c = player.worldObj.getChunkFromBlockCoords(this.posX, this.posZ);
|
||||
short[] biomeArray = ((IChunkMixin)c).getBiomeShortArray(); //changed
|
||||
biomeArray[(this.posZ & 15) << 4 | this.posX & 15] = (short)(this.biomeID & 0xFFFF); //changed
|
||||
((IChunkMixin)c).setBiomeShortArray(biomeArray); //changed
|
||||
Minecraft.getMinecraft().thePlayer.worldObj.markBlocksDirtyVertical(this.posX, this.posZ, 0, player.worldObj.getActualHeight());
|
||||
short[] biomeArray = ((IChunkMixin) c).getBiomeShortArray(); //changed
|
||||
biomeArray[(this.posZ & 15) << 4 | this.posX & 15] = (short) (this.biomeID & 0xFFFF); //changed
|
||||
((IChunkMixin) c).setBiomeShortArray(biomeArray); //changed
|
||||
Minecraft.getMinecraft().thePlayer.worldObj.markBlocksDirtyVertical(this.posX, this.posZ, 0,
|
||||
player.worldObj.getActualHeight());
|
||||
BiomeGenBase biome = BiomeGenBase.getBiome(this.biomeID);
|
||||
int colorInt = ItemBiomeCapsule.getColorForBiome(biome);
|
||||
Random rng = new Random();
|
||||
Color color = new Color(colorInt);
|
||||
|
||||
for(int i = 0; i < 64; ++i) {
|
||||
EntityFX smoke = new EntitySmokeFX(player.worldObj, (float)this.posX + rng.nextFloat(), (float)this.posY + rng.nextFloat(), (float)this.posZ + rng.nextFloat(), 0.0, 0.0, 0.0);
|
||||
smoke.setRBGColorF(0.003921569F * (float)color.getRed(), 0.003921569F * (float)color.getGreen(), 0.003921569F * (float)color.getBlue());
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
EntityFX smoke = new EntitySmokeFX(player.worldObj,
|
||||
(float) this.posX + rng.nextFloat(),
|
||||
(float) this.posY + rng.nextFloat(),
|
||||
(float) this.posZ + rng.nextFloat(),
|
||||
0.0, 0.0, 0.0);
|
||||
smoke.setRBGColorF(0.003921569F * (float) color.getRed(),
|
||||
0.003921569F * (float) color.getGreen(),
|
||||
0.003921569F * (float) color.getBlue());
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(smoke);
|
||||
}
|
||||
}
|
||||
|
||||
+39
@@ -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);
|
||||
}
|
||||
}
|
||||
-65
@@ -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;
|
||||
}
|
||||
}
|
||||
-21
@@ -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());
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
import net.minecraft.network.play.server.S26PacketMapChunkBulk;
|
||||
|
||||
@Mixin(S26PacketMapChunkBulk.class)
|
||||
public abstract class S26PacketMapChunkBulkMixin {
|
||||
|
||||
@ModifyConstant(method = "readPacketData",
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerBiome * 16 * 16),
|
||||
require = 1)
|
||||
private int extend2(int contant) {
|
||||
return ExtendedConstants.bytesPerBiome * 16 * 16;
|
||||
}
|
||||
}
|
||||
+8
-19
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.blockitem.ubc;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import exterminatorJeff.undergroundBiomes.worldGen.BiomeUndergroundDecorator;
|
||||
import exterminatorJeff.undergroundBiomes.worldGen.OreUBifier;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -16,7 +16,7 @@ import java.util.logging.Logger;
|
||||
remap = false)
|
||||
public abstract class BiomeUndergroundDecoratorMixin {
|
||||
private static NibbleArray fakeArray;
|
||||
private ThreadLocal<IExtendedBlockStorageMixin> ebs;
|
||||
private IExtendedBlockStorageMixin ebs;
|
||||
|
||||
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
|
||||
"replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
|
||||
@@ -24,13 +24,10 @@ public abstract class BiomeUndergroundDecoratorMixin {
|
||||
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B",
|
||||
remap = true),
|
||||
require = 2)
|
||||
private byte[] returnMSBasLSB(ExtendedBlockStorage instance) {
|
||||
if (ebs == null) {
|
||||
ebs = new ThreadLocal<>();
|
||||
}
|
||||
private byte[] returnLSB(ExtendedBlockStorage instance) {
|
||||
IExtendedBlockStorageMixin iebs = (IExtendedBlockStorageMixin) instance;
|
||||
ebs.set(iebs);
|
||||
return iebs.getMSB();
|
||||
ebs = iebs;
|
||||
return iebs.getB1();
|
||||
}
|
||||
|
||||
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
|
||||
@@ -50,17 +47,9 @@ public abstract class BiomeUndergroundDecoratorMixin {
|
||||
remap = true),
|
||||
require = 2)
|
||||
private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
|
||||
return ebs.get().getLSB()[y << 8 | z << 4 | x] & 0xFFFF;
|
||||
}
|
||||
|
||||
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
|
||||
"replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
|
||||
at = @At(value = "INVOKE",
|
||||
target = "LexterminatorJeff/undergroundBiomes/worldGen/OreUBifier;blockReplacer(I)LexterminatorJeff/undergroundBiomes/worldGen/OreUBifier$BlockReplacer;"),
|
||||
require = 2)
|
||||
private OreUBifier.BlockReplacer reshuffleID(OreUBifier instance, int blockID) {
|
||||
blockID = ((blockID & 0xFF) << 16) | ((blockID & 0xFFFF00) >>> 8);
|
||||
return instance.blockReplacer(blockID);
|
||||
val id = ebs.getID(x, y, z) >>> 8;
|
||||
ebs = null;
|
||||
return id;
|
||||
}
|
||||
|
||||
@Redirect(method = "correctBiomeDecorators",
|
||||
|
||||
-138
@@ -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;
|
||||
}
|
||||
}
|
||||
+240
-66
@@ -3,9 +3,10 @@ package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import com.falsepattern.endlessids.Hooks;
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import lombok.val;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import lombok.var;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -26,61 +27,59 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
private int blockRefCount;
|
||||
@Shadow
|
||||
private int tickRefCount;
|
||||
@Shadow private byte[] blockLSBArray;
|
||||
@Shadow private NibbleArray blockMetadataArray;
|
||||
private short[] lsbArray;
|
||||
private byte[] msbArray;
|
||||
private short[] metaArray;
|
||||
|
||||
@Override
|
||||
public void setBlockRefCount(int value) {
|
||||
blockRefCount = value;
|
||||
}
|
||||
@Shadow
|
||||
private byte[] blockLSBArray;
|
||||
@Shadow
|
||||
private NibbleArray blockMSBArray;
|
||||
private NibbleArray b2High;
|
||||
private byte[] b3;
|
||||
|
||||
@Override
|
||||
public void setTickRefCount(int value) {
|
||||
tickRefCount = value;
|
||||
}
|
||||
@Shadow
|
||||
private NibbleArray blockMetadataArray;
|
||||
private NibbleArray m1High;
|
||||
private byte[] m2;
|
||||
|
||||
@Override
|
||||
public short[] getLSB() {
|
||||
return lsbArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getMSB() {
|
||||
return msbArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[] getMetaArray() {
|
||||
return metaArray;
|
||||
}
|
||||
|
||||
@Inject(method = "<init>",
|
||||
at = @At(value = "RETURN"),
|
||||
require = 1)
|
||||
private void init(CallbackInfo ci) {
|
||||
blockLSBArray = null;
|
||||
blockMetadataArray = null;
|
||||
lsbArray = new short[16 * 16 * 16];
|
||||
msbArray = new byte[16 * 16 * 16];
|
||||
metaArray = new short[16 * 16 * 16];
|
||||
}
|
||||
|
||||
private int getID(int x, int y, int z) {
|
||||
public int getID(int x, int y, int z) {
|
||||
int index = y << 8 | z << 4 | x;
|
||||
int lsb = lsbArray[index] & 0xFFFF;
|
||||
int msb = (msbArray[index] & 0xFF) << 16;
|
||||
return lsb | msb;
|
||||
int id = blockLSBArray[index] & 0xFF;
|
||||
if (blockMSBArray != null) {
|
||||
id |= blockMSBArray.get(x, y, z) << 8;
|
||||
if (b2High != null) {
|
||||
id |= b2High.get(x, y, z) << 12;
|
||||
if (b3 != null) {
|
||||
id |= (b3[index] & 0xFF) << 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
private void setID(int x, int y, int z, int id) {
|
||||
int index = y << 8 | z << 4 | x;
|
||||
int lsb = id & 0xFFFF;
|
||||
int msb = (id >>> 16) & 0xFF;
|
||||
lsbArray[index] = (short) lsb;
|
||||
msbArray[index] = (byte) msb;
|
||||
blockLSBArray[index] = (byte) (id & 0xFF);
|
||||
if (id > 0xFF) {
|
||||
if (blockMSBArray == null) {
|
||||
createB2Low();
|
||||
}
|
||||
if (id > 0xFFF) {
|
||||
if (b2High == null) {
|
||||
createB2High();
|
||||
}
|
||||
if (id > 0xFFFF && b3 == null) {
|
||||
createB3();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blockMSBArray != null) {
|
||||
blockMSBArray.set(x, y, z, (id >>> 8) & 0xF);
|
||||
if (b2High != null) {
|
||||
b2High.set(x, y, z, (id >>> 12) & 0xF);
|
||||
if (b3 != null) {
|
||||
b3[index] = (byte) ((id >>> 16) & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,8 +122,14 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
*/
|
||||
@Overwrite
|
||||
public int getExtBlockMetadata(int x, int y, int z) {
|
||||
int index = y << 8 | z << 4 | x;
|
||||
return metaArray[index] & 0xFFFF;
|
||||
int meta = blockMetadataArray.get(x, y, z);
|
||||
if (m1High != null) {
|
||||
meta |= m1High.get(x, y, z) << 4;
|
||||
if (m2 != null) {
|
||||
meta |= (m2[(y << 8) | (z << 4) | x] & 0xFF) << 8;
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,17 +138,34 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
*/
|
||||
@Overwrite
|
||||
public void setExtBlockMetadata(int x, int y, int z, int meta) {
|
||||
int index = y << 8 | z << 4 | x;
|
||||
metaArray[index] = (short)(meta & 0xFFFF);
|
||||
blockMetadataArray.set(x, y, z, meta & 0xF);
|
||||
if (meta > 0xF) {
|
||||
if (m1High == null) {
|
||||
createM1High();
|
||||
}
|
||||
if (meta > 0xFF && m2 == null) {
|
||||
createM2();
|
||||
}
|
||||
}
|
||||
if (m1High != null) {
|
||||
m1High.set(x, y, z, (meta >>> 4) & 0xF);
|
||||
if (m2 != null) {
|
||||
m2[(y << 8) | (z << 4) | x] = (byte) ((meta >>> 8) & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Direct port from dumped code
|
||||
*/
|
||||
@Overwrite
|
||||
public void removeInvalidBlocks() {
|
||||
Hooks.removeInvalidBlocksHook(this);
|
||||
@Redirect(method = "removeInvalidBlocks",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockByExtId(III)Lnet/minecraft/block/Block;"),
|
||||
require = 1)
|
||||
private Block removeInvalidBlocks(ExtendedBlockStorage instance, int x, int y, int z) {
|
||||
var block = instance.getBlockByExtId(x, y, z);
|
||||
if (block == null && GeneralConfig.removeInvalidBlocks) {
|
||||
instance.func_150818_a(x, y, z, Blocks.air);
|
||||
block = Blocks.air;
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
private UnsupportedOperationException emergencyCrash() {
|
||||
@@ -154,44 +176,196 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
return new UnsupportedOperationException(crashMSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getB1() {
|
||||
return blockLSBArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setB1(byte[] data) {
|
||||
blockLSBArray = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray getB2Low() {
|
||||
return blockMSBArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setB2Low(NibbleArray data) {
|
||||
blockMSBArray = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB2Low() {
|
||||
blockMSBArray = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createB2Low() {
|
||||
return (blockMSBArray = new NibbleArray(blockLSBArray.length, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray getB2High() {
|
||||
return b2High;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setB2High(NibbleArray data) {
|
||||
b2High = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB2High() {
|
||||
b2High = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createB2High() {
|
||||
return (b2High = new NibbleArray(blockLSBArray.length, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getB3() {
|
||||
return b3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setB3(byte[] data) {
|
||||
b3 = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB3() {
|
||||
b3 = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createB3() {
|
||||
return b3 = new byte[blockLSBArray.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray getM1Low() {
|
||||
return blockMetadataArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setM1Low(NibbleArray m1Low) {
|
||||
blockMetadataArray = m1Low;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray getM1High() {
|
||||
return m1High;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setM1High(NibbleArray m1High) {
|
||||
this.m1High = m1High;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearM1High() {
|
||||
m1High = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createM1High() {
|
||||
return (m1High = new NibbleArray(blockLSBArray.length, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getM2() {
|
||||
return m2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setM2(byte[] m2) {
|
||||
this.m2 = m2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearM2() {
|
||||
m2 = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createM2() {
|
||||
return (m2 = new byte[blockLSBArray.length]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEBSMSBMask() {
|
||||
if (blockMSBArray == null) {
|
||||
return 0b00;
|
||||
}
|
||||
if (b2High == null) {
|
||||
return 0b01;
|
||||
}
|
||||
if (b3 == null) {
|
||||
return 0b10;
|
||||
}
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEBSMask() {
|
||||
if (m1High == null) {
|
||||
return 0b01;
|
||||
}
|
||||
if (m2 == null) {
|
||||
return 0b10;
|
||||
}
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
@Inject(method = {"getBlockMSBArray", "createBlockMSBArray"},
|
||||
at = @At("HEAD"))
|
||||
at = @At("HEAD"),
|
||||
expect = 0)
|
||||
private void crashMSBArray(CallbackInfoReturnable<NibbleArray> cir) {
|
||||
throw emergencyCrash();
|
||||
}
|
||||
|
||||
@Inject(method = "clearMSBArray",
|
||||
at = @At("HEAD"))
|
||||
at = @At("HEAD"),
|
||||
expect = 0)
|
||||
private void crashMSBArray(CallbackInfo ci) {
|
||||
throw emergencyCrash();
|
||||
}
|
||||
|
||||
@Inject(method = "setBlockMSBArray",
|
||||
at = @At("HEAD"))
|
||||
at = @At("HEAD"),
|
||||
expect = 0)
|
||||
private void crashMSBArray(NibbleArray p_76673_1_, CallbackInfo ci) {
|
||||
throw emergencyCrash();
|
||||
}
|
||||
|
||||
@Inject(method = "setBlockLSBArray",
|
||||
at = @At("HEAD"))
|
||||
at = @At("HEAD"),
|
||||
expect = 0)
|
||||
private void crashLSBArray(byte[] p_76664_1_, CallbackInfo ci) {
|
||||
throw emergencyCrash();
|
||||
}
|
||||
|
||||
@Inject(method = "getBlockLSBArray",
|
||||
at = @At("HEAD"))
|
||||
at = @At("HEAD"),
|
||||
expect = 0)
|
||||
private void crashLSBArray(CallbackInfoReturnable<byte[]> cir) {
|
||||
throw emergencyCrash();
|
||||
}
|
||||
|
||||
@Inject(method = "setBlockMetadataArray",
|
||||
at = @At("HEAD"))
|
||||
at = @At("HEAD"),
|
||||
expect = 0)
|
||||
private void crashMetadataArray(NibbleArray p_76668_1_, CallbackInfo ci) {
|
||||
throw emergencyCrash();
|
||||
}
|
||||
|
||||
@Inject(method = "getMetadataArray",
|
||||
at = @At("HEAD"))
|
||||
at = @At("HEAD"),
|
||||
expect = 0)
|
||||
private void crashMetadataArray(CallbackInfoReturnable<NibbleArray> cir) {
|
||||
throw emergencyCrash();
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import com.falsepattern.endlessids.Hooks;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
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.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.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 {
|
||||
@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) {
|
||||
Hooks.getBlockData((IExtendedBlockStorageMixin) aextendedblockstorage[l], abyte, j);
|
||||
}
|
||||
|
||||
private static byte[] fakeArray;
|
||||
@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) {
|
||||
return fakeArray != null ? fakeArray : (fakeArray = new byte[16 * 16 * 16 * ExtendedConstants.bytesPerID]);
|
||||
}
|
||||
|
||||
@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) {
|
||||
Hooks.getBlockMeta((IExtendedBlockStorageMixin) aextendedblockstorage[l], abyte, j);
|
||||
}
|
||||
|
||||
private static NibbleArray fakeNarray;
|
||||
|
||||
@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) {
|
||||
return fakeNarray != null ? fakeNarray : (fakeNarray = new NibbleArray(null, 0));
|
||||
}
|
||||
|
||||
@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 * (ExtendedConstants.nibblesPerMetadata >>> 1);
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "readPacketData",
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerEBS),
|
||||
require = 1)
|
||||
private int increaseReadSize(int constant) {
|
||||
return ExtendedConstants.bytesPerEBS;
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
import net.minecraft.network.play.server.S26PacketMapChunkBulk;
|
||||
|
||||
@Mixin(S26PacketMapChunkBulk.class)
|
||||
public abstract class S26PacketMapChunkBulkMixin {
|
||||
@ModifyConstant(method = "readPacketData",
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerIDPlusMetadata * 16 * 16 * 16),
|
||||
require = 1)
|
||||
private int extend1(int constant) {
|
||||
return ExtendedConstants.bytesPerIDPlusMetadata * 16 * 16 * 16;
|
||||
}
|
||||
}
|
||||
+9
-2
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -9,7 +9,8 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
@Mixin(value = BaseBlock.class,
|
||||
remap = false)
|
||||
public abstract class BaseBlockMixin {
|
||||
@Shadow private short data;
|
||||
@Shadow
|
||||
private short data;
|
||||
private int idExtended;
|
||||
|
||||
/**
|
||||
@@ -58,7 +59,7 @@ public abstract class BaseBlockMixin {
|
||||
} else if (data < -1) {
|
||||
throw new IllegalArgumentException("Can't have a block data value below -1");
|
||||
} else {
|
||||
this.data = (short)data;
|
||||
this.data = (short) data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+30
-26
@@ -13,32 +13,6 @@ import net.minecraft.potion.PotionEffect;
|
||||
|
||||
@Mixin(value = PotionEffect.class)
|
||||
public abstract class PotionEffectMixin {
|
||||
@Shadow public abstract int getPotionID();
|
||||
|
||||
@Shadow public abstract int getAmplifier();
|
||||
|
||||
@Shadow public abstract int getDuration();
|
||||
|
||||
@Shadow public abstract boolean getIsAmbient();
|
||||
|
||||
@Inject(method = "writeCustomPotionEffectToNBT",
|
||||
at = @At(value = "HEAD"),
|
||||
cancellable = true,
|
||||
require = 1)
|
||||
private void writeCustomPotionEffectToNBTExtended(NBTTagCompound nbt, CallbackInfoReturnable<NBTTagCompound> cir) {
|
||||
val potionID = getPotionID();
|
||||
if (potionID > 127) {
|
||||
nbt.setInteger("IdExtended", potionID);
|
||||
nbt.setByte("Id", (byte)-1);
|
||||
} else {
|
||||
nbt.setByte("Id", (byte)potionID);
|
||||
}
|
||||
nbt.setByte("Amplifier", (byte)this.getAmplifier());
|
||||
nbt.setInteger("Duration", this.getDuration());
|
||||
nbt.setBoolean("Ambient", this.getIsAmbient());
|
||||
cir.setReturnValue(nbt);
|
||||
}
|
||||
|
||||
@Inject(method = "readCustomPotionEffectFromNBT",
|
||||
at = @At(value = "HEAD"),
|
||||
cancellable = true,
|
||||
@@ -60,4 +34,34 @@ public abstract class PotionEffectMixin {
|
||||
cir.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public abstract int getPotionID();
|
||||
|
||||
@Shadow
|
||||
public abstract int getAmplifier();
|
||||
|
||||
@Shadow
|
||||
public abstract int getDuration();
|
||||
|
||||
@Shadow
|
||||
public abstract boolean getIsAmbient();
|
||||
|
||||
@Inject(method = "writeCustomPotionEffectToNBT",
|
||||
at = @At(value = "HEAD"),
|
||||
cancellable = true,
|
||||
require = 1)
|
||||
private void writeCustomPotionEffectToNBTExtended(NBTTagCompound nbt, CallbackInfoReturnable<NBTTagCompound> cir) {
|
||||
val potionID = getPotionID();
|
||||
if (potionID > 127) {
|
||||
nbt.setInteger("IdExtended", potionID);
|
||||
nbt.setByte("Id", (byte) -1);
|
||||
} else {
|
||||
nbt.setByte("Id", (byte) potionID);
|
||||
}
|
||||
nbt.setByte("Amplifier", (byte) this.getAmplifier());
|
||||
nbt.setInteger("Duration", this.getDuration());
|
||||
nbt.setBoolean("Ambient", this.getIsAmbient());
|
||||
cir.setReturnValue(nbt);
|
||||
}
|
||||
}
|
||||
-1
@@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
+8
-8
@@ -18,7 +18,7 @@ public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffe
|
||||
|
||||
@WrapOperation(method = "<init>(ILnet/minecraft/potion/PotionEffect;)V",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/potion/PotionEffect;getPotionID()I"),
|
||||
target = "Lnet/minecraft/potion/PotionEffect;getPotionID()I"),
|
||||
require = 1)
|
||||
private int getPotionID(PotionEffect effect, Operation<Integer> original) {
|
||||
idExtended = original.call(effect);
|
||||
@@ -26,10 +26,10 @@ public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffe
|
||||
}
|
||||
|
||||
@Redirect(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private byte networkReadPacketData(PacketBuffer instance) {
|
||||
idExtended = instance.readInt();
|
||||
return -1;
|
||||
@@ -44,9 +44,9 @@ public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffe
|
||||
instance.writeInt(idExtended);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIDExtended() {
|
||||
|
||||
@Override
|
||||
public int getIDExtended() {
|
||||
return this.idExtended;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -13,7 +13,8 @@ import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect;
|
||||
|
||||
@Mixin(S1EPacketRemoveEntityEffect.class)
|
||||
public abstract class S1EPacketRemoveEntityEffectMixin {
|
||||
@Shadow private int field_149078_b;
|
||||
@Shadow
|
||||
private int field_149078_b;
|
||||
|
||||
@Redirect(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.Hooks;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
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.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.network.play.server.S21PacketChunkData;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
@Mixin(S21PacketChunkData.class)
|
||||
public abstract class S21PacketChunkDataMixin {
|
||||
@ModifyConstant(method = {"<clinit>", "func_149275_c"},
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerChunk),
|
||||
require = 1)
|
||||
private static int increasePacketSize(int constant) {
|
||||
return ExtendedConstants.bytesPerChunk;
|
||||
}
|
||||
}
|
||||
@@ -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,9 +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"),
|
||||
//endregion vanilla
|
||||
//region AntiIDConflict
|
||||
AIDCAntiIdConflictBaseMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.AntiIdConflictBaseMixin"),
|
||||
AIDCBiomesGenBasePlaceholderMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.BiomeGenBasePlaceholderMixin"),
|
||||
@@ -31,14 +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"),
|
||||
S26PacketMapChunkBulkMixinBiome(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.S26PacketMapChunkBulkMixin"),
|
||||
//endregion vanilla
|
||||
//region AbyssalCraft
|
||||
AbyssalCraftMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.ABYSSALCRAFT)), "biome.abyssalcraft.AbyssalCraftMixin"),
|
||||
@@ -67,7 +60,7 @@ public enum Mixin implements IMixin {
|
||||
BOPBiomesMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.BOP)), "biome.bop.BOPBiomesMixin"),
|
||||
//endregion BoP
|
||||
//region Buildcraft
|
||||
BuildcraftEnergyMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.BUILDCRAFT)), "buildcraft.BuildcraftEnergyMixin"),
|
||||
BuildcraftEnergyMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.BUILDCRAFT)), "biome.buildcraft.BuildcraftEnergyMixin"),
|
||||
//endregion Buildcraft
|
||||
//region CompactMachines
|
||||
CMCubeToolsMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.COMPACTMACHINES)), "biome.compactmachines.CubeToolsMixin"),
|
||||
@@ -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,16 +166,13 @@ 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"),
|
||||
S26PacketMapChunkBulkMixinBlockItem(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.S26PacketMapChunkBulkMixin"),
|
||||
StatListMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.StatListMixin"),
|
||||
WorldMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.WorldMixin"),
|
||||
//endregion vanilla
|
||||
@@ -220,16 +219,12 @@ public enum Mixin implements IMixin {
|
||||
|
||||
//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")),
|
||||
|
||||
+4
-4
@@ -3,10 +3,10 @@ package com.falsepattern.endlessids.mixin.stubpackage.org.dave.CompactMachines.t
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityMachine {
|
||||
public World getWorldObj()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public int xCoord;
|
||||
public int zCoord;
|
||||
|
||||
public World getWorldObj() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class CommonManager {
|
||||
}
|
||||
|
||||
private void runPatches(String stageName, Stage stage) throws Exception {
|
||||
for (val patch: patches) {
|
||||
for (val patch : patches) {
|
||||
if (Loader.isModLoaded(patch.modid)) {
|
||||
try {
|
||||
if (stage.run(patch)) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user