From 595e927ebf76b1df5aa05e005287347033693da1 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Wed, 17 Jun 2020 13:41:51 +0800 Subject: [PATCH] Make sure all mixin cancel has cancellable=true. This should have an AP check. --- .../core/entity/monster/CreeperEntityMixin.java | 4 ++-- .../mixin/core/entity/monster/ZombieEntityMixin.java | 2 +- .../common/mixin/core/item/BucketItemMixin.java | 4 ++-- .../core/network/play/ServerPlayNetHandlerMixin.java | 12 ++++++------ .../mixin/v1_15/entity/LivingEntityMixin_1_15.java | 2 +- .../core/block/RedstoneLampBlockMixin_1_14.java | 2 +- .../v1_14/core/block/RedstoneOreBlockMixin_1_14.java | 2 +- .../v1_14/core/entity/LivingEntityMixin_1_14.java | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/CreeperEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/CreeperEntityMixin.java index e4ec5693..4edc8524 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/CreeperEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/CreeperEntityMixin.java @@ -2,6 +2,7 @@ package io.izzel.arclight.common.mixin.core.entity.monster; import io.izzel.arclight.common.bridge.entity.monster.CreeperEntityBridge; import io.izzel.arclight.common.bridge.world.WorldBridge; +import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin; import net.minecraft.entity.AreaEffectCloudEntity; import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.monster.CreeperEntity; @@ -22,7 +23,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin; import java.util.Collection; @@ -36,7 +36,7 @@ public abstract class CreeperEntityMixin extends CreatureEntityMixin implements @Shadow private int timeSinceIgnited; // @formatter:on - @Inject(method = "onStruckByLightning", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/monster/CreeperEntity;dataManager:Lnet/minecraft/network/datasync/EntityDataManager;")) + @Inject(method = "onStruckByLightning", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/monster/CreeperEntity;dataManager:Lnet/minecraft/network/datasync/EntityDataManager;")) private void arclight$lightningBolt(LightningBoltEntity lightningBolt, CallbackInfo ci) { if (CraftEventFactory.callCreeperPowerEvent((CreeperEntity) (Object) this, lightningBolt, CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { ci.cancel(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ZombieEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ZombieEntityMixin.java index 781ad85d..0590dc52 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ZombieEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ZombieEntityMixin.java @@ -66,7 +66,7 @@ public abstract class ZombieEntityMixin extends CreatureEntityMixin { private void arclight$transformPre(VillagerEntity villagerEntity) { } - @Inject(method = "onKillEntity", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z")) + @Inject(method = "onKillEntity", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z")) private void arclight$transformInfection(LivingEntity entityLivingIn, CallbackInfo ci, VillagerEntity villagerEntity, ZombieVillagerEntity zombieVillagerEntity) { if (CraftEventFactory.callEntityTransformEvent(villagerEntity, zombieVillagerEntity, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) { ci.cancel(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BucketItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BucketItemMixin.java index 05c3c6df..99938824 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BucketItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BucketItemMixin.java @@ -39,7 +39,7 @@ public abstract class BucketItemMixin { @Shadow public abstract boolean tryPlaceContainedLiquid(@javax.annotation.Nullable PlayerEntity player, World worldIn, BlockPos posIn, @javax.annotation.Nullable BlockRayTraceResult p_180616_4_); // @formatter:on - @Inject(method = "onItemRightClick", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/IBucketPickupHandler;pickupFluid(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/fluid/Fluid;")) + @Inject(method = "onItemRightClick", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/IBucketPickupHandler;pickupFluid(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/fluid/Fluid;")) private void arclight$bucketFill(World worldIn, PlayerEntity playerIn, Hand handIn, CallbackInfoReturnable> cir, ItemStack stack, RayTraceResult result) { BlockPos pos = ((BlockRayTraceResult) result).getPos(); BlockState state = worldIn.getBlockState(pos); @@ -94,7 +94,7 @@ public abstract class BucketItemMixin { private transient BlockPos arclight$click; private transient ItemStack arclight$stack; - @Inject(method = "tryPlaceContainedLiquid", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;doesWaterVaporize()Z")) + @Inject(method = "tryPlaceContainedLiquid", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;doesWaterVaporize()Z")) private void arclight$bucketEmpty(PlayerEntity player, World worldIn, BlockPos posIn, BlockRayTraceResult p_180616_4_, CallbackInfoReturnable cir) { if (player != null) { PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(worldIn, player, posIn, arclight$click, arclight$direction, arclight$stack); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/play/ServerPlayNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/play/ServerPlayNetHandlerMixin.java index 54122339..54860c9d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/play/ServerPlayNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/play/ServerPlayNetHandlerMixin.java @@ -384,7 +384,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB this.player.getServerWorld().getChunkProvider().updatePlayerPosition(this.player); } - @Inject(method = "processConfirmTeleport", at = @At(value = "FIELD", target = "Lnet/minecraft/network/play/ServerPlayNetHandler;teleportId:I")) + @Inject(method = "processConfirmTeleport", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/network/play/ServerPlayNetHandler;teleportId:I")) private void arclight$confirm(CConfirmTeleportPacket packetIn, CallbackInfo ci) { if (this.targetPos == null) { ci.cancel(); @@ -1078,7 +1078,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB private static final Set sneakKeys = ImmutableSet.of("START_SNEAKING", "PRESS_SHIFT_KEY"); private static final Set standKeys = ImmutableSet.of("STOP_SNEAKING", "RELEASE_SHIFT_KEY"); - @Inject(method = "processEntityAction", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ServerPlayerEntity;markPlayerActive()V")) + @Inject(method = "processEntityAction", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ServerPlayerEntity;markPlayerActive()V")) private void arclight$toggleAction(CEntityActionPacket packetIn, CallbackInfo ci) { if (this.player.removed) { ci.cancel(); @@ -1178,7 +1178,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } } - @Inject(method = "processCloseWindow", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ServerPlayerEntity;closeContainer()V")) + @Inject(method = "processCloseWindow", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ServerPlayerEntity;closeContainer()V")) private void arclight$invClose(CCloseWindowPacket packetIn, CallbackInfo ci) { if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { ci.cancel(); @@ -1499,7 +1499,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } } - @Inject(method = "processEnchantItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ServerPlayerEntity;markPlayerActive()V")) + @Inject(method = "processEnchantItem", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ServerPlayerEntity;markPlayerActive()V")) private void arclight$noEnchant(CEnchantItemPacket packetIn, CallbackInfo ci) { if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) { ci.cancel(); @@ -1574,14 +1574,14 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } } - @Inject(method = "processConfirmTransaction", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue(Lnet/minecraft/network/IPacket;Lnet/minecraft/network/INetHandler;Lnet/minecraft/world/server/ServerWorld;)V")) + @Inject(method = "processConfirmTransaction", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue(Lnet/minecraft/network/IPacket;Lnet/minecraft/network/INetHandler;Lnet/minecraft/world/server/ServerWorld;)V")) private void arclight$noTransaction(CConfirmTransactionPacket packetIn, CallbackInfo ci) { if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) { ci.cancel(); } } - @Inject(method = "processUpdateSign", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ServerPlayerEntity;markPlayerActive()V")) + @Inject(method = "processUpdateSign", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ServerPlayerEntity;markPlayerActive()V")) private void arclight$noSignEdit(CUpdateSignPacket packetIn, CallbackInfo ci) { if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) { ci.cancel(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/LivingEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/LivingEntityMixin_1_15.java index 9d7a6577..82cfd9be 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/LivingEntityMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/LivingEntityMixin_1_15.java @@ -232,7 +232,7 @@ public abstract class LivingEntityMixin_1_15 extends EntityMixin_1_15 implements return removeActivePotionEffect(potioneffectin); } - @Inject(method = "removeActivePotionEffect", at = @At("HEAD")) + @Inject(method = "removeActivePotionEffect", cancellable = true, at = @At("HEAD")) public void arclight$clearActive(Effect effect, CallbackInfoReturnable cir) { EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); if (isTickingEffects) { diff --git a/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/block/RedstoneLampBlockMixin_1_14.java b/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/block/RedstoneLampBlockMixin_1_14.java index 01471226..424d3c89 100644 --- a/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/block/RedstoneLampBlockMixin_1_14.java +++ b/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/block/RedstoneLampBlockMixin_1_14.java @@ -15,7 +15,7 @@ import java.util.Random; @Mixin(RedstoneLampBlock.class) public class RedstoneLampBlockMixin_1_14 { - @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) + @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) private void arclight$redstoneChange(BlockState state, World worldIn, BlockPos pos, Random rand, CallbackInfo ci) { if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) { ci.cancel(); diff --git a/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/block/RedstoneOreBlockMixin_1_14.java b/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/block/RedstoneOreBlockMixin_1_14.java index 2e4c17d2..56089e96 100644 --- a/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/block/RedstoneOreBlockMixin_1_14.java +++ b/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/block/RedstoneOreBlockMixin_1_14.java @@ -38,7 +38,7 @@ public abstract class RedstoneOreBlockMixin_1_14 { arclight$entity = player; } - @Inject(method = "onEntityWalk", at = @At(value = "HEAD")) + @Inject(method = "onEntityWalk", cancellable = true, at = @At(value = "HEAD")) public void arclight$entityInteract(World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) { if (entityIn instanceof PlayerEntity) { PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(((PlayerEntity) entityIn), Action.PHYSICAL, pos, null, null, null); diff --git a/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/entity/LivingEntityMixin_1_14.java b/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/entity/LivingEntityMixin_1_14.java index a7d0cd20..8fc2e554 100644 --- a/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/entity/LivingEntityMixin_1_14.java +++ b/arclight-forge-1.14/src/main/java/io/izzel/arclight/impl/mixin/v1_14/core/entity/LivingEntityMixin_1_14.java @@ -229,7 +229,7 @@ public abstract class LivingEntityMixin_1_14 extends EntityMixin_1_14 implements return removeActivePotionEffect(potioneffectin); } - @Inject(method = "removeActivePotionEffect", at = @At("HEAD")) + @Inject(method = "removeActivePotionEffect", cancellable = true, at = @At("HEAD")) public void arclight$clearActive(Effect effect, CallbackInfoReturnable cir) { EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); if (isTickingEffects) {