blob: 50fb677a896b7b0bc12f99a63d427954bb423b98 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package ftbsc.bscv.patches;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
import ftbsc.lll.tools.InsnSequence;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;
public class BlockPushPatch {
@Cancelable
public static class PlayerBlockPushEvent extends Event {}
public static boolean shouldCancelBlockCollisions() {
return MinecraftForge.EVENT_BUS.post(new PlayerBlockPushEvent());
}
@Patch(value = ClientPlayerEntity.class, reason = "add hook to cancel block collisions")
public abstract static class BlockCollisionsOverride implements Opcodes {
@Target
abstract void moveTowardsClosestSpace(double x, double z);
@Injector
public void inject(ClassNode clazz, MethodNode main) {
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
is.add(new MethodInsnNode(
INVOKESTATIC,
"ftbsc/bscv/patches/BlockPushPatch",
"shouldCancelBlockCollisions",
"()Z"
));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(RETURN));
is.add(skip);
main.instructions.insert(is); // hook at top
}
}
}
|