cleanup code

This commit is contained in:
FalsePattern committed 2023-03-02 22:52:41 +01:00
1 parent c321707f0e
commit bf52cfaadf
46 files changed
+415 -384

No files matched your search

@@ -139,8 +139,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);
}
}
@@ -178,13 +178,13 @@ public class Hooks {
}
public static int readBiomeArrayFromPacket(Chunk chunk, byte[] array, int offset) {
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
short[] biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
byteToShortArray(array, offset, biomeArray, 0, biomeArray.length * 2);
return biomeArray.length * 2;
}
public static int writeBiomeArrayToPacket(Chunk chunk, byte[] array, int offset) {
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
short[] biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
shortToByteArray(biomeArray, 0, array, offset, biomeArray.length);
return biomeArray.length * 2;
}
@@ -195,7 +195,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];
@@ -10,11 +10,13 @@ import java.nio.ShortBuffer;
public class Unsafer {
public static final Unsafe UNSAFE;
static {
Field unsafeField = null;
Unsafe unsafe = null;
for (val field: Unsafe.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.getType().equals(Unsafe.class)) {
for (val field : Unsafe.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) &&
field.getType().equals(Unsafe.class)) {
unsafeField = field;
break;
}
@@ -40,9 +42,12 @@ public class Unsafer {
val sourceOffsetBytes = sourceOffset * 2;
val arrayOffsetSource = UNSAFE.arrayBaseOffset(source.getClass());
val arrayOffsetTarget = UNSAFE.arrayBaseOffset(target.getClass());
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffsetBytes, target, arrayOffsetTarget + targetOffset, (long)shorts << 1);
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffsetBytes, target, arrayOffsetTarget + targetOffset,
(long) shorts << 1);
} else {
ByteBuffer.wrap(target, targetOffset, target.length - targetOffset).asShortBuffer().put(source, sourceOffset, shorts);
ByteBuffer.wrap(target, targetOffset, target.length - targetOffset)
.asShortBuffer()
.put(source, sourceOffset, shorts);
}
}
@@ -51,9 +56,11 @@ public class Unsafer {
val targetOffsetBytes = targetOffset * 2;
val arrayOffsetSource = UNSAFE.arrayBaseOffset(source.getClass());
val arrayOffsetTarget = UNSAFE.arrayBaseOffset(target.getClass());
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffset, target, arrayOffsetTarget + targetOffsetBytes, (long)shorts << 1);
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffset, target, arrayOffsetTarget + targetOffsetBytes,
(long) shorts << 1);
} else {
ShortBuffer.wrap(target, targetOffset, target.length - targetOffset).put(ByteBuffer.wrap(source, sourceOffset, shorts * 2).asShortBuffer());
ShortBuffer.wrap(target, targetOffset, target.length - targetOffset)
.put(ByteBuffer.wrap(source, sourceOffset, shorts * 2).asShortBuffer());
}
}
}
@@ -18,7 +18,8 @@ public enum ClassEdit {
() -> GeneralConfig.extendBlockItem,
"cpw.mods.fml.common.registry.GameData",
"cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry"),
SpaceCoreModInfoGenerator(new SpaceCoreModInfoGenerator(), () -> true, "com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator");
SpaceCoreModInfoGenerator(new SpaceCoreModInfoGenerator(), () -> true,
"com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator");
private static final Map<String, ClassEdit> editMap;
@@ -18,9 +18,8 @@ import java.util.List;
public class IETransformer implements IClassTransformer {
public static final Logger logger;
public static boolean isObfuscated;
private static final List<String> blacklist = new ArrayList<>();
public static boolean isObfuscated;
static {
logger = LogManager.getLogger(Tags.MODNAME + " ASM");
@@ -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<>();
}
}
@@ -19,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;
@@ -60,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;
@@ -69,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,72 +6,63 @@ import com.falsepattern.lib.config.ConfigurationManager;
@Config(modid = Tags.MODID)
public class GeneralConfig {
static {
ConfigurationManager.selfInit();
}
@Config.Comment("WARNING: THIS CONFIG IS EXTREMELY SENSITIVE TO CHANGES, DISABLING STUFF ONCE THEY HAVE BEEN ENABLED\n" +
"CAN CORRUPT YOUR WORLD! ONLY TOUCH THIS FILE IF YOU KNOW WHAT YOU'RE DOING!\n" +
"This file should only be edited by modpack developers to finetune it for the modpack. Once an option\n" +
"has been enabled, it modifies the chunk save data format, which is (partially) compatible with\n" +
"vanilla, but removing the mod might cause block/item corruption for higher IDs.\n" +
"Additional note: Every client and server must have the exact same config, this also affects netcode.")
@Config.Comment(
"WARNING: THIS CONFIG IS EXTREMELY SENSITIVE TO CHANGES, DISABLING STUFF ONCE THEY HAVE BEEN ENABLED\n" +
"CAN CORRUPT YOUR WORLD! ONLY TOUCH THIS FILE IF YOU KNOW WHAT YOU'RE DOING!\n" +
"This file should only be edited by modpack developers to finetune it for the modpack. Once an option\n" +
"has been enabled, it modifies the chunk save data format, which is (partially) compatible with\n" +
"vanilla, but removing the mod might cause block/item corruption for higher IDs.\n" +
"Additional note: Every client and server must have the exact same config, this also affects netcode.")
@Config.DefaultString("")
public static String __NOTICE__;
@Config.Comment("Throw an exception when an invalid block is registered. FOR DEBUGGING PURPOSES")
@Config.DefaultBoolean(false)
public static boolean catchUnregisteredBlocks;
@Config.Comment("Remove invalid (corrupted) blocks from the game. FOR DEBUGGING PURPOSES")
@Config.DefaultBoolean(false)
public static boolean removeInvalidBlocks;
@Config.Comment("Extend Biome IDs. Vanilla limit is 256, new limit is 65536.")
@Config.DefaultBoolean(true)
public static boolean extendBiome;
@Config.Comment("Extend Block and Item IDs. Vanilla limit is 4096/32000, new limit is 16777216 for both.\n" +
"See also: countCorrectionBits")
@Config.DefaultBoolean(true)
public static boolean extendBlockItem;
@Config.Comment("Extend DataWatcher IDs. Vanilla limit is 31, new limit is 127.\n" +
"Disabled by default because of uncertain/weak implementation (taken from NotEnoughIDs)")
@Config.DefaultBoolean(false)
public static boolean extendDataWatcher;
@Config.Comment("Extend Enchantment IDs. Vanilla limit is 256, new limit is 32768.")
@Config.DefaultBoolean(true)
public static boolean extendEnchantment;
@Config.Comment("Extend Potion IDs. Vanilla limit is 32, new limit is 65536.")
@Config.DefaultBoolean(true)
public static boolean extendPotion;
@Config.Comment("Extends the maximum redstone signal strength.\n" +
"Only has effect with extendBlockItem enabled.\n" +
"WARNING: THIS IS HERE ONLY FOR FUN, IT WILL DEFINITELY CORRUPT YOUR WORLD!")
@Config.Comment(
"Extends the maximum redstone signal strength.\n" + "Only has effect with extendBlockItem enabled.\n" +
"WARNING: THIS IS HERE ONLY FOR FUN, IT WILL DEFINITELY CORRUPT YOUR WORLD!")
@Config.DefaultBoolean(false)
public static boolean extendRedstone;
@Config.Comment("Increases the max signal strength of redstone.\n" +
"Only has effect with both extendBlockItem and extendRedstone enabled.\n" +
"Vanilla value is 15.")
"Only has effect with both extendBlockItem and extendRedstone enabled.\n" + "Vanilla value is 15.")
@Config.RangeInt(min = 15,
max = 127)
@Config.DefaultInt(15)
public static int maxRedstone;
@Config.Comment(
"Use this to tune the amount of available block IDs.\n" +
"Minecraft contains some internal code that uses a HUGE amount of RAM with too many block IDs available.\n" +
"Notice: This does not affect ITEM IDs.\n" +
"The vanilla default is 4k block IDs, while the maximum is 16 million.\n" +
"The default setting sets it to 4k (vanilla).\n" +
"increase if necessary (when running out of BLOCK IDs in your modpack)\n" +
"Only effective if extendBlockItem is enabled.\n" +
"(0: 16M, 1: 8M, 2: 4M, 3: 2M, 4: 1M, 5: 512K, 6: 256K, 7: 128K, 8: 64K, 9: 32K, 10: 16K, 11: 8K, 12: 4K)\n")
@Config.Comment("Use this to tune the amount of available block IDs.\n" +
"Minecraft contains some internal code that uses a HUGE amount of RAM with too many block IDs available.\n" +
"Notice: This does not affect ITEM IDs.\n" +
"The vanilla default is 4k block IDs, while the maximum is 16 million.\n" +
"The default setting sets it to 4k (vanilla).\n" +
"increase if necessary (when running out of BLOCK IDs in your modpack)\n" +
"Only effective if extendBlockItem is enabled.\n" +
"(0: 16M, 1: 8M, 2: 4M, 3: 2M, 4: 1M, 5: 512K, 6: 256K, 7: 128K, 8: 64K, 9: 32K, 10: 16K, 11: 8K, 12: 4K)\n")
@Config.RangeInt(min = 0,
max = 12)
@Config.DefaultInt(12)
public static int countCorrectionBits;
static {
ConfigurationManager.selfInit();
}
}
@@ -34,14 +34,12 @@ public class ExtendedConstants {
public static final int biomeIDMask = biomeIDCount - 1;
public static final int biomeIDNull = biomeIDMask;
public static final int bytesPerBiome = (bitsPerBiome + 7) / 8;
//Chunk
public static final int bytesPerChunk =
(GeneralConfig.extendBiome ? bytesPerBiome : VanillaConstants.bytesPerBiome) * 256 +
(GeneralConfig.extendBlockItem ? bytesPerEBS : VanillaConstants.bytesPerEBS) * 16;
//DataWatcher
public static final int watchableCount = 1 << watchableBits;
public static final int maxWatchableID = watchableCount - 1;
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
//Chunk
public static final int bytesPerChunk =
(GeneralConfig.extendBiome ? bytesPerBiome : VanillaConstants.bytesPerBiome) * 256
+ (GeneralConfig.extendBlockItem ? bytesPerEBS : VanillaConstants.bytesPerEBS) * 16;
}
@@ -8,6 +8,7 @@ import java.lang.reflect.Field;
public class GalaxySpaceHelper {
private static final Field GSSpaceField;
static {
Class<?> clazz;
try {
@@ -4,21 +4,31 @@ import net.minecraft.world.chunk.NibbleArray;
public interface IExtendedBlockStorageMixin {
byte[] getB1();
void setB1(byte[] data);
NibbleArray getB2Low();
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 getStorageFlag();
@@ -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",
@@ -21,6 +21,9 @@ 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 fakeNarray;
@Shadow
private ExtendedBlockStorage[] storageArrays;
@@ -30,7 +33,7 @@ public abstract class ChunkMixin {
args = "array=length",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getSkylightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getSkylightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private int noMSBLoop(ExtendedBlockStorage[] array) {
return 0;
@@ -47,9 +50,6 @@ public abstract class ChunkMixin {
Hooks.setBlockData((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k, storageFlag);
}
//This is needed because the array is not a field, but a local, and local arraylength overriding does not exist
private static byte[][] fakeArrays;
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
@@ -62,7 +62,7 @@ public abstract class ChunkMixin {
fakeArrays[2] = new byte[16 * 16 * 16 * 4 / 2];
fakeArrays[3] = new byte[16 * 16 * 16 * 6 / 2];
}
return fakeArrays[((IExtendedBlockStorageMixin)instance).getStorageFlag()];
return fakeArrays[((IExtendedBlockStorageMixin) instance).getStorageFlag()];
}
@Redirect(method = "fillChunk",
@@ -72,9 +72,8 @@ public abstract class ChunkMixin {
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B")),
require = 1)
private void noCopy(Object src, int srcPos, Object dest, int destPos, int length) {}
private void noCopy(Object src, int srcPos, Object dest, int destPos, int length) {
}
@Inject(method = "fillChunk",
at = @At(value = "INVOKE",
@@ -85,8 +84,6 @@ public abstract class ChunkMixin {
Hooks.setBlockMeta((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k);
}
private static NibbleArray fakeNarray;
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
@@ -44,7 +44,8 @@ public abstract class NetHandlerPlayClientMixin {
int y = pos & 255;
this.clientWorldController.func_147492_c(x + chunkX, y, z + chunkZ, Block.getBlockById(id), meta);
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}
}
}
@@ -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",
@@ -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);
}
}
@@ -132,7 +132,7 @@ public abstract class AnvilChunkLoaderMixin {
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;setBlockMetadataArray(Lnet/minecraft/world/chunk/NibbleArray;)V"),
require = 1)
private void redirectBlockMetaRead(ExtendedBlockStorage instance, NibbleArray p_76668_1_) {
Hooks.readBlockMetaFromNBT((IExtendedBlockStorageMixin)instance, nbt);
Hooks.readBlockMetaFromNBT((IExtendedBlockStorageMixin) instance, nbt);
nbt = null;
}
}
@@ -27,10 +27,13 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
private int blockRefCount;
@Shadow
private int tickRefCount;
@Shadow private byte[] blockLSBArray;
@Shadow private NibbleArray blockMetadataArray;
@Shadow
private byte[] blockLSBArray;
@Shadow
private NibbleArray blockMetadataArray;
@Shadow private NibbleArray blockMSBArray;
@Shadow
private NibbleArray blockMSBArray;
private NibbleArray b2High;
private byte[] b3;
private short[] metaArray;
@@ -141,7 +144,7 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
@Overwrite
public void setExtBlockMetadata(int x, int y, int z, int meta) {
int index = y << 8 | z << 4 | x;
metaArray[index] = (short)(meta & 0xFFFF);
metaArray[index] = (short) (meta & 0xFFFF);
}
@Redirect(method = "removeInvalidBlocks",
@@ -181,13 +184,13 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
}
@Override
public void clearB2Low() {
blockMSBArray = null;
public void setB2Low(NibbleArray data) {
blockMSBArray = data;
}
@Override
public void setB2Low(NibbleArray data) {
blockMSBArray = data;
public void clearB2Low() {
blockMSBArray = null;
}
@Override
@@ -19,6 +19,9 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
private static byte[][] fakeArrays;
private static NibbleArray fakeNarray;
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;",
@@ -38,7 +41,6 @@ public abstract class S21PacketChunkDataMixin {
extracted.field_150281_c |= Hooks.getBlockData(ebs, abyte, j) << l * 2;
}
private static byte[][] fakeArrays;
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
@@ -51,7 +53,7 @@ public abstract class S21PacketChunkDataMixin {
fakeArrays[2] = new byte[16 * 16 * 16 * 4 / 2];
fakeArrays[3] = new byte[16 * 16 * 16 * 6 / 2];
}
return fakeArrays[((IExtendedBlockStorageMixin)instance).getStorageFlag()];
return fakeArrays[((IExtendedBlockStorageMixin) instance).getStorageFlag()];
}
@Redirect(method = "func_149269_a",
@@ -74,8 +76,6 @@ public abstract class S21PacketChunkDataMixin {
Hooks.getBlockMeta((IExtendedBlockStorageMixin) aextendedblockstorage[l], abyte, j);
}
private static NibbleArray fakeNarray;
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;"),
@@ -9,7 +9,8 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = BaseBlock.class,
remap = false)
public abstract class BaseBlockMixin {
@Shadow private short data;
@Shadow
private short data;
private int idExtended;
/**
@@ -58,7 +59,7 @@ public abstract class BaseBlockMixin {
} else if (data < -1) {
throw new IllegalArgumentException("Can't have a block data value below -1");
} else {
this.data = (short)data;
this.data = (short) data;
}
}
@@ -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);
}
}
@@ -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",
@@ -21,21 +21,22 @@ import java.util.zip.Inflater;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
@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;
@Shadow private static byte[] field_149286_i;
@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),
@@ -47,8 +48,8 @@ public abstract class S21PacketChunkDataMixin {
@Inject(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
ordinal = 1),
target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;",
ordinal = 1),
require = 1)
private void extendWrite(PacketBuffer p_148840_1_, CallbackInfo ci) {
p_148840_1_.writeInt(this.field_149280_d);
@@ -16,15 +16,20 @@ import java.util.zip.Inflater;
@Mixin(S26PacketMapChunkBulk.class)
public abstract class S26PacketMapChunkBulkMixin {
@Shadow private int[] field_149262_d;
@Shadow
private int[] field_149262_d;
@Shadow private byte[][] field_149260_f;
@Shadow
private byte[][] field_149260_f;
@Shadow private int[] field_149266_a;
@Shadow
private int[] field_149266_a;
@Shadow private int[] field_149264_b;
@Shadow
private int[] field_149264_b;
@Shadow private int[] field_149265_c;
@Shadow
private int[] field_149265_c;
@Inject(method = "writePacketData",
at = @At(value = "INVOKE",
@@ -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)) {