mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 18:50:51 +01:00
54 lines
2.7 KiB
Diff
54 lines
2.7 KiB
Diff
--- a/net/minecraft/world/item/ExperienceBottleItem.java
|
|
+++ b/net/minecraft/world/item/ExperienceBottleItem.java
|
|
@@ -21,22 +21,38 @@
|
|
@Override
|
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
|
ItemStack itemStack = user.getItemInHand(hand);
|
|
- world.playSound(
|
|
- null,
|
|
- user.getX(),
|
|
- user.getY(),
|
|
- user.getZ(),
|
|
- SoundEvents.EXPERIENCE_BOTTLE_THROW,
|
|
- SoundSource.NEUTRAL,
|
|
- 0.5F,
|
|
- 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
|
- );
|
|
+ // Paper - PlayerLaunchProjectileEvent - moved down
|
|
if (world instanceof ServerLevel serverLevel) {
|
|
- Projectile.spawnProjectileFromRotation(ThrownExperienceBottle::new, serverLevel, itemStack, user, -20.0F, 0.7F, 1.0F);
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
|
+ final Projectile.Delayed<ThrownExperienceBottle> thrownExperienceBottle = Projectile.spawnProjectileFromRotationDelayed(ThrownExperienceBottle::new, serverLevel, itemStack, user, -20.0F, 0.7F, 1.0F);
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) thrownExperienceBottle.projectile().getBukkitEntity());
|
|
+ if (event.callEvent() && thrownExperienceBottle.attemptSpawn()) {
|
|
+ if (event.shouldConsume()) {
|
|
+ itemStack.consume(1, user);
|
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+
|
|
+ world.playSound(
|
|
+ null,
|
|
+ user.getX(),
|
|
+ user.getY(),
|
|
+ user.getZ(),
|
|
+ SoundEvents.EXPERIENCE_BOTTLE_THROW,
|
|
+ SoundSource.NEUTRAL,
|
|
+ 0.5F,
|
|
+ 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
|
+ );
|
|
+ } else {
|
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+ return InteractionResult.FAIL;
|
|
+ }
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
|
}
|
|
|
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
|
- itemStack.consume(1, user);
|
|
+ // Paper - PlayerLaunchProjectileEvent - moved up
|
|
return InteractionResult.SUCCESS;
|
|
}
|
|
|