mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-12 06:07:31 +00:00
remove magic constants, start implementing id extension to 24 bits
This commit is contained in:
23 files changed
+202
-66
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package com.falsepattern.endlessids;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -28,11 +29,11 @@ public class Hooks
|
||||
public static void writeChunkToNbt(final NBTTagCompound nbt, final IExtendedBlockStorageMixin ebs) {
|
||||
nbt.setByteArray("Blocks16", getBlockData(ebs));
|
||||
if (IEConfig.postNeidWorldsSupport) {
|
||||
final short[] data = ebs.get16B();
|
||||
final short[] data = ebs.getLSB();
|
||||
final byte[] lsbData = new byte[data.length];
|
||||
byte[] msbData = null;
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
final int id = data[i] & 0xFFFF;
|
||||
final int id = data[i] & ExtendedConstants.blockIDMask;
|
||||
if (id <= 255) {
|
||||
lsbData[i] = (byte)id;
|
||||
}
|
||||
@@ -102,6 +103,10 @@ public class Hooks
|
||||
return new short[4096];
|
||||
}
|
||||
|
||||
public static byte[] create8BArray() {
|
||||
return new byte[4096];
|
||||
}
|
||||
|
||||
public static void removeInvalidBlocksHook(final IExtendedBlockStorageMixin ebs) {
|
||||
final short[] blkIds = ebs.get16B();
|
||||
int cntNonEmpty = 0;
|
||||
@@ -132,7 +137,7 @@ public class Hooks
|
||||
if (IEConfig.catchUnregisteredBlocks && id == -1) {
|
||||
throw new IllegalArgumentException("Block " + block + " is not registered. <-- Say about this to the author of this mod, or you can try to enable \"RemoveInvalidBlocks\" option in NEID config.");
|
||||
}
|
||||
if (id >= 0 && id <= 32767) {
|
||||
if (id >= 0 && id <= ExtendedConstants.maxBlockID) {
|
||||
return id;
|
||||
}
|
||||
if (id == -1) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.falsepattern.endlessids.asm;
|
||||
|
||||
public class Constants
|
||||
{
|
||||
|
||||
public static final int maxBlockId = 32767;
|
||||
public static final int blockIdMask = 65535;
|
||||
public static final int ebsIdArrayLength = 4096;
|
||||
@@ -11,7 +12,11 @@ public class Constants
|
||||
public static final int newEbsSize = 14336;
|
||||
public static final int newSize = 229632;
|
||||
public static final int maxDataWatcherId = 127;
|
||||
|
||||
public static final int vanillaIDCount = 4096;
|
||||
public static final int newIDCount = 32768;
|
||||
public static final int vanillaIDBits = 12;
|
||||
public static final int newIDBits = 16;
|
||||
|
||||
public Constants() {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import com.falsepattern.endlessids.asm.AsmUtil;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -14,8 +16,8 @@ public class CofhBlockHelper implements IClassNodeTransformer
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
final MethodNode method = AsmUtil.findMethod(cn, "<clinit>");
|
||||
if (!AsmUtil.transformInlinedSizeMethod(cn, method, 4096, 32768, true)) {
|
||||
AsmUtil.transformInlinedSizeMethod(cn, method, 1024, 32768);
|
||||
if (!AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.blockIDCount, ExtendedConstants.blockIDCount, true)) {
|
||||
AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.blockIDCount / 4, ExtendedConstants.blockIDCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import com.falsepattern.endlessids.asm.AsmTransformException;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
@@ -17,11 +19,11 @@ public class FmlRegistry implements IClassNodeTransformer
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
final FieldNode field = AsmUtil.findField(cn, "MAX_BLOCK_ID", true);
|
||||
if (field != null) {
|
||||
field.value = Integer.valueOf(32767);
|
||||
field.value = ExtendedConstants.maxBlockID;
|
||||
}
|
||||
boolean found = false;
|
||||
for (final MethodNode method : cn.methods) {
|
||||
if (AsmUtil.transformInlinedSizeMethod(cn, method, 4095, 32767, true)) {
|
||||
if (AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.maxBlockID, ExtendedConstants.maxBlockID, true)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import com.falsepattern.endlessids.asm.AsmUtil;
|
||||
import com.falsepattern.endlessids.asm.Name;
|
||||
@@ -17,7 +19,7 @@ public class MFQM implements IClassNodeTransformer
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
if (IEConfig.extendDataWatcher) {
|
||||
final MethodNode method = AsmUtil.findMethod(cn, Name.MFQM_preInit);
|
||||
AsmUtil.transformInlinedSizeMethod(cn, method, 31, 127);
|
||||
AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.watchableMask, ExtendedConstants.watchableMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import com.falsepattern.endlessids.asm.AsmUtil;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -14,6 +16,6 @@ public class UndergroundBiomesOreUBifier implements IClassNodeTransformer
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
final MethodNode method = AsmUtil.findMethod(cn, "renewBlockReplacers");
|
||||
AsmUtil.transformInlinedSizeMethod(cn, method, 4096, 32768, false);
|
||||
AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.blockIDCount, ExtendedConstants.blockIDCount, false);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import lombok.val;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
@@ -20,15 +22,15 @@ public class WorldEditBaseBlock implements IClassNodeTransformer
|
||||
if (method == null) {
|
||||
return;
|
||||
}
|
||||
AsmUtil.transformInlinedSizeMethod(cn, method, 4095, 32767);
|
||||
AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.maxBlockID, ExtendedConstants.maxBlockID);
|
||||
final InsnList code = method.instructions;
|
||||
val iter = code.iterator();
|
||||
while (iter.hasNext()) {
|
||||
val insn = iter.next();
|
||||
if (insn.getType() == 9 && ((LdcInsnNode)insn).cst instanceof String) {
|
||||
final String string = (String)((LdcInsnNode)insn).cst;
|
||||
if (string.contains("4095")) {
|
||||
((LdcInsnNode)insn).cst = string.replace("4095", Integer.toString(32767));
|
||||
if (string.contains(Integer.toString(VanillaConstants.maxBlockID))) {
|
||||
((LdcInsnNode)insn).cst = string.replace(Integer.toString(VanillaConstants.maxBlockID), Integer.toString(ExtendedConstants.maxBlockID));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.falsepattern.endlessids.constants;
|
||||
|
||||
public class ExtendedConstants {
|
||||
//Tunables
|
||||
public static final int bitsPerID = 16;
|
||||
public static final int bitsPerMetadata = 4;
|
||||
public static final int countCorrectionBits = 1;
|
||||
|
||||
public static final int watchableBits = 7;
|
||||
|
||||
//IDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int nibblesPerMetadata = bitsPerMetadata / 4;
|
||||
|
||||
public static final int bytesPerID = (nibblesPerID + 1) / 2;
|
||||
public static final int bytesPerIDPlusMetadata = (nibblesPerID + nibblesPerMetadata + 1) / 2;
|
||||
|
||||
public static final int blockIDMask = (1 << bitsPerID) - 1;
|
||||
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBits);
|
||||
public static final int maxBlockID = blockIDCount - 1;
|
||||
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
|
||||
public static final int bytesPerEBS = nibblesPerEBS / 2;
|
||||
public static final int bytesPerChunk = 256 + bytesPerEBS * 16;
|
||||
|
||||
//DataWatcher
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.falsepattern.endlessids.constants;
|
||||
|
||||
public class VanillaConstants {
|
||||
//Tunables
|
||||
public static final int bitsPerID = 12;
|
||||
public static final int bitsPerMetadata = 4;
|
||||
public static final int countCorrectionBits = 0;
|
||||
|
||||
public static final int watchableBits = 5;
|
||||
|
||||
//IDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int nibblesPerMetadata = bitsPerMetadata / 4;
|
||||
|
||||
public static final int bytesPerID = (nibblesPerID + 1) / 2;
|
||||
public static final int bytesPerIDPlusMetadata = (nibblesPerID + nibblesPerMetadata + 1) / 2;
|
||||
|
||||
public static final int blockIDMask = (1 << bitsPerID) - 1;
|
||||
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBits);
|
||||
public static final int maxBlockID = blockIDCount - 1;
|
||||
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
|
||||
public static final int bytesPerEBS = nibblesPerEBS / 2;
|
||||
public static final int bytesPerChunk = 256 + bytesPerEBS * 16;
|
||||
|
||||
//DataWatcher
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
}
|
||||
+2
-1
@@ -3,5 +3,6 @@ package com.falsepattern.endlessids.mixin.helpers;
|
||||
public interface IExtendedBlockStorageMixin {
|
||||
void setBlockRefCount(int value);
|
||||
void setTickRefCount(int value);
|
||||
short[] get16B();
|
||||
short[] getLSB();
|
||||
byte[] getMSB();
|
||||
}
|
||||
+2
@@ -20,6 +20,8 @@ public abstract class NetHandlerPlayClientMixin {
|
||||
|
||||
@Shadow private WorldClient clientWorldController;
|
||||
|
||||
|
||||
//TODO magic logic
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Direct port from dumped code
|
||||
|
||||
+6
-4
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.client;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
@@ -11,16 +13,16 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@Mixin(RenderGlobal.class)
|
||||
public abstract class RenderGlobalMixin {
|
||||
@ModifyConstant(method = "playAuxSFX",
|
||||
constant = @Constant(intValue = 4095),
|
||||
constant = @Constant(intValue = VanillaConstants.blockIDMask),
|
||||
require = 1)
|
||||
private int extend1(int constant) {
|
||||
return 65535;
|
||||
return ExtendedConstants.blockIDMask;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "playAuxSFX",
|
||||
constant = @Constant(intValue = 12),
|
||||
constant = @Constant(intValue = VanillaConstants.bitsPerID),
|
||||
require = 1)
|
||||
private int extend2(int constant) {
|
||||
return 16;
|
||||
return ExtendedConstants.bitsPerID;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.block.BlockFire;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -8,10 +10,10 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@Mixin(BlockFire.class)
|
||||
public abstract class BlockFireMixin {
|
||||
@ModifyConstant(method = {"<init>", "rebuildFireInfo", "getFlammability", "getEncouragement"},
|
||||
constant = @Constant(intValue = 4096),
|
||||
constant = @Constant(intValue = VanillaConstants.blockIDCount),
|
||||
remap = false,
|
||||
require = 1)
|
||||
private static int extendIDs(int constant) {
|
||||
return 32768;
|
||||
return ExtendedConstants.blockIDCount;
|
||||
}
|
||||
}
|
||||
+18
-16
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.DataWatcher;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -18,24 +20,24 @@ import java.util.List;
|
||||
@Mixin(DataWatcher.class)
|
||||
public abstract class DataWatcherMixin {
|
||||
@ModifyConstant(method = {"addObject", "writeWatchedListToPacketBuffer", "func_151509_a", "writeWatchableObjectToPacketBuffer"},
|
||||
constant = @Constant(intValue = 31),
|
||||
constant = @Constant(intValue = VanillaConstants.maxWatchableID),
|
||||
require = 4)
|
||||
private static int extend1(int constant) {
|
||||
return 127;
|
||||
return ExtendedConstants.maxWatchableID;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "writeWatchableObjectToPacketBuffer",
|
||||
constant = @Constant(intValue = 5, ordinal = 0),
|
||||
constant = @Constant(intValue = VanillaConstants.watchableBits, ordinal = 0),
|
||||
require = 1)
|
||||
private static int extend2(int constant) {
|
||||
return 7;
|
||||
return ExtendedConstants.watchableBits;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "writeWatchableObjectToPacketBuffer",
|
||||
constant = @Constant(intValue = 255, ordinal = 0),
|
||||
constant = @Constant(intValue = VanillaConstants.watchableMask, ordinal = 0),
|
||||
require = 1)
|
||||
private static int extend3(int constant) {
|
||||
return 1023;
|
||||
return ExtendedConstants.watchableMask;
|
||||
}
|
||||
|
||||
@Redirect(method = "writeWatchableObjectToPacketBuffer",
|
||||
@@ -59,33 +61,33 @@ public abstract class DataWatcherMixin {
|
||||
watchables = new ArrayList<>();
|
||||
}
|
||||
|
||||
int var3 = (id & 896) >> 7;
|
||||
int var4 = id & 127;
|
||||
int flag = (id >> ExtendedConstants.watchableBits) & 0x7;
|
||||
int watchableID = id & ExtendedConstants.maxWatchableID;
|
||||
DataWatcher.WatchableObject watchable = null;
|
||||
switch(var3) {
|
||||
switch(flag) {
|
||||
case 0:
|
||||
watchable = new DataWatcher.WatchableObject(var3, var4, packet.readByte());
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readByte());
|
||||
break;
|
||||
case 1:
|
||||
watchable = new DataWatcher.WatchableObject(var3, var4, packet.readShort());
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readShort());
|
||||
break;
|
||||
case 2:
|
||||
watchable = new DataWatcher.WatchableObject(var3, var4, packet.readInt());
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readInt());
|
||||
break;
|
||||
case 3:
|
||||
watchable = new DataWatcher.WatchableObject(var3, var4, packet.readFloat());
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readFloat());
|
||||
break;
|
||||
case 4:
|
||||
watchable = new DataWatcher.WatchableObject(var3, var4, packet.readStringFromBuffer(32767));
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readStringFromBuffer(32767));
|
||||
break;
|
||||
case 5:
|
||||
watchable = new DataWatcher.WatchableObject(var3, var4, packet.readItemStackFromBuffer());
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readItemStackFromBuffer());
|
||||
break;
|
||||
case 6:
|
||||
int x = packet.readInt();
|
||||
int y = packet.readInt();
|
||||
int z = packet.readInt();
|
||||
watchable = new DataWatcher.WatchableObject(var3, var4, new ChunkCoordinates(x, y, z));
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, new ChunkCoordinates(x, y, z));
|
||||
}
|
||||
|
||||
watchables.add(watchable);
|
||||
|
||||
+37
-14
@@ -16,7 +16,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorageMixin {
|
||||
@Shadow private int blockRefCount;
|
||||
@Shadow private int tickRefCount;
|
||||
private short[] block16BArray;
|
||||
private short[] lsbArray;
|
||||
private byte[] msbArray;
|
||||
|
||||
@Override
|
||||
public void setBlockRefCount(int value) {
|
||||
@@ -29,15 +30,36 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[] get16B() {
|
||||
return block16BArray;
|
||||
public short[] getLSB() {
|
||||
return new short[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getMSB() {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
@Inject(method = "<init>",
|
||||
at = @At(value = "RETURN"),
|
||||
require = 1)
|
||||
private void init(CallbackInfo ci) {
|
||||
block16BArray = Hooks.create16BArray();
|
||||
lsbArray = new short[16 * 16 * 16];
|
||||
msbArray = new byte[16 * 16 * 16];
|
||||
}
|
||||
|
||||
private 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,8 +67,8 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
* @reason Direct port from dumped code
|
||||
*/
|
||||
@Overwrite
|
||||
public Block getBlockByExtId(int var1, int var2, int var3) {
|
||||
return Hooks.getBlock(this, var1, var2, var3);
|
||||
public Block getBlockByExtId(int x, int y, int z) {
|
||||
return Block.getBlockById(getID(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,24 +76,25 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
* @reason Direct port from dumped code
|
||||
*/
|
||||
@Overwrite
|
||||
public void func_150818_a(int var1, int var2, int var3, Block var4) {
|
||||
Block var5 = this.getBlockByExtId(var1, var2, var3);
|
||||
if (var5 != Blocks.air) {
|
||||
public void func_150818_a(int x, int y, int z, Block newBlock) {
|
||||
Block oldBlock = this.getBlockByExtId(x, y, z);
|
||||
if (oldBlock != Blocks.air) {
|
||||
--this.blockRefCount;
|
||||
if (var5.getTickRandomly()) {
|
||||
if (oldBlock.getTickRandomly()) {
|
||||
--this.tickRefCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (var4 != Blocks.air) {
|
||||
if (newBlock != Blocks.air) {
|
||||
++this.blockRefCount;
|
||||
if (var4.getTickRandomly()) {
|
||||
if (newBlock.getTickRandomly()) {
|
||||
++this.tickRefCount;
|
||||
}
|
||||
}
|
||||
|
||||
int var6 = Hooks.getIdFromBlockWithCheck(var4, var5);
|
||||
Hooks.setBlockId(this, var1, var2, var3, var6);
|
||||
int blockID = Hooks.getIdFromBlockWithCheck(newBlock, oldBlock);
|
||||
setID(x, y, z, blockID);
|
||||
Hooks.setBlockId(this, x, y, z, blockID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.server.management.ItemInWorldManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -8,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@Mixin(ItemInWorldManager.class)
|
||||
public abstract class ItemInWorldManagerMixin {
|
||||
@ModifyConstant(method = "tryHarvestBlock",
|
||||
constant = @Constant(intValue = 12, ordinal = 0),
|
||||
constant = @Constant(intValue = VanillaConstants.bitsPerID, ordinal = 0),
|
||||
require = 1)
|
||||
private int extend1(int constant) {
|
||||
return 16;
|
||||
return ExtendedConstants.bitsPerID;
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -1,5 +1,8 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.asm.Constants;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -8,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
public abstract class PlayerControllerMPMixin {
|
||||
@ModifyConstant(method = "onPlayerDestroyBlock",
|
||||
constant = @Constant(intValue = 12, ordinal = 0),
|
||||
constant = @Constant(intValue = VanillaConstants.bitsPerID, ordinal = 0),
|
||||
require = 1)
|
||||
private int extend1(int constant) {
|
||||
return 16;
|
||||
return ExtendedConstants.bitsPerID;
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -1,6 +1,9 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.Hooks;
|
||||
import com.falsepattern.endlessids.asm.Constants;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import net.minecraft.network.play.server.S21PacketChunkData;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
@@ -12,18 +15,19 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(S21PacketChunkData.class)
|
||||
public abstract class S21PacketChunkDataMixin {
|
||||
|
||||
@ModifyConstant(method = {"<clinit>", "func_149275_c"},
|
||||
constant = @Constant(intValue = 0x30100),
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerChunk),
|
||||
require = 1)
|
||||
private static int increasePacketSize(int constant) {
|
||||
return constant + 0x8000;
|
||||
return ExtendedConstants.bytesPerChunk;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "readPacketData",
|
||||
constant = @Constant(intValue = 0x3000),
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerEBS),
|
||||
require = 1)
|
||||
private int increaseReadSize(int constant) {
|
||||
return constant + 0x800;
|
||||
return ExtendedConstants.bytesPerEBS;
|
||||
}
|
||||
|
||||
@Redirect(method = "func_149269_a",
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ import java.io.IOException;
|
||||
|
||||
@Mixin(S22PacketMultiBlockChange.class)
|
||||
public abstract class S22PacketMultiBlockChangeMixin {
|
||||
//TODO magic number
|
||||
@ModifyConstant(method = "<init>(I[SLnet/minecraft/world/chunk/Chunk;)V",
|
||||
constant = @Constant(intValue = 4, ordinal = 0),
|
||||
require = 1)
|
||||
|
||||
+5
-2
@@ -1,5 +1,8 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.asm.Constants;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.network.play.server.S24PacketBlockAction;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -8,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@Mixin(S24PacketBlockAction.class)
|
||||
public abstract class S24PacketBlockActionMixin {
|
||||
@ModifyConstant(method = {"readPacketData", "writePacketData"},
|
||||
constant = @Constant(intValue = 4095),
|
||||
constant = @Constant(intValue = VanillaConstants.blockIDMask),
|
||||
require = 2)
|
||||
private int extend1(int constant) {
|
||||
return 65535;
|
||||
return ExtendedConstants.blockIDMask;
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.network.play.server.S26PacketMapChunkBulk;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -7,10 +9,11 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(S26PacketMapChunkBulk.class)
|
||||
public abstract class S26PacketMapChunkBulkMixin {
|
||||
//TODO magic number
|
||||
@ModifyConstant(method = "readPacketData",
|
||||
constant = @Constant(intValue = 0x2000),
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerIDPlusMetadata * 0x1000),
|
||||
require = 1)
|
||||
private int extend1(int constant) {
|
||||
return constant + 0x1000;
|
||||
return ExtendedConstants.bytesPerIDPlusMetadata * 0x1000;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.stats.StatList;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -8,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@Mixin(StatList.class)
|
||||
public abstract class StatListMixin {
|
||||
@ModifyConstant(method = "<clinit>",
|
||||
constant = @Constant(intValue = 4096),
|
||||
constant = @Constant(intValue = VanillaConstants.blockIDCount),
|
||||
require = 1)
|
||||
private static int modifyMineBlockStatArraySize(int constant) {
|
||||
return 32768;
|
||||
return ExtendedConstants.blockIDCount;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -8,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@Mixin(World.class)
|
||||
public abstract class WorldMixin {
|
||||
@ModifyConstant(method = "func_147480_a",
|
||||
constant = @Constant(intValue = 12),
|
||||
constant = @Constant(intValue = VanillaConstants.bitsPerID),
|
||||
require = 1)
|
||||
private int modifySoundShift(int original) {
|
||||
return 16;
|
||||
return ExtendedConstants.bitsPerID;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user