mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-24 10:34:29 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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>
|
||||
@@ -5,136 +5,179 @@ import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
|
||||
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 int getBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset) {
|
||||
val b1 = ebs.getB1();
|
||||
System.arraycopy(b1, 0, data, offset, b1.length);
|
||||
offset += b1.length;
|
||||
val b2Low = ebs.getB2Low();
|
||||
if (b2Low != null) {
|
||||
System.arraycopy(b2Low.data, 0, data, offset, b2Low.data.length);
|
||||
offset += b2Low.data.length;
|
||||
val b2High = ebs.getB2High();
|
||||
if (b2High != null) {
|
||||
System.arraycopy(b2High.data, 0, data, offset, b2High.data.length);
|
||||
offset += b2High.data.length;
|
||||
val b3 = ebs.getB3();
|
||||
if (b3 != null) {
|
||||
System.arraycopy(b3, 0, data, offset, b3.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ebs.getEBSMSBMask();
|
||||
}
|
||||
|
||||
public static void setBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, 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 setBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset, final int storageFlag) {
|
||||
val b1 = ebs.getB1();
|
||||
System.arraycopy(data, offset, b1, 0, b1.length);
|
||||
offset += b1.length;
|
||||
if (storageFlag == 0b00) {
|
||||
ebs.clearB2Low();
|
||||
ebs.clearB2High();
|
||||
ebs.clearB3();
|
||||
return;
|
||||
}
|
||||
var b2Low = ebs.getB2Low();
|
||||
if (b2Low == null) {
|
||||
b2Low = ebs.createB2Low();
|
||||
}
|
||||
System.arraycopy(data, offset, b2Low.data, 0, b2Low.data.length);
|
||||
offset += b2Low.data.length;
|
||||
if (storageFlag == 0b01) {
|
||||
ebs.clearB2High();
|
||||
ebs.clearB3();
|
||||
return;
|
||||
}
|
||||
var b2High = ebs.getB2High();
|
||||
if (b2High == null) {
|
||||
b2High = ebs.createB2High();
|
||||
}
|
||||
System.arraycopy(data, offset, b2High.data, 0, b2High.data.length);
|
||||
offset += b2High.data.length;
|
||||
if (storageFlag == 0b10) {
|
||||
ebs.clearB3();
|
||||
return;
|
||||
}
|
||||
var b3 = ebs.getB3();
|
||||
if (b3 == null) {
|
||||
b3 = ebs.createB3();
|
||||
}
|
||||
System.arraycopy(data, offset, b3, 0, b3.length);
|
||||
}
|
||||
|
||||
public static void writeBlockDataToNBT(final NBTTagCompound nbt, final IExtendedBlockStorageMixin ebs) {
|
||||
val 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;
|
||||
|
||||
val b1 = ebs.getB1();
|
||||
val b2Low = ebs.getB2Low();
|
||||
val b2High = ebs.getB2High();
|
||||
val b3 = ebs.getB3();
|
||||
nbt.setByteArray("Blocks", b1);
|
||||
if (b2Low != null) {
|
||||
nbt.setByteArray("Add", b2Low.data);
|
||||
}
|
||||
nbt.setByteArray("Blocks", byte1Data);
|
||||
if (byte2BottomNibbleData != null) {
|
||||
nbt.setByteArray("Add", byte2BottomNibbleData);
|
||||
if (b2High != null) {
|
||||
nbt.setByteArray("BlocksB2Hi", b2High.data);
|
||||
}
|
||||
if (byte2TopNibbleData != null) {
|
||||
nbt.setByteArray("BlocksB2Hi", byte2TopNibbleData);
|
||||
}
|
||||
if (byte3Data != null) {
|
||||
nbt.setByteArray("BlocksB3", byte3Data);
|
||||
if (b3 != null) {
|
||||
nbt.setByteArray("BlocksB3", b3);
|
||||
}
|
||||
}
|
||||
|
||||
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 b1 = nbt.getByteArray("Blocks");
|
||||
final byte[] b2Low = nbt.hasKey("Add") ? nbt.getByteArray("Add") : null;
|
||||
final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
|
||||
final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
|
||||
|
||||
val lsb = ebs.getLSB();
|
||||
val msb = ebs.getMSB();
|
||||
for (int i = 0; i < lsb.length; i++) {
|
||||
if (byte3Data != null) {
|
||||
msb[i] = byte3Data[i];
|
||||
ebs.setB1(b1);
|
||||
if (b2Low == null) {
|
||||
ebs.clearB2Low();
|
||||
} else {
|
||||
ebs.setB2Low(new NibbleArray(b2Low, 4));
|
||||
}
|
||||
if (b2High == null) {
|
||||
ebs.clearB2High();
|
||||
} else {
|
||||
ebs.setB2High(new NibbleArray(b2High, 4));
|
||||
}
|
||||
ebs.setB3(b3);
|
||||
}
|
||||
|
||||
public static int getBlockMeta(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset) {
|
||||
val m1Low = ebs.getM1Low();
|
||||
System.arraycopy(m1Low.data, 0, data, offset, m1Low.data.length);
|
||||
offset += m1Low.data.length;
|
||||
val m1High = ebs.getM1High();
|
||||
if (m1High != null) {
|
||||
System.arraycopy(m1High.data, 0, data, offset, m1High.data.length);
|
||||
offset += m1High.data.length;
|
||||
val m2 = ebs.getM2();
|
||||
if (m2 != null) {
|
||||
System.arraycopy(m2, 0, data, offset, m2.length);
|
||||
}
|
||||
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;
|
||||
}
|
||||
return ebs.getEBSMask();
|
||||
}
|
||||
|
||||
public static void setBlockMeta(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset, final int storageFlag) {
|
||||
val m1Low = ebs.getM1Low();
|
||||
System.arraycopy(data, offset, m1Low.data, 0, m1Low.data.length);
|
||||
offset += m1Low.data.length;
|
||||
if (storageFlag == 0b01) {
|
||||
ebs.clearM1High();
|
||||
ebs.clearM2();
|
||||
return;
|
||||
}
|
||||
var m1High = ebs.getM1High();
|
||||
if (m1High == null) {
|
||||
m1High = ebs.createM1High();
|
||||
}
|
||||
System.arraycopy(data, offset, m1High.data, 0, m1High.data.length);
|
||||
if (storageFlag == 0b10) {
|
||||
ebs.clearM2();
|
||||
return;
|
||||
}
|
||||
var m2 = ebs.getM2();
|
||||
if (m2 == null) {
|
||||
m2 = ebs.createM2();
|
||||
}
|
||||
System.arraycopy(data, offset, m2, 0, m2.length);
|
||||
}
|
||||
|
||||
public static void writeBlockMetaToNBT(IExtendedBlockStorageMixin ebs, NBTTagCompound nbt) {
|
||||
val m1Low = ebs.getM1Low();
|
||||
val m1High = ebs.getM1High();
|
||||
val m2 = ebs.getM2();
|
||||
nbt.setByteArray("Data", m1Low.data);
|
||||
if (m1High != null) {
|
||||
nbt.setByteArray("Data1High", m1High.data);
|
||||
}
|
||||
if (m2 != null) {
|
||||
nbt.setByteArray("Data2", m2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void readBlockMetaFromNBT(IExtendedBlockStorageMixin ebs, NBTTagCompound nbt) {
|
||||
assert nbt.hasKey("Data");
|
||||
val m1Low = nbt.getByteArray("Data");
|
||||
final byte[] m1High = nbt.hasKey("Data1High") ? nbt.getByteArray("Data1High") : null;
|
||||
final byte[] m2 = nbt.hasKey("Data2") ? nbt.getByteArray("Data2") : null;
|
||||
|
||||
ebs.setM1Low(new NibbleArray(m1Low, 4));
|
||||
if (m1High == null) {
|
||||
ebs.clearM1High();
|
||||
} else {
|
||||
ebs.setM1High(new NibbleArray(m1High, 4));
|
||||
}
|
||||
ebs.setBlockRefCount(cntNonEmpty);
|
||||
ebs.setTickRefCount(cntTicking);
|
||||
ebs.setM2(m2);
|
||||
}
|
||||
|
||||
public static int getIdFromBlockWithCheck(final Block block, final Block oldBlock) {
|
||||
@@ -155,8 +198,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,13 +237,13 @@ public class Hooks {
|
||||
}
|
||||
|
||||
public static int readBiomeArrayFromPacket(Chunk chunk, byte[] array, int offset) {
|
||||
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
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();
|
||||
short[] biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
shortToByteArray(biomeArray, 0, array, offset, biomeArray.length);
|
||||
return biomeArray.length * 2;
|
||||
}
|
||||
@@ -211,7 +254,7 @@ public class Hooks {
|
||||
}
|
||||
|
||||
public static void readChunkBiomeArrayFromNbt(Chunk chunk, NBTTagCompound nbt) {
|
||||
short[] data = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
short[] data = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
boolean put = false;
|
||||
if (data == null) {
|
||||
data = new short[16 * 16];
|
||||
@@ -219,9 +262,9 @@ public class Hooks {
|
||||
}
|
||||
if (nbt.hasKey("Biomes16v2", 7)) {
|
||||
byteToShortArray(nbt.getByteArray("Biomes16v2"), 0, data, 0, data.length * 2);
|
||||
} else if (nbt.hasKey("Biomes16", 7)) {
|
||||
} else if (nbt.hasKey("Biomes16", 7)) { //NotEnoughBiomes DFU
|
||||
byteToShortArrayLegacy(nbt.getByteArray("Biomes16"), data);
|
||||
} else if (nbt.hasKey("Biomes", 7)) {
|
||||
} else if (nbt.hasKey("Biomes", 7)) { //Vanilla DFU
|
||||
scatter(nbt.getByteArray("Biomes"), data);
|
||||
} else {
|
||||
put = false;
|
||||
@@ -230,17 +273,4 @@ public class Hooks {
|
||||
((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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,8 @@ public enum ClassEdit {
|
||||
() -> 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");
|
||||
|
||||
private static final Map<String, ClassEdit> editMap;
|
||||
|
||||
|
||||
@@ -18,9 +18,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");
|
||||
|
||||
+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
-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,63 @@ 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(
|
||||
"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" +
|
||||
"(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.RangeInt(min = 0,
|
||||
max = 12)
|
||||
@Config.DefaultInt(12)
|
||||
public static int countCorrectionBits;
|
||||
|
||||
static {
|
||||
ConfigurationManager.selfInit();
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,12 @@ public class ExtendedConstants {
|
||||
public static final int biomeIDMask = biomeIDCount - 1;
|
||||
public static final int biomeIDNull = biomeIDMask;
|
||||
public static final int bytesPerBiome = (bitsPerBiome + 7) / 8;
|
||||
|
||||
//Chunk
|
||||
public static final int bytesPerChunk =
|
||||
(GeneralConfig.extendBiome ? bytesPerBiome : VanillaConstants.bytesPerBiome) * 256 +
|
||||
(GeneralConfig.extendBlockItem ? bytesPerEBS : VanillaConstants.bytesPerEBS) * 16;
|
||||
//DataWatcher
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
|
||||
//Chunk
|
||||
public static final int bytesPerChunk =
|
||||
(GeneralConfig.extendBiome ? bytesPerBiome : VanillaConstants.bytesPerBiome) * 256
|
||||
+ (GeneralConfig.extendBlockItem ? bytesPerEBS : VanillaConstants.bytesPerEBS) * 16;
|
||||
}
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -35,7 +35,8 @@ public abstract class ChunkMixin {
|
||||
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) {}
|
||||
private void noCopyBiome(Object src, int srcPos, Object dest, int destPos, int length) {
|
||||
}
|
||||
|
||||
@Redirect(method = "fillChunk",
|
||||
at = @At(value = "FIELD",
|
||||
|
||||
+42
-16
@@ -1,19 +1,18 @@
|
||||
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 lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.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;
|
||||
@@ -22,11 +21,26 @@ import java.util.Iterator;
|
||||
|
||||
@Mixin(Chunk.class)
|
||||
public abstract class ChunkMixin {
|
||||
//This is needed because the array is not a field, but a local, and local arraylength overriding does not exist
|
||||
private static byte[][] fakeArrays;
|
||||
private static NibbleArray[] fakeNarrays;
|
||||
@Shadow
|
||||
private ExtendedBlockStorage[] storageArrays;
|
||||
|
||||
//This is needed because the array is not a field, but a local, and local arraylength overriding does not exist
|
||||
private static byte[] fakeArray;
|
||||
private int ebsData;
|
||||
|
||||
@ModifyVariable(method = "fillChunk",
|
||||
at = @At("HEAD"),
|
||||
ordinal = 0,
|
||||
argsOnly = true)
|
||||
private int extractEBSData(int ebs) {
|
||||
ebsData = ebs;
|
||||
int result = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
result |= ((ebs >>> (i << 1)) & 0b11) > 0 ? 1 << i : 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Redirect(method = "fillChunk",
|
||||
at = @At(value = "FIELD",
|
||||
@@ -34,7 +48,7 @@ public abstract class ChunkMixin {
|
||||
args = "array=length",
|
||||
ordinal = 0),
|
||||
slice = @Slice(from = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getSkylightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
|
||||
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getSkylightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
|
||||
require = 1)
|
||||
private int noMSBLoop(ExtendedBlockStorage[] array) {
|
||||
return 0;
|
||||
@@ -47,7 +61,8 @@ public abstract class ChunkMixin {
|
||||
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);
|
||||
val storageFlag = (p_76607_3_ >>> (l << 1)) & 0b11;
|
||||
Hooks.setBlockData((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k, storageFlag);
|
||||
}
|
||||
|
||||
@Redirect(method = "fillChunk",
|
||||
@@ -55,7 +70,14 @@ public abstract class ChunkMixin {
|
||||
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]);
|
||||
if (fakeArrays == null) {
|
||||
fakeArrays = new byte[4][];
|
||||
fakeArrays[0] = new byte[16 * 16 * 16 * 2 / 2];
|
||||
fakeArrays[1] = new byte[16 * 16 * 16 * 3 / 2];
|
||||
fakeArrays[2] = new byte[16 * 16 * 16 * 4 / 2];
|
||||
fakeArrays[3] = new byte[16 * 16 * 16 * 6 / 2];
|
||||
}
|
||||
return fakeArrays[((IExtendedBlockStorageMixin) instance).getEBSMSBMask()];
|
||||
}
|
||||
|
||||
@Redirect(method = "fillChunk",
|
||||
@@ -65,9 +87,8 @@ public abstract class ChunkMixin {
|
||||
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) {}
|
||||
|
||||
|
||||
private void noCopy(Object src, int srcPos, Object dest, int destPos, int length) {
|
||||
}
|
||||
|
||||
@Inject(method = "fillChunk",
|
||||
at = @At(value = "INVOKE",
|
||||
@@ -75,17 +96,22 @@ public abstract class ChunkMixin {
|
||||
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);
|
||||
val storageFlag = (ebsData >>> (l << 1)) & 0b11;
|
||||
Hooks.setBlockMeta((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k, storageFlag);
|
||||
}
|
||||
|
||||
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));
|
||||
if (fakeNarrays == null) {
|
||||
fakeNarrays = new NibbleArray[3];
|
||||
fakeNarrays[0] = new NibbleArray(new byte[]{(byte)0b01}, 0);
|
||||
fakeNarrays[1] = new NibbleArray(new byte[]{(byte)0b10}, 0);
|
||||
fakeNarrays[2] = new NibbleArray(new byte[]{(byte)0b100}, 0);
|
||||
}
|
||||
return fakeNarrays[((IExtendedBlockStorageMixin)instance).getEBSMask() - 1];
|
||||
}
|
||||
|
||||
@Redirect(method = "fillChunk",
|
||||
@@ -99,7 +125,7 @@ public abstract class ChunkMixin {
|
||||
expect = 2,
|
||||
require = 2)
|
||||
private int hookSetBlockMetaFakeBytesLength(byte[] array) {
|
||||
return 16 * 16 * 16 * (ExtendedConstants.nibblesPerMetadata >>> 1);
|
||||
return 16 * 16 * 16 * (array[0] & 0xFF) / 2;
|
||||
}
|
||||
|
||||
@Redirect(method = "fillChunk",
|
||||
|
||||
+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);
|
||||
}
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -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",
|
||||
@@ -43,11 +45,9 @@ public abstract class ReikaWorldHelperMixin {
|
||||
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;
|
||||
((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;",
|
||||
@@ -55,7 +55,7 @@ public abstract class ReikaWorldHelperMixin {
|
||||
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];
|
||||
fromBiomeID = ((IChunkMixin) ch).getBiomeShortArray()[index];
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "setBiomeAndBlocksForXZ",
|
||||
@@ -72,6 +72,6 @@ public abstract class ReikaWorldHelperMixin {
|
||||
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;
|
||||
((IChunkMixin) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||
}
|
||||
}
|
||||
+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;
|
||||
}
|
||||
|
||||
+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)
|
||||
|
||||
+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);
|
||||
}
|
||||
}
|
||||
|
||||
-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",
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ public abstract class AnvilChunkLoaderMixin {
|
||||
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);
|
||||
Hooks.readBlockMetaFromNBT((IExtendedBlockStorageMixin) instance, nbt);
|
||||
nbt = null;
|
||||
}
|
||||
}
|
||||
+226
-59
@@ -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,6 +176,151 @@ 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"))
|
||||
private void crashMSBArray(CallbackInfoReturnable<NibbleArray> cir) {
|
||||
|
||||
+27
-20
@@ -1,15 +1,12 @@
|
||||
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 lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.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;
|
||||
@@ -22,6 +19,9 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
@Mixin(S21PacketChunkData.class)
|
||||
public abstract class S21PacketChunkDataMixin {
|
||||
private static byte[][] fakeArrays;
|
||||
private static NibbleArray[] fakeNarrays;
|
||||
|
||||
@Redirect(method = "func_149269_a",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;",
|
||||
@@ -37,16 +37,23 @@ public abstract class S21PacketChunkDataMixin {
|
||||
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);
|
||||
val ebs = (IExtendedBlockStorageMixin) aextendedblockstorage[l];
|
||||
extracted.field_150281_c |= Hooks.getBlockData(ebs, abyte, j) << (l << 1);
|
||||
}
|
||||
|
||||
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]);
|
||||
if (fakeArrays == null) {
|
||||
fakeArrays = new byte[4][];
|
||||
fakeArrays[0] = new byte[16 * 16 * 16 * 2 / 2];
|
||||
fakeArrays[1] = new byte[16 * 16 * 16 * 3 / 2];
|
||||
fakeArrays[2] = new byte[16 * 16 * 16 * 4 / 2];
|
||||
fakeArrays[3] = new byte[16 * 16 * 16 * 6 / 2];
|
||||
}
|
||||
return fakeArrays[((IExtendedBlockStorageMixin) instance).getEBSMSBMask()];
|
||||
}
|
||||
|
||||
@Redirect(method = "func_149269_a",
|
||||
@@ -66,17 +73,24 @@ public abstract class S21PacketChunkDataMixin {
|
||||
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);
|
||||
if (l == 0) {
|
||||
extracted.field_150280_b = 0;
|
||||
}
|
||||
extracted.field_150280_b |= Hooks.getBlockMeta((IExtendedBlockStorageMixin) aextendedblockstorage[l], abyte, j) << (l << 1);
|
||||
}
|
||||
|
||||
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));
|
||||
if (fakeNarrays == null) {
|
||||
fakeNarrays = new NibbleArray[3];
|
||||
fakeNarrays[0] = new NibbleArray(new byte[]{(byte)0b01}, 0);
|
||||
fakeNarrays[1] = new NibbleArray(new byte[]{(byte)0b10}, 0);
|
||||
fakeNarrays[2] = new NibbleArray(new byte[]{(byte)0b100}, 0);
|
||||
}
|
||||
return fakeNarrays[((IExtendedBlockStorageMixin)instance).getEBSMask() - 1];
|
||||
}
|
||||
|
||||
@Redirect(method = "func_149269_a",
|
||||
@@ -90,7 +104,7 @@ public abstract class S21PacketChunkDataMixin {
|
||||
expect = 2,
|
||||
require = 2)
|
||||
private static int hookGetBlockMetaFakeBytesLength(byte[] array) {
|
||||
return 16 * 16 * 16 * (ExtendedConstants.nibblesPerMetadata >>> 1);
|
||||
return 16 * 16 * 16 * (array[0] & 0xFF) / 2;
|
||||
}
|
||||
|
||||
@Redirect(method = "func_149269_a",
|
||||
@@ -103,11 +117,4 @@ public abstract class S21PacketChunkDataMixin {
|
||||
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;
|
||||
}
|
||||
}
|
||||
+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",
|
||||
|
||||
+100
-5
@@ -1,26 +1,121 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.Hooks;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S21PacketChunkData;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
@Mixin(S21PacketChunkData.class)
|
||||
public abstract class S21PacketChunkDataMixin {
|
||||
@Shadow
|
||||
private static byte[] field_149286_i;
|
||||
@Shadow
|
||||
private int field_149280_d;
|
||||
@Shadow
|
||||
private byte[] field_149278_f;
|
||||
@Shadow
|
||||
private int field_149284_a;
|
||||
@Shadow
|
||||
private int field_149282_b;
|
||||
@Shadow
|
||||
private boolean field_149279_g;
|
||||
@Shadow
|
||||
private int field_149283_c;
|
||||
@Shadow
|
||||
private int field_149285_h;
|
||||
|
||||
@ModifyConstant(method = {"<clinit>", "func_149275_c"},
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerChunk),
|
||||
require = 1)
|
||||
private static int increasePacketSize(int constant) {
|
||||
return ExtendedConstants.bytesPerChunk;
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private void extendWrite(PacketBuffer p_148840_1_, CallbackInfo ci) {
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
p_148840_1_.writeInt(this.field_149283_c);
|
||||
p_148840_1_.writeInt(this.field_149280_d);
|
||||
} else {
|
||||
p_148840_1_.writeShort((short)(this.field_149283_c & 65535));
|
||||
p_148840_1_.writeShort((short)(this.field_149280_d & 65535));
|
||||
}
|
||||
p_148840_1_.writeInt(this.field_149278_f.length);
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private ByteBuf suppressOldWrite1(PacketBuffer instance, int p_writeShort_1_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 1),
|
||||
require = 1)
|
||||
private ByteBuf suppressOldWrite2(PacketBuffer instance, int p_writeShort_1_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject(method = "readPacketData",
|
||||
at = @At("HEAD"),
|
||||
require = 1,
|
||||
cancellable = true)
|
||||
private void customRead(PacketBuffer data, CallbackInfo ci) throws IOException {
|
||||
this.field_149284_a = data.readInt();
|
||||
this.field_149282_b = data.readInt();
|
||||
this.field_149279_g = data.readBoolean();
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
this.field_149283_c = data.readInt();
|
||||
this.field_149280_d = data.readInt();
|
||||
} else {
|
||||
this.field_149283_c = data.readShort();
|
||||
this.field_149280_d = data.readShort();
|
||||
}
|
||||
int length = data.readInt();
|
||||
this.field_149285_h = data.readInt();
|
||||
|
||||
if (field_149286_i.length < this.field_149285_h) {
|
||||
field_149286_i = new byte[this.field_149285_h];
|
||||
}
|
||||
|
||||
data.readBytes(field_149286_i, 0, this.field_149285_h);
|
||||
|
||||
this.field_149278_f = new byte[length];
|
||||
Inflater inflater = new Inflater();
|
||||
inflater.setInput(field_149286_i, 0, this.field_149285_h);
|
||||
|
||||
try {
|
||||
inflater.inflate(this.field_149278_f);
|
||||
} catch (DataFormatException dataformatexception) {
|
||||
throw new IOException("Bad compressed data format");
|
||||
} finally {
|
||||
inflater.end();
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S26PacketMapChunkBulk;
|
||||
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
@Mixin(S26PacketMapChunkBulk.class)
|
||||
public abstract class S26PacketMapChunkBulkMixin {
|
||||
@Shadow
|
||||
private int[] field_149262_d;
|
||||
|
||||
@Shadow
|
||||
private byte[][] field_149260_f;
|
||||
|
||||
@Shadow
|
||||
private int[] field_149266_a;
|
||||
|
||||
@Shadow
|
||||
private int[] field_149264_b;
|
||||
|
||||
@Shadow
|
||||
private int[] field_149265_c;
|
||||
|
||||
@Inject(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 1),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
require = 1)
|
||||
private void extendWrite(PacketBuffer p_148840_1_, CallbackInfo ci, int i) {
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
p_148840_1_.writeInt(this.field_149265_c[i]);
|
||||
p_148840_1_.writeInt(this.field_149262_d[i]);
|
||||
} else {
|
||||
p_148840_1_.writeShort((short)(this.field_149265_c[i] & 65535));
|
||||
p_148840_1_.writeShort((short)(this.field_149262_d[i] & 65535));
|
||||
}
|
||||
p_148840_1_.writeInt(this.field_149260_f[i].length);
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 1),
|
||||
require = 1)
|
||||
private ByteBuf suppressOldWrite1(PacketBuffer instance, int p_writeShort_1_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 2),
|
||||
require = 1)
|
||||
private ByteBuf suppressOldWrite2(PacketBuffer instance, int p_writeShort_1_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Ljava/util/zip/Inflater;inflate([B)I",
|
||||
shift = At.Shift.AFTER),
|
||||
require = 1,
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
cancellable = true)
|
||||
private void customRead(PacketBuffer data, CallbackInfo ci, short short1, byte[] abyte, Inflater inflater) {
|
||||
int i = 0;
|
||||
|
||||
for (int j = 0; j < short1; ++j) {
|
||||
this.field_149266_a[j] = data.readInt();
|
||||
this.field_149264_b[j] = data.readInt();
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
this.field_149265_c[j] = data.readInt();
|
||||
this.field_149262_d[j] = data.readInt();
|
||||
} else {
|
||||
this.field_149265_c[j] = data.readShort();
|
||||
this.field_149262_d[j] = data.readShort();
|
||||
}
|
||||
byte[] dataBytes = new byte[data.readInt()];
|
||||
this.field_149260_f[j] = dataBytes;
|
||||
System.arraycopy(abyte, i, dataBytes, 0, dataBytes.length);
|
||||
i += dataBytes.length;
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public enum Mixin implements IMixin {
|
||||
//region common
|
||||
//region vanilla
|
||||
S21PacketChunkDataMixin(Side.COMMON, always(), "vanilla.S21PacketChunkDataMixin"),
|
||||
S26PacketMapChunkBulkMixin(Side.COMMON, always(), "vanilla.S26PacketMapChunkBulkMixin"),
|
||||
//endregion vanilla
|
||||
//region AntiIDConflict
|
||||
AIDCAntiIdConflictBaseMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.AntiIdConflictBaseMixin"),
|
||||
@@ -38,7 +39,6 @@ public enum Mixin implements IMixin {
|
||||
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 +67,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"),
|
||||
@@ -173,7 +173,6 @@ public enum Mixin implements IMixin {
|
||||
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
|
||||
|
||||
+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)) {
|
||||
|
||||
Reference in new issue
Block a user