mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-12 04:57:31 +00:00
restyle code
This commit is contained in:
6 files changed
+72
-71
No files matched your search
@@ -3,7 +3,6 @@ package com.falsepattern.endlessids.asm;
|
||||
import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
|
||||
import com.falsepattern.endlessids.asm.stubpackage.Reika.DragonAPI.ModList;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.val;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
@@ -44,5 +43,6 @@ public class ASMHooks {
|
||||
return list.condition;
|
||||
}
|
||||
|
||||
public static void DragonAPIModListSuppressLogging(Object obj) {}
|
||||
public static void DragonAPIModListSuppressLogging(Object obj) {
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,7 @@ import java.util.Map;
|
||||
public enum ClassEdit {
|
||||
FmlRegistry(new FmlRegistry(), new String[]{"cpw.mods.fml.common.registry.GameData",
|
||||
"cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry"}),
|
||||
DragonAPIModList(new DragonAPIModList(), new String[]{"Reika.DragonAPI.ModList"})
|
||||
;
|
||||
DragonAPIModList(new DragonAPIModList(), new String[]{"Reika.DragonAPI.ModList"});
|
||||
|
||||
private static final Map<String, ClassEdit> editMap;
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@ package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.asm.ASMHooks;
|
||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
||||
import com.falsepattern.endlessids.mixin.plugin.MixinPlugin;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -13,7 +11,6 @@ import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.FrameNode;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.LabelNode;
|
||||
import org.objectweb.asm.tree.LineNumberNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
@@ -24,54 +21,6 @@ import java.util.List;
|
||||
|
||||
public class DragonAPIModList implements IClassNodeTransformer {
|
||||
private static final List<String> fields = Arrays.asList("condition", "itemClasses", "blockClasses");
|
||||
private void crash() {
|
||||
throw new IllegalStateException("Tweaking failed!");
|
||||
}
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
int state = 0;
|
||||
for (val field: cn.fields) {
|
||||
if (field.name.equals("__MARKER__FALSEPATTERN__MIXINPATCH__")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (val field: cn.fields) {
|
||||
if (field.name.equals("condition") && field.desc.equals("Z")) {
|
||||
field.access &= ~Opcodes.ACC_FINAL;
|
||||
state++;
|
||||
}
|
||||
if (fields.contains(field.name)) {
|
||||
field.access &= ~Opcodes.ACC_PRIVATE;
|
||||
field.access &= ~Opcodes.ACC_PROTECTED;
|
||||
field.access |= Opcodes.ACC_PUBLIC;
|
||||
state++;
|
||||
}
|
||||
}
|
||||
if (state != 4) {
|
||||
crash();
|
||||
}
|
||||
cn.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "successful", "Z", null, 0));
|
||||
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "__MARKER__FALSEPATTERN__MIXINPATCH__", "Z", null, 0));
|
||||
|
||||
int state2 = 0;
|
||||
for (val method : cn.methods) {
|
||||
if ((state2 & 1) == 0 &&
|
||||
method.name.equals("<init>") &&
|
||||
method.desc.equals("(Ljava/lang/String;ILjava/lang/String;[Ljava/lang/String;[Ljava/lang/String;)V")) {
|
||||
tweakInit(method);
|
||||
state2 |= 1;
|
||||
}
|
||||
if ((state2 & 2) == 0 &&
|
||||
method.name.equals("isLoaded") &&
|
||||
method.desc.equals("()Z")) {
|
||||
tweakIsLoaded(method);
|
||||
state2 |= 2;
|
||||
}
|
||||
}
|
||||
if (state2 != 3) {
|
||||
crash();
|
||||
}
|
||||
}
|
||||
|
||||
private static void tweakIsLoaded(MethodNode method) {
|
||||
val iterator = method.instructions.iterator();
|
||||
@@ -79,14 +28,15 @@ public class DragonAPIModList implements IClassNodeTransformer {
|
||||
iterator.next();
|
||||
iterator.next();
|
||||
iterator.next();
|
||||
iterator.set(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ASMHooks.class), "DragonAPIModListTryLoad", "(LReika/DragonAPI/ModList;)Z", false));
|
||||
iterator.set(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ASMHooks.class),
|
||||
"DragonAPIModListTryLoad", "(LReika/DragonAPI/ModList;)Z", false));
|
||||
}
|
||||
|
||||
private static void tweakInit(MethodNode method) {
|
||||
val iterator = method.instructions.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
var insn = iterator.next();
|
||||
if (insn instanceof LineNumberNode && ((LineNumberNode)insn).line == 154) {
|
||||
if (insn instanceof LineNumberNode && ((LineNumberNode) insn).line == 154) {
|
||||
//SRC:
|
||||
// L3
|
||||
// LINENUMBER 154 L3
|
||||
@@ -110,15 +60,11 @@ public class DragonAPIModList implements IClassNodeTransformer {
|
||||
// RETURN
|
||||
iterator.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
iterator.add(new VarInsnNode(Opcodes.ALOAD, 5));
|
||||
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD,
|
||||
"Reika/DragonAPI/ModList",
|
||||
"itemClasses",
|
||||
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD, "Reika/DragonAPI/ModList", "itemClasses",
|
||||
"[Ljava/lang/String;"));
|
||||
iterator.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
iterator.add(new VarInsnNode(Opcodes.ALOAD, 4));
|
||||
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD,
|
||||
"Reika/DragonAPI/ModList",
|
||||
"blockClasses",
|
||||
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD, "Reika/DragonAPI/ModList", "blockClasses",
|
||||
"[Ljava/lang/String;"));
|
||||
iterator.next();
|
||||
iterator.remove();
|
||||
@@ -129,13 +75,66 @@ public class DragonAPIModList implements IClassNodeTransformer {
|
||||
methodInsn.owner = Type.getInternalName(ASMHooks.class);
|
||||
methodInsn.name = "DragonAPIModListConstructorTweak";
|
||||
methodInsn.desc = "(LReika/DragonAPI/ModList;)V";
|
||||
iterator.add(new FrameNode(Opcodes.F_FULL, 6, new Object[] {"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER, "java/lang/String", "[Ljava/lang/String;", "[Ljava/lang/String;"}, 0, new Object[] {}));
|
||||
iterator.add(new FrameNode(Opcodes.F_FULL, 6,
|
||||
new Object[]{"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER,
|
||||
"java/lang/String", "[Ljava/lang/String;",
|
||||
"[Ljava/lang/String;"}, 0, new Object[]{}));
|
||||
iterator.add(new InsnNode(Opcodes.RETURN));
|
||||
iterator.add(new FrameNode(Opcodes.F_FULL, 6, new Object[] {"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER, "java/lang/String", "[Ljava/lang/String;", "[Ljava/lang/String;"}, 0, new Object[] {}));
|
||||
iterator.add(new FrameNode(Opcodes.F_FULL, 6,
|
||||
new Object[]{"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER,
|
||||
"java/lang/String", "[Ljava/lang/String;",
|
||||
"[Ljava/lang/String;"}, 0, new Object[]{}));
|
||||
iterator.next();
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void crash() {
|
||||
throw new IllegalStateException("Tweaking failed!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
int state = 0;
|
||||
for (val field : cn.fields) {
|
||||
if (field.name.equals("__MARKER__FALSEPATTERN__MIXINPATCH__")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (val field : cn.fields) {
|
||||
if (field.name.equals("condition") && field.desc.equals("Z")) {
|
||||
field.access &= ~Opcodes.ACC_FINAL;
|
||||
state++;
|
||||
}
|
||||
if (fields.contains(field.name)) {
|
||||
field.access &= ~Opcodes.ACC_PRIVATE;
|
||||
field.access &= ~Opcodes.ACC_PROTECTED;
|
||||
field.access |= Opcodes.ACC_PUBLIC;
|
||||
state++;
|
||||
}
|
||||
}
|
||||
if (state != 4) {
|
||||
crash();
|
||||
}
|
||||
cn.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "successful", "Z", null, 0));
|
||||
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "__MARKER__FALSEPATTERN__MIXINPATCH__", "Z", null, 0));
|
||||
|
||||
int state2 = 0;
|
||||
for (val method : cn.methods) {
|
||||
if ((state2 & 1) == 0 && method.name.equals("<init>") &&
|
||||
method.desc.equals("(Ljava/lang/String;ILjava/lang/String;[Ljava/lang/String;[Ljava/lang/String;)V")) {
|
||||
tweakInit(method);
|
||||
state2 |= 1;
|
||||
}
|
||||
if ((state2 & 2) == 0 && method.name.equals("isLoaded") && method.desc.equals("()Z")) {
|
||||
tweakIsLoaded(method);
|
||||
state2 |= 2;
|
||||
}
|
||||
}
|
||||
if (state2 != 3) {
|
||||
crash();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,6 @@ package com.falsepattern.endlessids.mixin.mixins.common.dragonapi;
|
||||
|
||||
import Reika.DragonAPI.Extras.IDType;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@@ -16,6 +15,7 @@ public abstract class IDTypeMixin {
|
||||
private static int extendBiomeIDs(int constant) {
|
||||
return ExtendedConstants.biomeIDCount - 2;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "<clinit>",
|
||||
constant = {@Constant(intValue = 4095), @Constant(intValue = 32767)},
|
||||
require = 2)
|
||||
|
||||
+6
-4
@@ -13,9 +13,11 @@ import net.minecraft.world.chunk.Chunk;
|
||||
@Mixin(value = ChunkProviderRTG.class,
|
||||
remap = false)
|
||||
public abstract class ChunkProviderRTGMixin {
|
||||
@Shadow private BiomeGenBase[] baseBiomesList;
|
||||
@Shadow
|
||||
private BiomeGenBase[] baseBiomesList;
|
||||
|
||||
@Shadow private int[] xyinverted;
|
||||
@Shadow
|
||||
private int[] xyinverted;
|
||||
|
||||
@Redirect(method = "provideChunk",
|
||||
at = @At(value = "INVOKE",
|
||||
@@ -24,9 +26,9 @@ public abstract class ChunkProviderRTGMixin {
|
||||
remap = true,
|
||||
require = 1)
|
||||
private byte[] redictBiomeArrayFillLogic(Chunk chunk) {
|
||||
short[] biomes = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
short[] biomes = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
|
||||
for(int i = 0; i < biomes.length; ++i) {
|
||||
for (int i = 0; i < biomes.length; ++i) {
|
||||
biomes[i] = (short) baseBiomesList[xyinverted[i]].biomeID;
|
||||
}
|
||||
return new byte[0];
|
||||
|
||||
@@ -79,7 +79,8 @@ public enum Mixin implements IMixin {
|
||||
//endregion CoFHLib->common
|
||||
//region DragonAPI->common
|
||||
//region DragonAPI->common->vanilla
|
||||
DragonAPIGenLayerRiverMixMixin(Side.COMMON, require(TargetedMod.DRAGONAPI), "dragonapi.vanilla.GenLayerRiverMixMixin"),
|
||||
DragonAPIGenLayerRiverMixMixin(Side.COMMON, require(TargetedMod.DRAGONAPI),
|
||||
"dragonapi.vanilla.GenLayerRiverMixMixin"),
|
||||
//endregion DragonAPI->common->vanilla
|
||||
DragonAPIGenLayerRiverEventMixin(Side.COMMON, require(TargetedMod.DRAGONAPI), "dragonapi.GenLayerRiverEventMixin"),
|
||||
DragonAPIBlockPropertiesMixin(Side.COMMON, require(TargetedMod.DRAGONAPI), "dragonapi.BlockPropertiesMixin"),
|
||||
|
||||
Reference in new issue
Block a user