2019-08-05 04:15:53 +02:00
|
|
|
From 264d17e1439c26acd197336ce546e691460d1ebd Mon Sep 17 00:00:00 2001
|
2018-08-17 23:55:40 +02:00
|
|
|
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/server/ItemEgg.java b/src/main/java/net/minecraft/server/ItemEgg.java
|
2019-08-05 04:15:53 +02:00
|
|
|
index 7cc3c33b0..b92d39600 100644
|
2018-08-17 23:55:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemEgg.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemEgg.java
|
2019-04-30 03:20:24 +02:00
|
|
|
@@ -10,17 +10,35 @@ public class ItemEgg extends Item {
|
2018-08-17 23:55:40 +02:00
|
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
2018-09-01 00:56:57 +02:00
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
+ /* // Paper start - moved down
|
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
itemstack.subtract(1);
|
|
|
|
}
|
|
|
|
|
2019-07-20 06:01:24 +02:00
|
|
|
world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.i.nextFloat() * 0.4F + 0.8F));
|
2019-01-01 04:15:55 +01:00
|
|
|
+ */ // Paper end
|
2018-08-17 23:55:40 +02:00
|
|
|
if (!world.isClientSide) {
|
|
|
|
EntityEgg entityegg = new EntityEgg(world, entityhuman);
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2019-04-30 03:20:24 +02:00
|
|
|
entityegg.setItem(itemstack);
|
2018-08-17 23:55:40 +02:00
|
|
|
entityegg.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
|
|
|
- world.addEntity(entityegg);
|
|
|
|
+ // Paper start
|
|
|
|
+ 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(itemstack), (org.bukkit.entity.Projectile) entityegg.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addEntity(entityegg)) {
|
|
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ itemstack.subtract(1);
|
|
|
|
+ } else if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
2019-07-20 06:01:24 +02:00
|
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ } else {
|
|
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemEnderPearl.java b/src/main/java/net/minecraft/server/ItemEnderPearl.java
|
2019-08-05 04:15:53 +02:00
|
|
|
index e4a9e4b7b..570abc8b2 100644
|
2018-08-17 23:55:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemEnderPearl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemEnderPearl.java
|
2019-04-30 03:20:24 +02:00
|
|
|
@@ -16,7 +16,19 @@ public class ItemEnderPearl extends Item {
|
2018-08-17 23:55:40 +02:00
|
|
|
|
2019-04-30 03:20:24 +02:00
|
|
|
entityenderpearl.setItem(itemstack);
|
2018-08-17 23:55:40 +02:00
|
|
|
entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
|
|
|
- if (!world.addEntity(entityenderpearl)) {
|
|
|
|
+ // Paper start
|
|
|
|
+ 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(itemstack), (org.bukkit.entity.Projectile) entityenderpearl.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addEntity(entityenderpearl)) {
|
|
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ itemstack.subtract(1);
|
|
|
|
+ } else if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
2019-07-20 06:01:24 +02:00
|
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
2019-08-05 04:15:53 +02:00
|
|
|
+ entityhuman.getCooldownTracker().setCooldown(this, 20);
|
2018-08-17 23:55:40 +02:00
|
|
|
+ } else {
|
|
|
|
+ // Paper end
|
|
|
|
if (entityhuman instanceof EntityPlayer) {
|
|
|
|
((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
}
|
2019-04-30 03:20:24 +02:00
|
|
|
@@ -24,13 +36,15 @@ public class ItemEnderPearl extends Item {
|
2018-08-17 23:55:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
- itemstack.subtract(1);
|
|
|
|
- }
|
|
|
|
-
|
2019-07-20 06:01:24 +02:00
|
|
|
- world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.i.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
- entityhuman.getCooldownTracker().a(this, 20);
|
|
|
|
- // CraftBukkit end
|
2019-07-20 06:01:24 +02:00
|
|
|
+// // Paper start - moved up
|
|
|
|
+// if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+// itemstack.subtract(1);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.i.nextFloat() * 0.4F + 0.8F));
|
|
|
|
+// entityhuman.getCooldownTracker().a(this, 20);
|
|
|
|
+// // CraftBukkit end
|
|
|
|
+// // Paper end
|
2018-08-17 23:55:40 +02:00
|
|
|
|
|
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
2019-01-01 04:15:55 +01:00
|
|
|
return new InteractionResultWrapper<>(EnumInteractionResult.SUCCESS, itemstack);
|
2018-08-17 23:55:40 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemExpBottle.java b/src/main/java/net/minecraft/server/ItemExpBottle.java
|
2019-08-05 04:15:53 +02:00
|
|
|
index 8d557cd85..2a0aded65 100644
|
2018-08-17 23:55:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemExpBottle.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemExpBottle.java
|
2019-04-30 03:20:24 +02:00
|
|
|
@@ -9,18 +9,35 @@ public class ItemExpBottle extends Item {
|
|
|
|
@Override
|
2018-08-17 23:55:40 +02:00
|
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
2019-01-01 04:15:55 +01:00
|
|
|
-
|
|
|
|
+ /* // Paper start
|
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
itemstack.subtract(1);
|
|
|
|
}
|
2018-09-01 00:56:57 +02:00
|
|
|
|
2019-07-20 06:01:24 +02:00
|
|
|
world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemExpBottle.i.nextFloat() * 0.4F + 0.8F));
|
2019-01-01 04:15:55 +01:00
|
|
|
+ */ // Paper end
|
2018-08-17 23:55:40 +02:00
|
|
|
if (!world.isClientSide) {
|
|
|
|
EntityThrownExpBottle entitythrownexpbottle = new EntityThrownExpBottle(world, entityhuman);
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2019-04-30 03:20:24 +02:00
|
|
|
entitythrownexpbottle.setItem(itemstack);
|
2018-08-17 23:55:40 +02:00
|
|
|
entitythrownexpbottle.a(entityhuman, entityhuman.pitch, entityhuman.yaw, -20.0F, 0.7F, 1.0F);
|
|
|
|
- world.addEntity(entitythrownexpbottle);
|
|
|
|
+ // Paper start
|
|
|
|
+ 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(itemstack), (org.bukkit.entity.Projectile) entitythrownexpbottle.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addEntity(entitythrownexpbottle)) {
|
|
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ itemstack.subtract(1);
|
|
|
|
+ } else if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
2019-07-20 06:01:24 +02:00
|
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ } else {
|
|
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemLingeringPotion.java b/src/main/java/net/minecraft/server/ItemLingeringPotion.java
|
2019-08-05 04:15:53 +02:00
|
|
|
index 1bddb7801..ca3f9f8cc 100644
|
2018-08-17 23:55:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemLingeringPotion.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemLingeringPotion.java
|
2019-04-30 03:20:24 +02:00
|
|
|
@@ -9,15 +9,40 @@ public class ItemLingeringPotion extends ItemPotion {
|
|
|
|
@Override
|
2018-08-17 23:55:40 +02:00
|
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
2019-01-01 04:15:55 +01:00
|
|
|
+ /* // Paper start
|
|
|
|
ItemStack itemstack1 = entityhuman.abilities.canInstantlyBuild ? itemstack.cloneItemStack() : itemstack.cloneAndSubtract(1);
|
|
|
|
|
2019-07-20 06:01:24 +02:00
|
|
|
world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_LINGERING_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemLingeringPotion.i.nextFloat() * 0.4F + 0.8F));
|
2019-01-01 04:15:55 +01:00
|
|
|
+ */ // Paper end
|
2018-08-17 23:55:40 +02:00
|
|
|
if (!world.isClientSide) {
|
2019-04-30 03:20:24 +02:00
|
|
|
+
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper start - ensure stack count matches vanilla behavior without modifying original stack yet
|
|
|
|
+ ItemStack itemstack1 = itemstack.cloneItemStack();
|
|
|
|
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ itemstack1.setCount(1);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2019-04-30 03:20:24 +02:00
|
|
|
EntityPotion entitypotion = new EntityPotion(world, entityhuman);
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2019-04-30 03:20:24 +02:00
|
|
|
entitypotion.setItem(itemstack1);
|
2018-08-17 23:55:40 +02:00
|
|
|
entitypotion.a(entityhuman, entityhuman.pitch, entityhuman.yaw, -20.0F, 0.5F, 1.0F);
|
|
|
|
- world.addEntity(entitypotion);
|
|
|
|
+ // Paper start
|
|
|
|
+ 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(itemstack), (org.bukkit.entity.Projectile) entitypotion.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addEntity(entitypotion)) {
|
|
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ itemstack.subtract(1);
|
|
|
|
+ } else if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
2019-07-20 06:01:24 +02:00
|
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_LINGERING_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ } else {
|
|
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemSnowball.java b/src/main/java/net/minecraft/server/ItemSnowball.java
|
2019-08-05 04:15:53 +02:00
|
|
|
index f5387a74a..bbd22596e 100644
|
2018-08-17 23:55:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemSnowball.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemSnowball.java
|
2019-07-20 06:01:24 +02:00
|
|
|
@@ -23,14 +23,21 @@ public class ItemSnowball extends Item {
|
2018-08-17 23:55:40 +02:00
|
|
|
|
2019-04-30 03:20:24 +02:00
|
|
|
entitysnowball.setItem(itemstack);
|
2018-08-17 23:55:40 +02:00
|
|
|
entitysnowball.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
|
|
|
- if (world.addEntity(entitysnowball)) {
|
|
|
|
- if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ // Paper start
|
|
|
|
+ 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(itemstack), (org.bukkit.entity.Projectile) entitysnowball.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addEntity(entitysnowball)) {
|
|
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
itemstack.subtract(1);
|
|
|
|
+ } else if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
}
|
|
|
|
|
2019-07-20 06:01:24 +02:00
|
|
|
- world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.i.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
- } else if (entityhuman instanceof EntityPlayer) {
|
|
|
|
- ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
2019-07-20 06:01:24 +02:00
|
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ } else {
|
|
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
2019-07-20 06:01:24 +02:00
|
|
|
+ return new InteractionResultWrapper<>(EnumInteractionResult.FAIL, itemstack);
|
2018-08-17 23:55:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemSplashPotion.java b/src/main/java/net/minecraft/server/ItemSplashPotion.java
|
2019-08-05 04:15:53 +02:00
|
|
|
index bb9e60659..4460ddc6d 100644
|
2018-08-17 23:55:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemSplashPotion.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemSplashPotion.java
|
2019-04-30 03:20:24 +02:00
|
|
|
@@ -9,15 +9,39 @@ public class ItemSplashPotion extends ItemPotion {
|
|
|
|
@Override
|
2018-08-17 23:55:40 +02:00
|
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
2019-01-01 04:15:55 +01:00
|
|
|
+ /* // Paper start
|
|
|
|
ItemStack itemstack1 = entityhuman.abilities.canInstantlyBuild ? itemstack.cloneItemStack() : itemstack.cloneAndSubtract(1);
|
|
|
|
|
2019-07-20 06:01:24 +02:00
|
|
|
world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemSplashPotion.i.nextFloat() * 0.4F + 0.8F));
|
2019-01-01 04:15:55 +01:00
|
|
|
+ */ // Paper end
|
2018-08-17 23:55:40 +02:00
|
|
|
if (!world.isClientSide) {
|
2019-04-30 03:20:24 +02:00
|
|
|
EntityPotion entitypotion = new EntityPotion(world, entityhuman);
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper start - ensure stack count matches vanilla behavior without modifying original stack yet
|
|
|
|
+ ItemStack itemstack1 = itemstack.cloneItemStack();
|
|
|
|
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ itemstack1.setCount(1);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2019-04-30 03:20:24 +02:00
|
|
|
entitypotion.setItem(itemstack1);
|
2018-08-17 23:55:40 +02:00
|
|
|
entitypotion.a(entityhuman, entityhuman.pitch, entityhuman.yaw, -20.0F, 0.5F, 1.0F);
|
|
|
|
- world.addEntity(entitypotion);
|
|
|
|
+ // Paper start
|
|
|
|
+ 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(itemstack), (org.bukkit.entity.Projectile) entitypotion.getBukkitEntity());
|
|
|
|
+ if (event.callEvent() && world.addEntity(entitypotion)) {
|
|
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ itemstack.subtract(1);
|
|
|
|
+ } else if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+
|
2019-07-20 06:01:24 +02:00
|
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ } else {
|
|
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
|
|
--
|
2019-08-05 04:15:53 +02:00
|
|
|
2.20.1
|
2018-08-17 23:55:40 +02:00
|
|
|
|