Compare commits

..
Author SHA1 Message Date
FalsePattern 0e58bf113d weaken some checks 2023-03-03 09:10:15 +01:00
FalsePattern 0b968923df reimplemented metadata storage, now it's optimized like IDs 2023-03-03 08:55:08 +01:00
FalsePattern f98d2c98e3 fix broken BC mixin 2023-03-03 07:48:37 +01:00
FalsePattern bf52cfaadf cleanup code 2023-03-02 22:52:41 +01:00
FalsePattern c321707f0e optimize imports 2023-03-02 22:43:12 +01:00
FalsePattern c8e076f6d2 update code style 2023-03-02 22:42:19 +01:00
FalsePattern 6f832f4905 optimized chunk block id memory/network usage 2023-03-02 22:41:36 +01:00
FalsePattern 818f201f30 metadata extension 2023-03-02 10:32:12 +01:00
61 changed files with 1536 additions and 577 deletions

No files matched your search

+2
View File
@@ -145,3 +145,5 @@ gradle-app.setting
# End of https://www.toptal.com/developers/gitignore/api/intellij+all,gradle,forgegradle,java
!lib/*.jar
srgmap.cfg
+7
View File
@@ -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>
+1
View File
@@ -6,6 +6,7 @@ Comparison of the known limits:
| | Vanilla | NotEnoughIDs | EndlessIDs |
|-----------------|----------------------------------------------------|--------------|----------------------------------|
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
| Block Metadata | 16 | 16 | 65,536 since 1.5 |
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
| Entity IDs | 256 | 256 | 256 right now, extension planned |
@@ -5,132 +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 java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import net.minecraft.world.chunk.NibbleArray;
public class Hooks {
public static byte[] getBlockData(final IExtendedBlockStorageMixin ebs) {
val lsb = ebs.getLSB();
val msb = ebs.getMSB();
final byte[] ret = new byte[lsb.length * 3];
ByteBuffer.wrap(ret).asShortBuffer().put(lsb);
System.arraycopy(msb, 0, ret, lsb.length * 2, lsb.length);
return ret;
}
public static void setBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, final int offset) {
val lsb = ebs.getLSB();
val msb = ebs.getMSB();
val lsbBytes = lsb.length * 2;
ShortBuffer.wrap(ebs.getLSB()).put(ByteBuffer.wrap(data, offset, lsbBytes).asShortBuffer());
System.arraycopy(data, offset + lsbBytes, msb, 0, msb.length);
}
public static void writeChunkToNbt(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];
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);
}
byte3Data[i] = ebsMSB[i];
}
val idLSB = (ebsLSB[i] & 0xFFFF);
byte1Data[i] = (byte) (idLSB & 0xFF);
if (idLSB <= 0xFF) {
continue;
}
val nibbleIndex = i >> 1;
val nibbleShift = (i & 1) * 4;
if (byte2BottomNibbleData == null) {
byte2BottomNibbleData = new byte[ebsLSB.length / 2];
}
byte2BottomNibbleData[nibbleIndex] |= ((idLSB >>> 8) & 0xF) << nibbleShift;
if (idLSB <= 0xFFF) {
continue;
}
if (byte2TopNibbleData == null) {
byte2TopNibbleData = new byte[ebsLSB.length / 2];
}
byte2TopNibbleData[nibbleIndex] |= ((idLSB >>> 12) & 0xF) << nibbleShift;
}
nbt.setByteArray("Blocks", byte1Data);
if (byte2BottomNibbleData != null) {
nbt.setByteArray("Add", byte2BottomNibbleData);
return ebs.getEBSMSBMask();
}
public static void setBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, int offset, final int storageFlag) {
val b1 = ebs.getB1();
System.arraycopy(data, offset, b1, 0, b1.length);
offset += b1.length;
if (storageFlag == 0b00) {
ebs.clearB2Low();
ebs.clearB2High();
ebs.clearB3();
return;
}
if (byte2TopNibbleData != null) {
nbt.setByteArray("BlocksB2Hi", byte2TopNibbleData);
var b2Low = ebs.getB2Low();
if (b2Low == null) {
b2Low = ebs.createB2Low();
}
if (byte3Data != null) {
nbt.setByteArray("BlocksB3", byte3Data);
System.arraycopy(data, offset, b2Low.data, 0, b2Low.data.length);
offset += b2Low.data.length;
if (storageFlag == 0b01) {
ebs.clearB2High();
ebs.clearB3();
return;
}
var b2High = ebs.getB2High();
if (b2High == null) {
b2High = ebs.createB2High();
}
System.arraycopy(data, offset, b2High.data, 0, b2High.data.length);
offset += b2High.data.length;
if (storageFlag == 0b10) {
ebs.clearB3();
return;
}
var b3 = ebs.getB3();
if (b3 == null) {
b3 = ebs.createB3();
}
System.arraycopy(data, offset, b3, 0, b3.length);
}
public static void writeBlockDataToNBT(final NBTTagCompound nbt, final IExtendedBlockStorageMixin ebs) {
val b1 = ebs.getB1();
val b2Low = ebs.getB2Low();
val b2High = ebs.getB2High();
val b3 = ebs.getB3();
nbt.setByteArray("Blocks", b1);
if (b2Low != null) {
nbt.setByteArray("Add", b2Low.data);
}
if (b2High != null) {
nbt.setByteArray("BlocksB2Hi", b2High.data);
}
if (b3 != null) {
nbt.setByteArray("BlocksB3", b3);
}
}
public static void readChunkFromNbt(final IExtendedBlockStorageMixin ebs, final NBTTagCompound nbt) {
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) {
@@ -151,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);
}
}
@@ -183,20 +230,20 @@ public class Hooks {
}
}
public static void oldBiomeByteToNewShortArray(byte[] byteArray, short[] shortArray) {
for (int i = 0; i < 256; i++) {
private static void scatter(byte[] byteArray, short[] shortArray) {
for (int i = 0; i < byteArray.length; i++) {
shortArray[i] = (short) (byteArray[i] & 0xff);
}
}
public static int readBiomeArrayFromPacket(Chunk chunk, byte[] array, int offset) {
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
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;
}
@@ -207,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];
@@ -215,10 +262,10 @@ 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)) {
oldBiomeByteToNewShortArray(nbt.getByteArray("Biomes"), data);
} else if (nbt.hasKey("Biomes", 7)) { //Vanilla DFU
scatter(nbt.getByteArray("Biomes"), data);
} else {
put = false;
}
@@ -0,0 +1,66 @@
package com.falsepattern.endlessids;
import lombok.val;
import sun.misc.Unsafe;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
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)) {
unsafeField = field;
break;
}
}
if (unsafeField != null) {
unsafeField.setAccessible(true);
try {
unsafe = (Unsafe) unsafeField.get(null);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
if (unsafe == null) {
UNSAFE = null;
new IllegalStateException("Could not retrieve Unsafe! Falling back to bytebuffers!").printStackTrace();
} else {
UNSAFE = unsafe;
}
}
public static void arraycopy(short[] source, int sourceOffset, byte[] target, int targetOffset, int shorts) {
if (UNSAFE != null) {
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);
} else {
ByteBuffer.wrap(target, targetOffset, target.length - targetOffset)
.asShortBuffer()
.put(source, sourceOffset, shorts);
}
}
public static void arraycopy(byte[] source, int sourceOffset, short[] target, int targetOffset, int shorts) {
if (UNSAFE != null) {
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);
} else {
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");
@@ -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;
}
}
@@ -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,58 +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(
"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")
"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.")
@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.RangeInt(min = 0,
max = 12)
@Config.DefaultInt(12)
public static int countCorrectionBits;
static {
ConfigurationManager.selfInit();
}
}
@@ -5,7 +5,7 @@ import com.falsepattern.endlessids.config.GeneralConfig;
public class ExtendedConstants {
//Tunables
public static final int bitsPerID = 24;
public static final int bitsPerMetadata = 4;
public static final int bitsPerMetadata = 16;
public static final int countCorrectionBits = GeneralConfig.countCorrectionBits;
public static final int watchableBits = 7;
@@ -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 {
@@ -1,11 +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);
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]);
}
@@ -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",
@@ -1,29 +1,46 @@
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.LocalCapture;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.util.Iterator;
@Mixin(Chunk.class)
public abstract class ChunkMixin {
//This is needed because the array is not a field, but a local, and local arraylength overriding does not exist
private static byte[][] fakeArrays;
private static NibbleArray[] fakeNarrays;
@Shadow
private ExtendedBlockStorage[] storageArrays;
//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",
@@ -31,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;
@@ -44,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",
@@ -52,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",
@@ -62,5 +87,55 @@ 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",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private void hookSetBlockMeta(byte[] p_76607_1_, int p_76607_2_, int p_76607_3_, boolean p_76607_4_, CallbackInfo ci, Iterator iterator, int k, boolean flag1, int l) {
val storageFlag = (ebsData >>> (l << 1)) & 0b11;
Hooks.setBlockMeta((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k, storageFlag);
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 1)
private NibbleArray hookSetBlockMetaNoArray(ExtendedBlockStorage instance) {
if (fakeNarrays == null) {
fakeNarrays = new NibbleArray[3];
fakeNarrays[0] = new NibbleArray(new byte[]{(byte)0b01}, 0);
fakeNarrays[1] = new NibbleArray(new byte[]{(byte)0b10}, 0);
fakeNarrays[2] = new NibbleArray(new byte[]{(byte)0b100}, 0);
}
return fakeNarrays[((IExtendedBlockStorageMixin)instance).getEBSMask() - 1];
}
@Redirect(method = "fillChunk",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/NibbleArray;data:[B",
args = "array=length"),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
to = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlocklightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
expect = 2,
require = 2)
private int hookSetBlockMetaFakeBytesLength(byte[] array) {
return 16 * 16 * 16 * (array[0] & 0xFF) / 2;
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private void hookSetBlockMetaNoCopy(Object src, int srcPos, Object dest, int destPos, int length) {
}
}
@@ -38,13 +38,14 @@ public abstract class NetHandlerPlayClientMixin {
short idLSB = dataInput.readShort();
byte idMSB = dataInput.readByte();
int id = (idLSB & 0xFFFF) | ((idMSB & 0xFF) << 16);
int meta = dataInput.readByte() & 15;
int meta = dataInput.readShort() & 0xFFFF;
int x = pos >> 12 & 15;
int z = pos >> 8 & 15;
int y = pos & 255;
this.clientWorldController.func_147492_c(x + chunkX, y, z + chunkZ, Block.getBlockById(id), meta);
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}
}
}
@@ -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",
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.client.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.block.BlockRedstoneWire;
@Mixin(BlockRedstoneWire.class)
public abstract class BlockRedstoneWireMixin {
@ModifyConstant(method = "randomDisplayTick",
constant = @Constant(floatValue = 15.0F),
require = 1)
private float bigRedstone(float constant) {
return GeneralConfig.maxRedstone;
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.client.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.client.renderer.RenderBlocks;
@Mixin(RenderBlocks.class)
public abstract class RenderBlocksMixin {
@ModifyConstant(method = "renderBlockRedstoneWire",
constant = @Constant(floatValue = 15.0F),
require = 1)
private float bigRedstone(float constant) {
return GeneralConfig.maxRedstone;
}
}
@@ -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);
}
@@ -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;
}
}
}
}
@@ -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;
}
@@ -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;
}
@@ -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);
}
}
@@ -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);
}
@@ -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);
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
@@ -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;
@@ -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;
}
@@ -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)
@@ -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;
@@ -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);
}
}
@@ -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,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);
}
}
@@ -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;
}
}
@@ -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",
@@ -3,15 +3,11 @@ package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@@ -41,8 +37,8 @@ public abstract class AnvilChunkLoaderMixin {
to = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private void redirectBlockDataWrite(NBTTagCompound instance, String p_74773_1_, byte[] p_74773_2_) {
Hooks.writeChunkToNbt(instance, ebs);
private void redirectBlockDataWrite(NBTTagCompound instance, String key, byte[] value) {
Hooks.writeBlockDataToNBT(instance, ebs);
ebs = null;
}
@@ -54,6 +50,38 @@ public abstract class AnvilChunkLoaderMixin {
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 1)
private NibbleArray grabEBSBlockMetaWrite(ExtendedBlockStorage instance) {
ebs = (IExtendedBlockStorageMixin) instance;
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/NibbleArray;data:[B",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private byte[] suppressEBSBlockMetaNibbleArrayAccess(NibbleArray instance) {
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Data")),
require = 1)
private void redirectBlockMetaWrite(NBTTagCompound instance, String p_74773_1_, byte[] p_74773_2_) {
Hooks.writeBlockMetaToNBT(ebs, instance);
ebs = null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B",
@@ -61,7 +89,7 @@ public abstract class AnvilChunkLoaderMixin {
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Blocks")),
require = 1)
private byte[] grabNBTBlockDataRead(NBTTagCompound instance, String p_74770_1_) {
private byte[] grabNBTBlockDataRead(NBTTagCompound instance, String key) {
nbt = instance;
return null;
}
@@ -71,7 +99,7 @@ public abstract class AnvilChunkLoaderMixin {
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;setBlockLSBArray([B)V"),
require = 1)
private void redirectBlockDataRead(ExtendedBlockStorage instance, byte[] p_76664_1_) {
Hooks.readChunkFromNbt((IExtendedBlockStorageMixin) instance, nbt);
Hooks.readBlockDataFromNBT((IExtendedBlockStorageMixin) instance, nbt);
nbt = null;
}
@@ -83,7 +111,28 @@ public abstract class AnvilChunkLoaderMixin {
args = "stringValue=Add",
ordinal = 0)),
require = 1)
private boolean suppressVanillaBlockDataRead(NBTTagCompound instance, String p_150297_1_, int p_150297_2_) {
private boolean suppressVanillaBlockDataRead(NBTTagCompound instance, String key, int type) {
return false;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Data")),
require = 1)
private byte[] grabNBTBlockMetaRead(NBTTagCompound instance, String key) {
nbt = instance;
return null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;setBlockMetadataArray(Lnet/minecraft/world/chunk/NibbleArray;)V"),
require = 1)
private void redirectBlockMetaRead(ExtendedBlockStorage instance, NibbleArray p_76668_1_) {
Hooks.readBlockMetaFromNBT((IExtendedBlockStorageMixin) instance, nbt);
nbt = null;
}
}
@@ -1,16 +1,24 @@
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 lombok.var;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(ExtendedBlockStorage.class)
@@ -19,50 +27,59 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
private int blockRefCount;
@Shadow
private int tickRefCount;
private short[] lsbArray;
private byte[] msbArray;
@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;
}
@Inject(method = "<init>",
at = @At(value = "RETURN"),
require = 1)
private void init(CallbackInfo ci) {
lsbArray = new short[16 * 16 * 16];
msbArray = new byte[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);
}
}
}
}
/**
@@ -101,10 +118,255 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
/**
* @author FalsePattern
* @reason Direct port from dumped code
* @reason meta ID extension
*/
@Overwrite
public void removeInvalidBlocks() {
Hooks.removeInvalidBlocksHook(this);
public int getExtBlockMetadata(int x, int y, int z) {
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;
}
/**
* @author FalsePattern
* @reason meta ID extension
*/
@Overwrite
public void setExtBlockMetadata(int x, int y, int z, int meta) {
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);
}
}
}
@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() {
val crashMSG = "A mod that is incompatible with " + Tags.MODNAME + " has tried to access the block array of a" +
" chunk like in vanilla! Crashing in fear of potential world corruption!\n" +
"Please report this issue on https://github.com/FalsePattern/EndlessIDs ASAP!";
EndlessIDs.LOG.fatal(crashMSG);
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"),
expect = 0)
private void crashMSBArray(CallbackInfoReturnable<NibbleArray> cir) {
throw emergencyCrash();
}
@Inject(method = "clearMSBArray",
at = @At("HEAD"),
expect = 0)
private void crashMSBArray(CallbackInfo ci) {
throw emergencyCrash();
}
@Inject(method = "setBlockMSBArray",
at = @At("HEAD"),
expect = 0)
private void crashMSBArray(NibbleArray p_76673_1_, CallbackInfo ci) {
throw emergencyCrash();
}
@Inject(method = "setBlockLSBArray",
at = @At("HEAD"),
expect = 0)
private void crashLSBArray(byte[] p_76664_1_, CallbackInfo ci) {
throw emergencyCrash();
}
@Inject(method = "getBlockLSBArray",
at = @At("HEAD"),
expect = 0)
private void crashLSBArray(CallbackInfoReturnable<byte[]> cir) {
throw emergencyCrash();
}
@Inject(method = "setBlockMetadataArray",
at = @At("HEAD"),
expect = 0)
private void crashMetadataArray(NibbleArray p_76668_1_, CallbackInfo ci) {
throw emergencyCrash();
}
@Inject(method = "getMetadataArray",
at = @At("HEAD"),
expect = 0)
private void crashMetadataArray(CallbackInfoReturnable<NibbleArray> cir) {
throw emergencyCrash();
}
}
@@ -1,32 +1,120 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
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.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.network.play.server.S21PacketChunkData;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
private static byte[][] fakeArrays;
private static NibbleArray[] fakeNarrays;
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;",
ordinal = 0),
require = 1)
private static NibbleArray noMSB(ExtendedBlockStorage instance) {
return null;
}
@Inject(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private static void hookGetBlockData(Chunk p_149269_0_, boolean p_149269_1_, int p_149269_2_, CallbackInfoReturnable<S21PacketChunkData.Extracted> cir, int j, ExtendedBlockStorage[] aextendedblockstorage, int k, S21PacketChunkData.Extracted extracted, byte[] abyte, int l) {
val ebs = (IExtendedBlockStorageMixin) aextendedblockstorage[l];
extracted.field_150281_c |= Hooks.getBlockData(ebs, abyte, j) << (l << 1);
}
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private static byte[] hookGetBlockData(ExtendedBlockStorage instance) {
return Hooks.getBlockData((IExtendedBlockStorageMixin) instance);
private static byte[] hookGetBlockDataFakeArray(ExtendedBlockStorage instance) {
if (fakeArrays == null) {
fakeArrays = new byte[4][];
fakeArrays[0] = new byte[16 * 16 * 16 * 2 / 2];
fakeArrays[1] = new byte[16 * 16 * 16 * 3 / 2];
fakeArrays[2] = new byte[16 * 16 * 16 * 4 / 2];
fakeArrays[3] = new byte[16 * 16 * 16 * 6 / 2];
}
return fakeArrays[((IExtendedBlockStorageMixin) instance).getEBSMSBMask()];
}
@ModifyConstant(method = "readPacketData",
constant = @Constant(intValue = VanillaConstants.bytesPerEBS),
require = 1)
private int increaseReadSize(int constant) {
return ExtendedConstants.bytesPerEBS;
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B")),
require = 1)
private static void hookGetBlockDataNoCopy(Object src, int srcPos, Object dest, int destPos, int length) {
}
@Inject(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private static void hookGetBlockMeta(Chunk p_149269_0_, boolean p_149269_1_, int p_149269_2_, CallbackInfoReturnable<S21PacketChunkData.Extracted> cir, int j, ExtendedBlockStorage[] aextendedblockstorage, int k, S21PacketChunkData.Extracted extracted, byte[] abyte, int l) {
if (l == 0) {
extracted.field_150280_b = 0;
}
extracted.field_150280_b |= Hooks.getBlockMeta((IExtendedBlockStorageMixin) aextendedblockstorage[l], abyte, j) << (l << 1);
}
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 1)
private static NibbleArray hookGetBlockMetaNoArray(ExtendedBlockStorage instance) {
if (fakeNarrays == null) {
fakeNarrays = new NibbleArray[3];
fakeNarrays[0] = new NibbleArray(new byte[]{(byte)0b01}, 0);
fakeNarrays[1] = new NibbleArray(new byte[]{(byte)0b10}, 0);
fakeNarrays[2] = new NibbleArray(new byte[]{(byte)0b100}, 0);
}
return fakeNarrays[((IExtendedBlockStorageMixin)instance).getEBSMask() - 1];
}
@Redirect(method = "func_149269_a",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/NibbleArray;data:[B",
args = "array=length"),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
to = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlocklightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
expect = 2,
require = 2)
private static int hookGetBlockMetaFakeBytesLength(byte[] array) {
return 16 * 16 * 16 * (array[0] & 0xFF) / 2;
}
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private static void hookGetBlockMetaNoCopy(Object src, int srcPos, Object dest, int destPos, int length) {
}
}
@@ -1,5 +1,7 @@
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.At;
import org.spongepowered.asm.mixin.injection.Constant;
@@ -18,13 +20,12 @@ public abstract class S22PacketMultiBlockChangeMixin {
private int id;
private int meta;
//TODO magic number
@ModifyConstant(method = "<init>(I[SLnet/minecraft/world/chunk/Chunk;)V",
constant = @Constant(intValue = 4,
constant = @Constant(intValue = 2 + VanillaConstants.bytesPerIDPlusMetadata,
ordinal = 0),
require = 1)
private int extend1(int constant) {
return 6;
return 2 + ExtendedConstants.bytesPerIDPlusMetadata;
}
@Redirect(method = "<init>(I[SLnet/minecraft/world/chunk/Chunk;)V",
@@ -46,6 +47,6 @@ public abstract class S22PacketMultiBlockChangeMixin {
private void hackWrite(DataOutputStream instance, int value) throws IOException {
instance.writeShort(id & 0xFFFF);
instance.writeByte((id >>> 16) & 0xFF);
instance.writeByte(meta);
instance.writeShort(meta);
}
}
@@ -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;
}
}
@@ -4,10 +4,13 @@ import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.sk89q.worldedit.blocks.BaseBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = BaseBlock.class,
remap = false)
public abstract class BaseBlockMixin {
@Shadow
private short data;
private int idExtended;
/**
@@ -35,4 +38,29 @@ public abstract class BaseBlockMixin {
return idExtended;
}
/**
* @author FalsePattern
* @reason ID limit extension
*/
@Overwrite
public int getData() {
return this.data & 0xFFFF;
}
/**
* @author FalsePattern
* @reason ID limit extension
*/
@Overwrite
protected final void internalSetData(int data) {
if (data > 0xFFFF) {
throw new IllegalArgumentException("Can't have a block data value above 65535 (" + data + " given)");
} else if (data < -1) {
throw new IllegalArgumentException("Can't have a block data value below -1");
} else {
this.data = (short) data;
}
}
}
@@ -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);
}
}
@@ -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;
@@ -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;
}
}
@@ -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",
@@ -0,0 +1,21 @@
package com.falsepattern.endlessids.mixin.mixins.common.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.BlockCompressedPowered;
import net.minecraft.world.IBlockAccess;
@Mixin(BlockCompressedPowered.class)
public abstract class BlockCompressedPoweredMixin {
@Inject(method = "isProvidingWeakPower",
at = @At("HEAD"),
cancellable = true,
require = 1)
private void bigRedstone(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_, CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(GeneralConfig.maxRedstone);
}
}
@@ -0,0 +1,20 @@
package com.falsepattern.endlessids.mixin.mixins.common.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.BlockRedstoneDiode;
import net.minecraft.world.IBlockAccess;
@Mixin(BlockRedstoneDiode.class)
public abstract class BlockRedstoneDiodeMixin {
@Inject(method = "func_149904_f",
at = @At("HEAD"),
cancellable = true)
private void bigRedstone(IBlockAccess p_149904_1_, int p_149904_2_, int p_149904_3_, int p_149904_4_, int p_149904_5_, CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(GeneralConfig.maxRedstone);
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.common.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.block.BlockRedstoneTorch;
@Mixin(BlockRedstoneTorch.class)
public abstract class BlockRedstoneTorchMixin {
@ModifyConstant(method = "isProvidingWeakPower",
constant = @Constant(intValue = 15),
require = 1)
private int bigRedstone(int original) {
return GeneralConfig.maxRedstone;
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.common.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.world.World;
@Mixin(World.class)
public abstract class WorldMixin {
@ModifyConstant(method = {"getStrongestIndirectPower", "getBlockPowerInput"},
constant = @Constant(intValue = 15),
require = 8)
private int bigRedstone(int constant) {
return GeneralConfig.maxRedstone;
}
}
@@ -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();
}
}
@@ -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
@@ -242,6 +241,19 @@ public enum Mixin implements IMixin {
//endregion potion
//endregion client
//region redstone
//region common
BlockCompressedPoweredMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.BlockCompressedPoweredMixin"),
BlockRedstoneDiodeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.BlockRedstoneDiodeMixin"),
BlockRedstoneTorchMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.BlockRedstoneTorchMixin"),
RedstoneWorldMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.WorldMixin"),
//endregion common
//region client
BlockRedstoneWireMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.BlockRedstoneWireMixin"),
RedstoneRenderBlocksMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.RenderBlocksMixin"),
//endregion client
//endregion redstone
;
@Getter
private final Side side;
@@ -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)) {