Browse Source

0.1.7

master
Adrian Siekierka 3 months ago
parent
commit
e0da173ace

+ 19
- 19
build.gradle View File

@@ -22,7 +22,7 @@ apply plugin: 'net.minecrell.licenser'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = "0.1.6"
version = "0.1.7"
group = "pl.asie.charset.patches"
archivesBaseName = "CharsetPatches"
@@ -38,12 +38,12 @@ dependencies {
}
minecraft {
version = "1.12.2-14.23.4.2739"
version = "1.12.2-14.23.5.2838"
runDir = "run"
useDepAts = true
makeObfSourceJar = false
mappings = "snapshot_20180722"
mappings = "stable_39"
replace '@VERSION@', project.version
replace '@MC_VERSION@', version
@@ -51,14 +51,14 @@ minecraft {
repositories {
mavenCentral()
maven {
name = "Elytra Maven"
url = "https://repo.elytradev.com"
ivy {
name 'asie dependency mirror'
artifactPattern "http://asie.pl/javadeps/[module]-[revision](-[classifier]).[ext]"
}
}
dependencies {
deobfCompile "pl.asie.charset:charset:0.5.0.140"
deobfCompile name: "charset", version: "0560alpha"
}
license {
@@ -108,17 +108,17 @@ if (file('private.gradle').exists()) {
apply from: 'private.gradle'
}
task signJar(type: SignJar, dependsOn: jar) {
onlyIf {
project.hasProperty('keyStore')
}
//task signJar(type: SignJar, dependsOn: jar) {
// onlyIf {
// project.hasProperty('keyStore')
// }
keyStore = project.keyStore
alias = project.keyStoreAlias
storePass = project.keyStorePass
keyPass = project.keyStoreKeyPass
inputFile = jar.archivePath
outputFile = jar.archivePath
}
// keyStore = project.keyStore
// alias = project.keyStoreAlias
// storePass = project.keyStorePass
// keyPass = project.keyStoreKeyPass
// inputFile = jar.archivePath
// outputFile = jar.archivePath
//}
build.dependsOn(signJar)
//build.dependsOn(signJar)

+ 37
- 0
src/main/java/pl/asie/charset/patches/CanPushHooks.java View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017, 2018 Adrian Siekierka
*
* This file is part of CharsetPatches.
*
* CharsetPatches is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CharsetPatches is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CharsetPatches. If not, see <http://www.gnu.org/licenses/>.
*/

package pl.asie.charset.patches;

import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import pl.asie.charset.lib.block.IPatchCanPushListener;

public class CanPushHooks {
public static boolean canPush(IBlockState blockStateIn, World worldIn, BlockPos pos, EnumFacing facing, boolean destroyBlocks, EnumFacing p_185646_5_) {
if (blockStateIn.getBlock() instanceof IPatchCanPushListener) {
return ((IPatchCanPushListener) blockStateIn.getBlock()).charsetCanPushByPiston(blockStateIn, worldIn, pos, facing, destroyBlocks, p_185646_5_);
}

return false;
}

}

+ 6
- 1
src/main/java/pl/asie/charset/patches/CharsetPatchTransformer.java View File

@@ -26,6 +26,7 @@ import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRema
import org.objectweb.asm.*;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.util.TraceClassVisitor;
import pl.asie.charset.patches.logic.CanPushLogic;
import pl.asie.charset.patches.logic.LaserRedstoneLogic;
import pl.asie.charset.patches.logic.LockHookLogic;

@@ -108,11 +109,15 @@ public class CharsetPatchTransformer implements IClassTransformer {
ClassReader reader = new ClassReader(basicClass);

boolean applyLockHook = CharsetPatchwork.LOCKS_BLOCK_CAPABILITIES && isExtends(transformedName, "net.minecraft.tileentity.TileEntity");
boolean applyPushHook = transformedName.equals("net.minecraft.block.BlockPistonBase");
boolean requiresClassNode = applyLockHook;
ClassNode node = new ClassNode();
ClassWriter writer = new ClassWriter(0);
ClassWriter writer = new ClassWriter(applyPushHook ? ClassWriter.COMPUTE_FRAMES : 0);

ClassVisitor target = requiresClassNode ? node : writer;
if (applyPushHook) {
target = new CanPushLogic.MyClassVisitor(Opcodes.ASM5, target);
}
if (CharsetPatchwork.LASER_REDSTONE) {
target = new LaserRedstoneLogic.MyClassVisitor(Opcodes.ASM5, target);
}

+ 96
- 0
src/main/java/pl/asie/charset/patches/logic/CanPushLogic.java View File

@@ -0,0 +1,96 @@
/*
* Copyright (c) 2017, 2018 Adrian Siekierka
*
* This file is part of CharsetPatches.
*
* CharsetPatches is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CharsetPatches is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CharsetPatches. If not, see <http://www.gnu.org/licenses/>.
*/

package pl.asie.charset.patches.logic;

import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import static org.objectweb.asm.Opcodes.*;

public class CanPushLogic {
private CanPushLogic() {

}

public static class MyClassVisitor extends ClassVisitor {
public MyClassVisitor(int api, ClassVisitor cv) {
super(api, cv);
}

@Override
public MethodVisitor visitMethod(int access, String name, String desc,
String signature, String[] exceptions) {
if ("func_185646_a".equals(name) || "canPush".equals(name)) {
System.out.println("[CanPushLogic] Patching " + name + "!");

return new CanPushLogic.MyMethodVisitor(api, "func_185646_a".equals(name), super.visitMethod(access, name, desc, signature, exceptions));
} else {
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
}

public static class MyMethodVisitor extends MethodVisitor {
private final boolean isSrg;
private boolean first = true;

public MyMethodVisitor(int api, boolean srg, MethodVisitor mv) {
super(api, mv);
this.isSrg = srg;
}

@Override
public void visitMethodInsn(int opcode, String owner, String name,
String desc, boolean itf) {
if (first) {

first = false;
Label l0 = new Label();
super.visitLabel(l0);
super.visitLineNumber(4000, l0);
super.visitVarInsn(ALOAD, 0);
super.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/block/state/IBlockState", isSrg ? "fync_177230_c" : "getBlock", "()Lnet/minecraft/block/Block;", true);
super.visitTypeInsn(INSTANCEOF, "pl/asie/charset/lib/block/IPatchCanPushListener");
Label l1 = new Label();
super.visitJumpInsn(IFEQ, l1);
Label l2 = new Label();
super.visitLabel(l2);
super.visitLineNumber(4001, l2);
super.visitVarInsn(ALOAD, 0);
super.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/block/state/IBlockState", isSrg ? "fync_177230_c" : "getBlock", "()Lnet/minecraft/block/Block;", true);
super.visitTypeInsn(CHECKCAST, "pl/asie/charset/lib/block/IPatchCanPushListener");
super.visitVarInsn(ALOAD, 0);
super.visitVarInsn(ALOAD, 1);
super.visitVarInsn(ALOAD, 2);
super.visitVarInsn(ALOAD, 3);
super.visitVarInsn(ILOAD, 4);
super.visitVarInsn(ALOAD, 5);
super.visitMethodInsn(INVOKEINTERFACE, "pl/asie/charset/lib/block/IPatchCanPushListener", "charsetCanPushByPiston", "(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;ZLnet/minecraft/util/EnumFacing;)Z", true);
super.visitInsn(IRETURN);
super.visitLabel(l1);
super.visitLineNumber(4002, l1);
super.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
}

super.visitMethodInsn(opcode, owner, name, desc, itf);
}
}
}

+ 12
- 1
src/main/java/pl/asie/charset/patches/logic/LockHookLogic.java View File

@@ -20,6 +20,7 @@
package pl.asie.charset.patches.logic;

import com.google.common.io.ByteStreams;
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
@@ -86,7 +87,7 @@ public final class LockHookLogic {
MethodInsnNode methodInsnNode = (MethodInsnNode) node;
if (methodInsnNode.name.equals(srcMethod.name) && methodInsnNode.desc.equals(srcMethod.desc)) {
if (CharsetPatchTransformer.isExtends(methodInsnNode.owner.replace('/', '.'), baseClassName.replace('/', '.'))) {
methodInsnNode.name += suffix;
methodInsnNode.name = postCharsetify(methodInsnNode);
}
}
}
@@ -176,6 +177,16 @@ public final class LockHookLogic {
return newMethod;
}

private static String postCharsetify(MethodInsnNode methodInsnNode) {
if (methodInsnNode.name.equals("func_180461_b")) {
return "canExtractItem_postCharset";
} else if (methodInsnNode.name.equals("func_180462_a")) {
return "canInsertItem_postCharset";
} else {
return methodInsnNode.name + "_postCharset";
}
}

public static void patch(ClassNode target, String type, boolean isBase) {
initialize();


Loading…
Cancel
Save