diff options
Diffstat (limited to 'src/main/java/ftbsc')
8 files changed, 42 insertions, 67 deletions
diff --git a/src/main/java/ftbsc/bscv/patches/BackgroundPatch.java b/src/main/java/ftbsc/bscv/patches/BackgroundPatch.java index c60ff0f..92b6710 100644 --- a/src/main/java/ftbsc/bscv/patches/BackgroundPatch.java +++ b/src/main/java/ftbsc/bscv/patches/BackgroundPatch.java @@ -20,11 +20,6 @@ import org.objectweb.asm.tree.*; import com.mojang.blaze3d.matrix.MatrixStack; public class BackgroundPatch implements ICommons { - - public static boolean shouldDrawBackground(Screen screen) { - return MinecraftForge.EVENT_BUS.post(new RenderBackgroundEvent(screen)); - } - @Cancelable public static class RenderBackgroundEvent extends Event { public final Screen screen; @@ -40,7 +35,9 @@ public class BackgroundPatch implements ICommons { MethodProxy shouldDrawBackground; @Target(of = "shouldDrawBackground") - abstract boolean shouldDrawBackground(Screen screen); + public static boolean shouldDrawBackground(Screen screen) { + return MinecraftForge.EVENT_BUS.post(new RenderBackgroundEvent(screen)); + } @Target(of = "injectCancelBackgroundHook") abstract void renderBackground(MatrixStack stack, int x); diff --git a/src/main/java/ftbsc/bscv/patches/BlockPushPatch.java b/src/main/java/ftbsc/bscv/patches/BlockPushPatch.java index b9d2075..cc35eda 100644 --- a/src/main/java/ftbsc/bscv/patches/BlockPushPatch.java +++ b/src/main/java/ftbsc/bscv/patches/BlockPushPatch.java @@ -20,17 +20,15 @@ public class BlockPushPatch { @Cancelable public static class PlayerBlockPushEvent extends Event {} - public static boolean shouldCancelBlockCollisions() { - return MinecraftForge.EVENT_BUS.post(new PlayerBlockPushEvent()); - } - @Patch(ClientPlayerEntity.class) public abstract static class BlockCollisionsOverride implements Opcodes { @Find(BlockPushPatch.class) MethodProxy shouldCancelBlockCollisions; @Target(of = "shouldCancelBlockCollisions") - abstract boolean shouldCancelBlockCollisions(); + public static boolean shouldCancelBlockCollisions() { + return MinecraftForge.EVENT_BUS.post(new PlayerBlockPushEvent()); + } @Target(of = "injectCancelCollisionsHook") abstract void moveTowardsClosestSpace(double x, double z); diff --git a/src/main/java/ftbsc/bscv/patches/BoatPatch.java b/src/main/java/ftbsc/bscv/patches/BoatPatch.java index b8a31fe..ef00f2d 100644 --- a/src/main/java/ftbsc/bscv/patches/BoatPatch.java +++ b/src/main/java/ftbsc/bscv/patches/BoatPatch.java @@ -30,28 +30,15 @@ public class BoatPatch implements ICommons { public static class Gravity extends Event { } } - public static boolean boatControl() { - return MinecraftForge.EVENT_BUS.post(new BoatEvent.Control()); - } - - public static boolean boatClampRotation() { - return MinecraftForge.EVENT_BUS.post(new BoatEvent.ClampRotation()); - } - - public static boolean boatGravityCheck(Entity entity) { - if (MC.player == null) return false; - if (MC.player.getVehicle() == null) return false; - if (MC.player.getVehicle() != entity) return false; - return MinecraftForge.EVENT_BUS.post(new BoatEvent.Gravity()); - } - @Patch(BoatEntity.class) public abstract static class BoatControlOverride implements Opcodes { @Find(BoatPatch.class) MethodProxy boatControl; @Target(of = "boatControl") - abstract boolean boatControl(); + public static boolean boatControl() { + return MinecraftForge.EVENT_BUS.post(new BoatEvent.Control()); + } @Target(of = "injectBoatControlHook") public abstract void controlBoat(); @@ -76,7 +63,9 @@ public class BoatPatch implements ICommons { MethodProxy boatClampRotation; @Target(of = "boatClampRotation") - abstract boolean boatClampRotation(); + public static boolean boatClampRotation() { + return MinecraftForge.EVENT_BUS.post(new BoatEvent.ClampRotation()); + } @Target(of = "injectRotationClampingHook") public abstract void clampRotation(Entity e); @@ -101,7 +90,12 @@ public class BoatPatch implements ICommons { MethodProxy boatGravityCheck; @Target(of = "boatGravityCheck") - abstract boolean boatGravityCheck(Entity entity); + public static boolean boatGravityCheck(Entity entity) { + if (MC.player == null) return false; + if (MC.player.getVehicle() == null) return false; + if (MC.player.getVehicle() != entity) return false; + return MinecraftForge.EVENT_BUS.post(new BoatEvent.Gravity()); + } @Target(of = "injectGravityHook") public abstract boolean isNoGravity(); diff --git a/src/main/java/ftbsc/bscv/patches/CommandsPatch.java b/src/main/java/ftbsc/bscv/patches/CommandsPatch.java index a7474a0..4f45b42 100644 --- a/src/main/java/ftbsc/bscv/patches/CommandsPatch.java +++ b/src/main/java/ftbsc/bscv/patches/CommandsPatch.java @@ -30,18 +30,15 @@ public class CommandsPatch { } } - public static void cmdBuilt(CommandDispatcher<CommandSource> dispatcher) { - MinecraftForge.EVENT_BUS.post(new CommandsBuiltEvent(dispatcher)); - } - @Patch(ClientPlayNetHandler.class) public abstract static class CommandsDispatcherCatcher implements Opcodes { @Find(CommandsPatch.class) MethodProxy cmdBuilt; - @Target(of = "cmdBuilt") - abstract void cmdBuilt(CommandDispatcher<CommandSource> dispatcher); + public static void cmdBuilt(CommandDispatcher<CommandSource> dispatcher) { + MinecraftForge.EVENT_BUS.post(new CommandsBuiltEvent(dispatcher)); + } @Target(of = "injectCommandHandler") abstract void handleCommands(SCommandListPacket pkt); diff --git a/src/main/java/ftbsc/bscv/patches/EntityPushPatch.java b/src/main/java/ftbsc/bscv/patches/EntityPushPatch.java index d425987..c40062f 100644 --- a/src/main/java/ftbsc/bscv/patches/EntityPushPatch.java +++ b/src/main/java/ftbsc/bscv/patches/EntityPushPatch.java @@ -21,20 +21,18 @@ public class EntityPushPatch implements ICommons { @Cancelable public static class PlayerEntityPushEvent extends Event {} - public static boolean shouldCancelEntityCollisions(Entity e) { - if (e.equals(MC.player)) { - return MinecraftForge.EVENT_BUS.post(new PlayerEntityPushEvent()); - } - return false; - } - @Patch(Entity.class) public abstract static class EntityCollisionsOverride implements Opcodes { @Find(EntityPushPatch.class) MethodProxy shouldCancelEntityCollisions; @Target(of = "shouldCancelEntityCollisions") - abstract boolean shouldCancelEntityCollisions(Entity e); + public static boolean shouldCancelEntityCollisions(Entity e) { + if (e.equals(MC.player)) { + return MinecraftForge.EVENT_BUS.post(new PlayerEntityPushEvent()); + } + return false; + } @Target(of = "injectEntityCollisionHook") abstract void push(double x, double y, double z); diff --git a/src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java b/src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java index af8ccc1..2db811e 100644 --- a/src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java +++ b/src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java @@ -21,20 +21,18 @@ public class LiquidPushPatch implements ICommons { @Cancelable public static class PlayerLiquidPushEvent extends Event {} - public static boolean shouldCancelLiquidCollisions(PlayerEntity player) { - if (player.equals(MC.player)) { - return MinecraftForge.EVENT_BUS.post(new PlayerLiquidPushEvent()); - } - return false; - } - @Patch(PlayerEntity.class) public abstract static class LiquidCollisionsOverride implements Opcodes { @Find(LiquidPushPatch.class) MethodProxy shouldCancelLiquidCollisions; @Target(of = "shouldCancelLiquidCollisions") - abstract boolean shouldCancelLiquidCollisions(PlayerEntity player); + public static boolean shouldCancelLiquidCollisions(PlayerEntity player) { + if (player.equals(MC.player)) { + return MinecraftForge.EVENT_BUS.post(new PlayerLiquidPushEvent()); + } + return false; + } @Target(of = "injectLiquidCollisionHook") abstract boolean isPushedByFluid(); diff --git a/src/main/java/ftbsc/bscv/patches/NoSlowPatch.java b/src/main/java/ftbsc/bscv/patches/NoSlowPatch.java index f0e2c21..a100108 100644 --- a/src/main/java/ftbsc/bscv/patches/NoSlowPatch.java +++ b/src/main/java/ftbsc/bscv/patches/NoSlowPatch.java @@ -21,10 +21,6 @@ public class NoSlowPatch { @Cancelable public static class PlayerSlowDownEvent extends Event { } - public static boolean shouldSlowPlayer() { - return MinecraftForge.EVENT_BUS.post(new PlayerSlowDownEvent()); - } - @Patch(ClientPlayerEntity.class) public abstract static class SlowDownOverride implements Opcodes { @@ -32,7 +28,9 @@ public class NoSlowPatch { MethodProxy shouldSlowPlayer; @Target(of = "shouldSlowPlayer") - abstract boolean shouldSlowPlayer(); + public static boolean shouldSlowPlayer() { + return MinecraftForge.EVENT_BUS.post(new PlayerSlowDownEvent()); + } @Target(of = "injectNoSlowHook") abstract void aiStep(); diff --git a/src/main/java/ftbsc/bscv/patches/PacketPatch.java b/src/main/java/ftbsc/bscv/patches/PacketPatch.java index fbf5889..bc9b835 100644 --- a/src/main/java/ftbsc/bscv/patches/PacketPatch.java +++ b/src/main/java/ftbsc/bscv/patches/PacketPatch.java @@ -43,21 +43,15 @@ public class PacketPatch { } } - public static boolean pktIn(IPacket<?> pkt) { - return MinecraftForge.EVENT_BUS.post(new PacketEvent.Incoming(pkt)); - } - - public static boolean pktOut(IPacket<?> pkt) { - return MinecraftForge.EVENT_BUS.post(new PacketEvent.Outgoing(pkt)); - } - @Patch(NetworkManager.class) public abstract static class IncomingPacketInterceptor implements Opcodes { @Find(PacketPatch.class) MethodProxy pktIn; @Target(of = "pktIn") - abstract boolean pktIn(IPacket<?> pkt); + public static boolean pktIn(IPacket<?> pkt) { + return MinecraftForge.EVENT_BUS.post(new PacketEvent.Incoming(pkt)); + } @Target(of = "injectIncomingInterceptor") abstract void channelRead0(ChannelHandlerContext ctx, IPacket<?> pak); @@ -91,8 +85,9 @@ public class PacketPatch { MethodProxy pktOut; @Target(of = "pktOut") - abstract boolean pktOut(IPacket<?> pkt); - + public static boolean pktOut(IPacket<?> pkt) { + return MinecraftForge.EVENT_BUS.post(new PacketEvent.Outgoing(pkt)); + } @Target(of = "injectOutgoingInterceptor") public abstract void sendPacket(IPacket<?> pak, GenericFutureListener<? extends Future<? super Void>> gfl); |