2021-06-12 23:31:35 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
|
|
|
Date: Sat, 21 Jul 2018 03:11:03 -0500
|
|
|
|
Subject: [PATCH] PlayerLaunchProjectileEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/EggItem.java b/src/main/java/net/minecraft/world/item/EggItem.java
|
2024-01-21 19:37:09 +01:00
|
|
|
index 32b63407b943fb00d765dbf4e0eefb4b06f801b6..a3bd507793994e9cc87a956871a8afbb8ca9460d 100644
|
2021-06-12 23:31:35 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/EggItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/EggItem.java
|
2021-06-20 21:25:59 +02:00
|
|
|
@@ -25,21 +25,33 @@ public class EggItem extends Item {
|
2021-06-12 23:31:35 +02:00
|
|
|
|
|
|
|
entityegg.setItem(itemstack);
|
|
|
|
entityegg.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
|
|
|
|
- // CraftBukkit start
|
|
|
|
- if (!world.addFreshEntity(entityegg)) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
+ 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) entityegg.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addFreshEntity(entityegg)) {
|
|
|
|
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
|
|
|
|
+ itemstack.shrink(1);
|
|
|
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), net.minecraft.sounds.SoundEvents.EGG_THROW, net.minecraft.sounds.SoundSource.PLAYERS, 0.5F, 0.4F / (net.minecraft.world.entity.Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
|
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
+ } else {
|
|
|
|
if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
|
|
}
|
|
|
|
return InteractionResultHolder.fail(itemstack);
|
|
|
|
}
|
|
|
|
- // CraftBukkit end
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
2021-06-20 21:25:59 +02:00
|
|
|
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
2021-06-12 23:31:35 +02:00
|
|
|
|
2024-01-21 19:37:09 +01:00
|
|
|
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
|
2021-06-12 23:31:35 +02:00
|
|
|
user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
if (!user.getAbilities().instabuild) {
|
|
|
|
itemstack.shrink(1);
|
|
|
|
}
|
2024-01-21 19:37:09 +01:00
|
|
|
+ */ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
|
|
|
|
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/EnderpearlItem.java b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
2024-01-21 19:37:09 +01:00
|
|
|
index c7d4745aed77b23562cde7c68b8870fa239428d4..8c8cf8705107c95d9a4eab28b5845ae13c4ffb3c 100644
|
2021-06-12 23:31:35 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
|
|
|
@@ -25,7 +25,20 @@ public class EnderpearlItem extends Item {
|
|
|
|
|
|
|
|
entityenderpearl.setItem(itemstack);
|
|
|
|
entityenderpearl.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
|
|
|
|
- if (!world.addFreshEntity(entityenderpearl)) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
|
|
|
+ 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) entityenderpearl.getBukkitEntity());
|
2021-06-12 23:31:35 +02:00
|
|
|
+ if (event.callEvent() && world.addFreshEntity(entityenderpearl)) {
|
|
|
|
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
|
|
|
|
+ itemstack.shrink(1);
|
|
|
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (net.minecraft.world.entity.Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
|
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
+ user.getCooldowns().addCooldown(this, 20);
|
|
|
|
+ } else {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
|
|
}
|
|
|
|
@@ -33,6 +46,7 @@ public class EnderpearlItem extends Item {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-21 19:37:09 +01:00
|
|
|
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
|
2021-06-12 23:31:35 +02:00
|
|
|
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
|
|
|
user.getCooldowns().addCooldown(this, 20);
|
|
|
|
// CraftBukkit end
|
|
|
|
@@ -41,6 +55,7 @@ public class EnderpearlItem extends Item {
|
|
|
|
if (!user.getAbilities().instabuild) {
|
|
|
|
itemstack.shrink(1);
|
|
|
|
}
|
2024-01-21 19:37:09 +01:00
|
|
|
+ */ // Paper end - PlayerLaunchProjectileEvent; moved up
|
2021-06-12 23:31:35 +02:00
|
|
|
|
|
|
|
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
index fe03ef2e400b246f7f3a9333506f22b63ae28690..ad147f392e7ef151d971d462431ab67d378cc920 100644
|
2021-06-12 23:31:35 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
@@ -22,27 +22,46 @@ public class ExperienceBottleItem extends Item {
|
2021-06-12 23:31:35 +02:00
|
|
|
@Override
|
|
|
|
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
|
|
|
ItemStack itemStack = user.getItemInHand(hand);
|
2024-04-12 21:14:06 +02:00
|
|
|
- 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
|
2021-06-12 23:31:35 +02:00
|
|
|
if (!world.isClientSide) {
|
|
|
|
ThrownExperienceBottle thrownExperienceBottle = new ThrownExperienceBottle(world, user);
|
|
|
|
thrownExperienceBottle.setItem(itemStack);
|
|
|
|
thrownExperienceBottle.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.7F, 1.0F);
|
|
|
|
- world.addFreshEntity(thrownExperienceBottle);
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
+ 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.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addFreshEntity(thrownExperienceBottle)) {
|
|
|
|
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
|
|
|
|
+ itemStack.shrink(1);
|
|
|
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
2024-04-12 21:14:06 +02:00
|
|
|
+ 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)
|
|
|
|
+ );
|
2021-06-12 23:31:35 +02:00
|
|
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
+ } else {
|
|
|
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+ return InteractionResultHolder.fail(itemStack);
|
|
|
|
+ }
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
|
|
|
|
2024-01-21 19:37:09 +01:00
|
|
|
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
|
2021-06-12 23:31:35 +02:00
|
|
|
user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
if (!user.getAbilities().instabuild) {
|
|
|
|
itemStack.shrink(1);
|
|
|
|
}
|
2024-01-21 19:37:09 +01:00
|
|
|
+ */ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
|
|
|
|
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
index eb655eb01e4841ca163666f21dae00f0632a11e5..8a82b8bec014b70d672cfaae84510ed84fd2ea97 100644
|
2021-06-12 23:31:35 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
@@ -54,8 +54,12 @@ public class FireworkRocketItem extends Item {
|
|
|
|
itemStack
|
|
|
|
);
|
2021-06-12 23:31:35 +02:00
|
|
|
fireworkRocketEntity.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID(); // Paper
|
|
|
|
- level.addFreshEntity(fireworkRocketEntity);
|
|
|
|
- itemStack.shrink(1);
|
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
|
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) context.getPlayer().getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.getBukkitEntity());
|
|
|
|
+ if (!event.callEvent() || !level.addFreshEntity(fireworkRocketEntity)) return InteractionResult.PASS;
|
|
|
|
+ if (event.shouldConsume() && !context.getPlayer().getAbilities().instabuild) itemStack.shrink(1);
|
2022-12-07 19:52:24 +01:00
|
|
|
+ else if (context.getPlayer() instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) context.getPlayer()).getBukkitEntity().updateInventory();
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java b/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
index a822d82b577be20b5c8aa9ba1a4a0d6e4a493354..fec53407acc9bb95ae91e02a44ebc0e8d51355cf 100644
|
2021-06-12 23:31:35 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
@@ -23,6 +23,10 @@ public class LingeringPotionItem extends ThrowablePotionItem {
|
2021-06-12 23:31:35 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
+ InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand);
|
|
|
|
+ if (wrapper.getResult() != net.minecraft.world.InteractionResult.FAIL) {
|
2024-04-12 21:14:06 +02:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
|
|
|
world.playSound(
|
|
|
|
null,
|
|
|
|
user.getX(),
|
|
|
|
@@ -33,6 +37,9 @@ public class LingeringPotionItem extends ThrowablePotionItem {
|
|
|
|
0.5F,
|
|
|
|
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
|
|
|
);
|
2021-06-12 23:31:35 +02:00
|
|
|
- return super.use(world, user, hand);
|
2024-04-12 21:14:06 +02:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
+ }
|
|
|
|
+ return wrapper;
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/SnowballItem.java b/src/main/java/net/minecraft/world/item/SnowballItem.java
|
2024-01-21 19:37:09 +01:00
|
|
|
index d60e57e84f7d66e1858ab50ac33777feedf1c54d..bc8186a5bc3a98b35fad570729dd4ba52efab238 100644
|
2021-06-12 23:31:35 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/SnowballItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/SnowballItem.java
|
|
|
|
@@ -26,18 +26,26 @@ public class SnowballItem extends Item {
|
|
|
|
|
|
|
|
entitysnowball.setItem(itemstack);
|
|
|
|
entitysnowball.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
|
|
|
|
- if (world.addFreshEntity(entitysnowball)) {
|
|
|
|
- if (!user.getAbilities().instabuild) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
+ 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) entitysnowball.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addFreshEntity(entitysnowball)) {
|
|
|
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
itemstack.shrink(1);
|
2024-01-21 19:37:09 +01:00
|
|
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper - PlayerLaunchProjectileEvent
|
|
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.SNOWBALL_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();
|
2024-01-21 19:37:09 +01:00
|
|
|
+ } else { // Paper - PlayerLaunchProjectileEvent
|
|
|
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper - PlayerLaunchProjectileEvent
|
|
|
|
+ return InteractionResultHolder.fail(itemstack); // Paper - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2024-01-21 19:37:09 +01:00
|
|
|
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
|
2021-06-12 23:31:35 +02:00
|
|
|
user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
// CraftBukkit start - moved up
|
|
|
|
/*
|
|
|
|
@@ -45,6 +53,7 @@ public class SnowballItem extends Item {
|
2021-11-23 16:04:41 +01:00
|
|
|
itemstack.shrink(1);
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
|
|
|
*/
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
|
|
|
|
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/SplashPotionItem.java b/src/main/java/net/minecraft/world/item/SplashPotionItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
index 935c34ba7eb14348becdd3ac0c29766abf7ca614..73bac60b3bf6d20d415a8250d0426251c0c3265b 100644
|
2021-06-12 23:31:35 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/SplashPotionItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/SplashPotionItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
@@ -14,6 +14,10 @@ public class SplashPotionItem extends ThrowablePotionItem {
|
2021-06-12 23:31:35 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
+ InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand);
|
|
|
|
+ if (wrapper.getResult() != net.minecraft.world.InteractionResult.FAIL) {
|
2024-04-12 21:14:06 +02:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
|
|
|
world.playSound(
|
|
|
|
null,
|
|
|
|
user.getX(),
|
|
|
|
@@ -24,6 +28,9 @@ public class SplashPotionItem extends ThrowablePotionItem {
|
|
|
|
0.5F,
|
|
|
|
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
|
|
|
);
|
2021-06-12 23:31:35 +02:00
|
|
|
- return super.use(world, user, hand);
|
2024-04-12 21:14:06 +02:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
+ }
|
|
|
|
+ return wrapper;
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
2024-01-21 19:37:09 +01:00
|
|
|
index 0673f62f25532955f3552b64f122e644d42027e4..f47f793c62a919fb65c081ddb82d597a978d3b20 100644
|
2021-06-12 23:31:35 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
|
|
|
@@ -19,13 +19,31 @@ public class ThrowablePotionItem extends PotionItem {
|
|
|
|
ThrownPotion thrownPotion = new ThrownPotion(world, user);
|
|
|
|
thrownPotion.setItem(itemStack);
|
|
|
|
thrownPotion.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.5F, 1.0F);
|
|
|
|
- world.addFreshEntity(thrownPotion);
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
+ 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) thrownPotion.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addFreshEntity(thrownPotion)) {
|
|
|
|
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
|
|
|
|
+ itemStack.shrink(1);
|
|
|
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
+ } else {
|
|
|
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+ return InteractionResultHolder.fail(itemStack);
|
|
|
|
+ }
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2021-06-12 23:31:35 +02:00
|
|
|
}
|
|
|
|
|
2024-01-21 19:37:09 +01:00
|
|
|
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
|
2021-06-12 23:31:35 +02:00
|
|
|
user.awardStat(Stats.ITEM_USED.get(this));
|
|
|
|
if (!user.getAbilities().instabuild) {
|
|
|
|
itemStack.shrink(1);
|
|
|
|
}
|
|
|
|
+ */ // Paper end
|
|
|
|
|
|
|
|
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
|
|
|
}
|
2022-11-03 19:43:50 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/TridentItem.java b/src/main/java/net/minecraft/world/item/TridentItem.java
|
2024-04-12 21:14:06 +02:00
|
|
|
index f46d0015d707e6708b9e19cc8f20fad5d3bd590b..a792c7b7a6179aa88fc473b27ef0ca13bd91a395 100644
|
2022-11-03 19:43:50 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/TridentItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/TridentItem.java
|
2023-12-05 23:12:48 +01:00
|
|
|
@@ -83,21 +83,26 @@ public class TridentItem extends Item implements Vanishable {
|
2022-11-03 19:43:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
- if (!world.addFreshEntity(entitythrowntrident)) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
2022-11-03 19:43:50 +01:00
|
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), (org.bukkit.entity.Projectile) entitythrowntrident.getBukkitEntity());
|
|
|
|
+ if (!event.callEvent() || !world.addFreshEntity(entitythrowntrident)) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - PlayerLaunchProjectileEvent
|
2022-11-03 19:43:50 +01:00
|
|
|
if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) {
|
|
|
|
((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2023-12-05 23:12:48 +01:00
|
|
|
|
2024-01-21 19:37:09 +01:00
|
|
|
+ if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent
|
2022-11-03 19:43:50 +01:00
|
|
|
stack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
|
|
|
entityhuman1.broadcastBreakEvent(user.getUsedItemHand());
|
|
|
|
});
|
2024-01-21 19:37:09 +01:00
|
|
|
+ } // Paper - PlayerLaunchProjectileEvent
|
2023-12-05 23:12:48 +01:00
|
|
|
entitythrowntrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved
|
2022-11-03 19:43:50 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
world.playSound((Player) null, (Entity) entitythrowntrident, SoundEvents.TRIDENT_THROW, SoundSource.PLAYERS, 1.0F, 1.0F);
|
|
|
|
- if (!entityhuman.getAbilities().instabuild) {
|
2024-01-21 19:37:09 +01:00
|
|
|
+ if (event.shouldConsume() && !entityhuman.getAbilities().instabuild) { // Paper - PlayerLaunchProjectileEvent
|
2022-11-03 19:43:50 +01:00
|
|
|
entityhuman.getInventory().removeItem(stack);
|
|
|
|
}
|
|
|
|
// CraftBukkit start - SPIGOT-5458 also need in this branch :(
|