Make sure all mixin cancel has cancellable=true.

This should have an AP check.
This commit is contained in:
IzzelAliz 2020-06-17 13:41:51 +08:00
parent b6ffece228
commit 595e927ebf
8 changed files with 15 additions and 15 deletions

View File

@ -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.entity.monster.CreeperEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge; 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.AreaEffectCloudEntity;
import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.monster.CreeperEntity; 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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
import java.util.Collection; import java.util.Collection;
@ -36,7 +36,7 @@ public abstract class CreeperEntityMixin extends CreatureEntityMixin implements
@Shadow private int timeSinceIgnited; @Shadow private int timeSinceIgnited;
// @formatter:on // @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) { private void arclight$lightningBolt(LightningBoltEntity lightningBolt, CallbackInfo ci) {
if (CraftEventFactory.callCreeperPowerEvent((CreeperEntity) (Object) this, lightningBolt, CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { if (CraftEventFactory.callCreeperPowerEvent((CreeperEntity) (Object) this, lightningBolt, CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
ci.cancel(); ci.cancel();

View File

@ -66,7 +66,7 @@ public abstract class ZombieEntityMixin extends CreatureEntityMixin {
private void arclight$transformPre(VillagerEntity villagerEntity) { 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) { private void arclight$transformInfection(LivingEntity entityLivingIn, CallbackInfo ci, VillagerEntity villagerEntity, ZombieVillagerEntity zombieVillagerEntity) {
if (CraftEventFactory.callEntityTransformEvent(villagerEntity, zombieVillagerEntity, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) { if (CraftEventFactory.callEntityTransformEvent(villagerEntity, zombieVillagerEntity, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
ci.cancel(); ci.cancel();

View File

@ -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_); @Shadow public abstract boolean tryPlaceContainedLiquid(@javax.annotation.Nullable PlayerEntity player, World worldIn, BlockPos posIn, @javax.annotation.Nullable BlockRayTraceResult p_180616_4_);
// @formatter:on // @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<ActionResult<ItemStack>> cir, ItemStack stack, RayTraceResult result) { private void arclight$bucketFill(World worldIn, PlayerEntity playerIn, Hand handIn, CallbackInfoReturnable<ActionResult<ItemStack>> cir, ItemStack stack, RayTraceResult result) {
BlockPos pos = ((BlockRayTraceResult) result).getPos(); BlockPos pos = ((BlockRayTraceResult) result).getPos();
BlockState state = worldIn.getBlockState(pos); BlockState state = worldIn.getBlockState(pos);
@ -94,7 +94,7 @@ public abstract class BucketItemMixin {
private transient BlockPos arclight$click; private transient BlockPos arclight$click;
private transient ItemStack arclight$stack; 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<Boolean> cir) { private void arclight$bucketEmpty(PlayerEntity player, World worldIn, BlockPos posIn, BlockRayTraceResult p_180616_4_, CallbackInfoReturnable<Boolean> cir) {
if (player != null) { if (player != null) {
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(worldIn, player, posIn, arclight$click, arclight$direction, arclight$stack); PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(worldIn, player, posIn, arclight$click, arclight$direction, arclight$stack);

View File

@ -384,7 +384,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
this.player.getServerWorld().getChunkProvider().updatePlayerPosition(this.player); 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) { private void arclight$confirm(CConfirmTeleportPacket packetIn, CallbackInfo ci) {
if (this.targetPos == null) { if (this.targetPos == null) {
ci.cancel(); ci.cancel();
@ -1078,7 +1078,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
private static final Set<String> sneakKeys = ImmutableSet.of("START_SNEAKING", "PRESS_SHIFT_KEY"); private static final Set<String> sneakKeys = ImmutableSet.of("START_SNEAKING", "PRESS_SHIFT_KEY");
private static final Set<String> standKeys = ImmutableSet.of("STOP_SNEAKING", "RELEASE_SHIFT_KEY"); private static final Set<String> 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) { private void arclight$toggleAction(CEntityActionPacket packetIn, CallbackInfo ci) {
if (this.player.removed) { if (this.player.removed) {
ci.cancel(); 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) { private void arclight$invClose(CCloseWindowPacket packetIn, CallbackInfo ci) {
if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) {
ci.cancel(); 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) { private void arclight$noEnchant(CEnchantItemPacket packetIn, CallbackInfo ci) {
if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) { if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) {
ci.cancel(); 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) { private void arclight$noTransaction(CConfirmTransactionPacket packetIn, CallbackInfo ci) {
if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) { if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) {
ci.cancel(); 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) { private void arclight$noSignEdit(CUpdateSignPacket packetIn, CallbackInfo ci) {
if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) { if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) {
ci.cancel(); ci.cancel();

View File

@ -232,7 +232,7 @@ public abstract class LivingEntityMixin_1_15 extends EntityMixin_1_15 implements
return removeActivePotionEffect(potioneffectin); return removeActivePotionEffect(potioneffectin);
} }
@Inject(method = "removeActivePotionEffect", at = @At("HEAD")) @Inject(method = "removeActivePotionEffect", cancellable = true, at = @At("HEAD"))
public void arclight$clearActive(Effect effect, CallbackInfoReturnable<EffectInstance> cir) { public void arclight$clearActive(Effect effect, CallbackInfoReturnable<EffectInstance> cir) {
EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN);
if (isTickingEffects) { if (isTickingEffects) {

View File

@ -15,7 +15,7 @@ import java.util.Random;
@Mixin(RedstoneLampBlock.class) @Mixin(RedstoneLampBlock.class)
public class RedstoneLampBlockMixin_1_14 { 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) { private void arclight$redstoneChange(BlockState state, World worldIn, BlockPos pos, Random rand, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) { if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) {
ci.cancel(); ci.cancel();

View File

@ -38,7 +38,7 @@ public abstract class RedstoneOreBlockMixin_1_14 {
arclight$entity = player; 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) { public void arclight$entityInteract(World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
if (entityIn instanceof PlayerEntity) { if (entityIn instanceof PlayerEntity) {
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(((PlayerEntity) entityIn), Action.PHYSICAL, pos, null, null, null); PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(((PlayerEntity) entityIn), Action.PHYSICAL, pos, null, null, null);

View File

@ -229,7 +229,7 @@ public abstract class LivingEntityMixin_1_14 extends EntityMixin_1_14 implements
return removeActivePotionEffect(potioneffectin); return removeActivePotionEffect(potioneffectin);
} }
@Inject(method = "removeActivePotionEffect", at = @At("HEAD")) @Inject(method = "removeActivePotionEffect", cancellable = true, at = @At("HEAD"))
public void arclight$clearActive(Effect effect, CallbackInfoReturnable<EffectInstance> cir) { public void arclight$clearActive(Effect effect, CallbackInfoReturnable<EffectInstance> cir) {
EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN);
if (isTickingEffects) { if (isTickingEffects) {