2018-07-21 10:11:03 +02:00
|
|
|
--- a/net/minecraft/world/item/ExperienceBottleItem.java
|
|
|
|
+++ b/net/minecraft/world/item/ExperienceBottleItem.java
|
2024-12-15 15:55:13 +01:00
|
|
|
@@ -21,22 +_,36 @@
|
2018-07-21 10:11:03 +02:00
|
|
|
@Override
|
2024-12-14 21:50:20 +01:00
|
|
|
public InteractionResult use(Level level, Player player, InteractionHand hand) {
|
|
|
|
ItemStack itemInHand = player.getItemInHand(hand);
|
|
|
|
- level.playSound(
|
2018-07-21 10:11:03 +02:00
|
|
|
- null,
|
2024-12-14 21:50:20 +01:00
|
|
|
- player.getX(),
|
|
|
|
- player.getY(),
|
|
|
|
- player.getZ(),
|
2018-07-21 10:11:03 +02:00
|
|
|
- SoundEvents.EXPERIENCE_BOTTLE_THROW,
|
|
|
|
- SoundSource.NEUTRAL,
|
|
|
|
- 0.5F,
|
2024-12-14 21:50:20 +01:00
|
|
|
- 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F)
|
2018-07-21 10:11:03 +02:00
|
|
|
- );
|
|
|
|
+ // Paper - PlayerLaunchProjectileEvent - moved down
|
2024-12-14 21:50:20 +01:00
|
|
|
if (level instanceof ServerLevel serverLevel) {
|
|
|
|
- Projectile.spawnProjectileFromRotation(ThrownExperienceBottle::new, serverLevel, itemInHand, player, -20.0F, 0.7F, 1.0F);
|
2018-07-21 10:11:03 +02:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2024-12-14 21:50:20 +01:00
|
|
|
+ final Projectile.Delayed<ThrownExperienceBottle> thrownExperienceBottle = Projectile.spawnProjectileFromRotationDelayed(ThrownExperienceBottle::new, serverLevel, itemInHand, player, -20.0F, 0.7F, 1.0F);
|
|
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Projectile) thrownExperienceBottle.projectile().getBukkitEntity());
|
2018-07-21 10:11:03 +02:00
|
|
|
+ if (event.callEvent() && thrownExperienceBottle.attemptSpawn()) {
|
|
|
|
+ if (event.shouldConsume()) {
|
2024-12-14 21:50:20 +01:00
|
|
|
+ itemInHand.consume(1, player);
|
2024-12-15 15:55:13 +01:00
|
|
|
+ } else {
|
|
|
|
+ player.containerMenu.sendAllDataToRemote();
|
2018-07-21 10:11:03 +02:00
|
|
|
+ }
|
|
|
|
+
|
2024-12-14 21:50:20 +01:00
|
|
|
+ level.playSound(
|
2018-07-21 10:11:03 +02:00
|
|
|
+ null,
|
2024-12-14 21:50:20 +01:00
|
|
|
+ player.getX(),
|
|
|
|
+ player.getY(),
|
|
|
|
+ player.getZ(),
|
2018-07-21 10:11:03 +02:00
|
|
|
+ SoundEvents.EXPERIENCE_BOTTLE_THROW,
|
|
|
|
+ SoundSource.NEUTRAL,
|
|
|
|
+ 0.5F,
|
2024-12-14 21:50:20 +01:00
|
|
|
+ 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F)
|
2018-07-21 10:11:03 +02:00
|
|
|
+ );
|
|
|
|
+ } else {
|
2024-12-15 15:55:13 +01:00
|
|
|
+ player.containerMenu.sendAllDataToRemote();
|
2018-07-21 10:11:03 +02:00
|
|
|
+ return InteractionResult.FAIL;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
|
|
|
}
|
|
|
|
|
2024-12-14 21:50:20 +01:00
|
|
|
- player.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
- itemInHand.consume(1, player);
|
2018-07-21 10:11:03 +02:00
|
|
|
+ // Paper - PlayerLaunchProjectileEvent - moved up
|
|
|
|
return InteractionResult.SUCCESS;
|
|
|
|
}
|
|
|
|
|