geforkt von Mirrors/Paper
ef0e5a642d
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 9ae3f10f SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API 48c0c547 PR-786: Add methods to get sounds from entities CraftBukkit Changes: 5cc9c022a SPIGOT-7152: Handle hand item changing during air interact event 4ffa1acf6 SPIGOT-7154: Players get kicked when interacting with a conversation 4daa21123 SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API e5d6a9bbf PR-1100: Add methods to get sounds from entities b7e9f1c8b SPIGOT-7146: Reduce use of Material switch in ItemMeta Spigot Changes: 4c157bb4 Rebuild patches
43 Zeilen
2.7 KiB
Diff
43 Zeilen
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: JRoy <joshroy126@gmail.com>
|
|
Date: Wed, 7 Oct 2020 12:04:01 -0400
|
|
Subject: [PATCH] Add EntityLoadCrossbowEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/CrossbowItem.java b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
index d86ec8c4c1c3e7974463a545d80ed9744de0fbbb..3b8629d31dc7bc66debe9c56593fbd071a6ddd11 100644
|
|
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
@@ -88,7 +88,14 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
|
|
int j = this.getUseDuration(stack) - remainingUseTicks;
|
|
float f = CrossbowItem.getPowerForTime(j, stack);
|
|
|
|
- if (f >= 1.0F && !CrossbowItem.isCharged(stack) && CrossbowItem.tryLoadProjectiles(user, stack)) {
|
|
+ // Paper start - EntityLoadCrossbowEvent
|
|
+ if (f >= 1.0F && !CrossbowItem.isCharged(stack) /*&& CrossbowItem.tryLoadProjectiles(entityliving, itemstack)*/) {
|
|
+ final io.papermc.paper.event.entity.EntityLoadCrossbowEvent event = new io.papermc.paper.event.entity.EntityLoadCrossbowEvent(user.getBukkitLivingEntity(), stack.asBukkitMirror(), user.getUsedItemHand() == InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND);
|
|
+ if (!event.callEvent() || !tryLoadProjectiles(user, stack, event.shouldConsumeItem())) {
|
|
+ if (user instanceof ServerPlayer player) player.containerMenu.sendAllDataToRemote();
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
CrossbowItem.setCharged(stack, true);
|
|
SoundSource soundcategory = user instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE;
|
|
|
|
@@ -98,9 +105,14 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
|
|
}
|
|
|
|
private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack projectile) {
|
|
+ // Paper start
|
|
+ return CrossbowItem.tryLoadProjectiles(shooter, projectile, true);
|
|
+ }
|
|
+ private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack projectile, boolean consume) {
|
|
+ // Paper end
|
|
int i = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.MULTISHOT, projectile);
|
|
int j = i == 0 ? 1 : 3;
|
|
- boolean flag = shooter instanceof Player && ((Player) shooter).getAbilities().instabuild;
|
|
+ boolean flag = !consume || shooter instanceof Player && ((Player) shooter).getAbilities().instabuild; // Paper - add consume
|
|
ItemStack itemstack1 = shooter.getProjectile(projectile);
|
|
ItemStack itemstack2 = itemstack1.copy();
|
|
|