mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-24 01:19:44 +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
+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