Update CraftBukkit upstream.

This commit is contained in:
IzzelAliz 2020-09-01 09:15:44 +08:00
parent c1620e704d
commit 0aad4e83ea
3 changed files with 5 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.monster.AbstractSkeletonEntity; import net.minecraft.entity.monster.AbstractSkeletonEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents; import net.minecraft.util.SoundEvents;
import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
@ -21,7 +22,7 @@ public abstract class AbstractSkeletonEntityMixin extends CreatureEntityMixin {
@Inject(method = "attackEntityWithRangedAttack", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, @Inject(method = "attackEntityWithRangedAttack", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/AbstractSkeletonEntity;playSound(Lnet/minecraft/util/SoundEvent;FF)V")) at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/AbstractSkeletonEntity;playSound(Lnet/minecraft/util/SoundEvent;FF)V"))
private void arclight$shootBow(LivingEntity target, float distanceFactor, CallbackInfo ci, ItemStack itemStack, AbstractArrowEntity arrowEntity) { private void arclight$shootBow(LivingEntity target, float distanceFactor, CallbackInfo ci, ItemStack itemStack, AbstractArrowEntity arrowEntity) {
EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent((AbstractSkeletonEntity) (Object) this, this.getHeldItemMainhand(), arrowEntity, 0.8F); EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent((AbstractSkeletonEntity) (Object) this, this.getHeldItemMainhand(), null, arrowEntity, Hand.MAIN_HAND, 0.8F, true);
if (event.isCancelled()) { if (event.isCancelled()) {
event.getProjectile().remove(); event.getProjectile().remove();
ci.cancel(); ci.cancel();

View File

@ -82,11 +82,12 @@ public abstract class BowItemMixin extends ShootableItem {
abstractarrowentity.setFire(100); abstractarrowentity.setFire(100);
} }
EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent(playerentity, itemstack, abstractarrowentity, f); EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent(playerentity, stack, itemstack, abstractarrowentity, playerentity.getActiveHand(), f, !flag1);
if (event.isCancelled()) { if (event.isCancelled()) {
event.getProjectile().remove(); event.getProjectile().remove();
return; return;
} }
flag1 = !event.shouldConsumeItem();
stack.damageItem(1, playerentity, (p_220009_1_) -> { stack.damageItem(1, playerentity, (p_220009_1_) -> {
p_220009_1_.sendBreakAnimation(playerentity.getActiveHand()); p_220009_1_.sendBreakAnimation(playerentity.getActiveHand());

View File

@ -25,7 +25,7 @@ public class CrossbowItemMixin {
@Inject(method = "fireProjectile", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;damageItem(ILnet/minecraft/entity/LivingEntity;Ljava/util/function/Consumer;)V")) @Inject(method = "fireProjectile", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;damageItem(ILnet/minecraft/entity/LivingEntity;Ljava/util/function/Consumer;)V"))
private static void arclight$entityShoot(World worldIn, LivingEntity shooter, Hand handIn, ItemStack crossbow, ItemStack projectile, float soundPitch, boolean isCreativeMode, float velocity, float inaccuracy, float projectileAngle, CallbackInfo ci, private static void arclight$entityShoot(World worldIn, LivingEntity shooter, Hand handIn, ItemStack crossbow, ItemStack projectile, float soundPitch, boolean isCreativeMode, float velocity, float inaccuracy, float projectileAngle, CallbackInfo ci,
boolean flag, ProjectileEntity proj) { boolean flag, ProjectileEntity proj) {
EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent(shooter, crossbow, proj, soundPitch); EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent(shooter, crossbow, projectile, proj, shooter.getActiveHand(), soundPitch, true);
if (event.isCancelled()) { if (event.isCancelled()) {
event.getProjectile().remove(); event.getProjectile().remove();
ci.cancel(); ci.cancel();