2018-09-01 00:56:57 +02:00
|
|
|
From 5db9f5cec37287aadff02842e15cf321933e4dfd 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
|
2018-09-01 00:56:57 +02:00
|
|
|
index adc38763b9..776c86f1fe 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
|
2018-09-01 00:56:57 +02:00
|
|
|
@@ -7,15 +7,34 @@ 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);
|
|
|
|
- if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
- itemstack.subtract(1);
|
|
|
|
- }
|
2018-09-01 00:56:57 +02:00
|
|
|
|
|
|
|
- world.a((EntityHuman)null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (i.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper start - moved down
|
|
|
|
+ //if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ // itemstack.subtract(1);
|
|
|
|
+ //}
|
|
|
|
+ //
|
2018-08-26 20:11:49 +02:00
|
|
|
+ //world.a((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));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper end
|
|
|
|
if (!world.isClientSide) {
|
|
|
|
EntityEgg entityegg = new EntityEgg(world, entityhuman);
|
|
|
|
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();
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-26 20:11:49 +02:00
|
|
|
+ world.a((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
|
2018-08-26 20:11:49 +02:00
|
|
|
index 876384f37b..8b8bc8ec1c 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
|
|
|
|
@@ -14,7 +14,19 @@ public class ItemEnderPearl extends Item {
|
|
|
|
EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman);
|
|
|
|
|
|
|
|
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();
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-26 20:11:49 +02:00
|
|
|
+ world.a((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));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ entityhuman.getCooldownTracker().a(this, 20);
|
|
|
|
+ } else {
|
|
|
|
+ // Paper end
|
|
|
|
if (entityhuman instanceof EntityPlayer) {
|
|
|
|
((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
|
|
}
|
|
|
|
@@ -22,13 +34,15 @@ public class ItemEnderPearl extends Item {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
- itemstack.subtract(1);
|
|
|
|
- }
|
|
|
|
-
|
2018-08-26 20:11:49 +02:00
|
|
|
- world.a((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
|
|
|
|
+ // Paper start - moved up
|
|
|
|
+ //if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ // itemstack.subtract(1);
|
|
|
|
+ //}
|
|
|
|
+ //
|
2018-08-26 20:11:49 +02:00
|
|
|
+ //world.a((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
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
|
|
return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack);
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemExpBottle.java b/src/main/java/net/minecraft/server/ItemExpBottle.java
|
2018-09-01 00:56:57 +02:00
|
|
|
index b167c54417..42a0329c29 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
|
2018-09-01 00:56:57 +02:00
|
|
|
@@ -7,15 +7,34 @@ public class ItemExpBottle 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);
|
|
|
|
- if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
- itemstack.subtract(1);
|
|
|
|
- }
|
2018-09-01 00:56:57 +02:00
|
|
|
|
|
|
|
- world.a((EntityHuman)null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (i.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper start - moved down
|
|
|
|
+ //if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ // itemstack.subtract(1);
|
|
|
|
+ //}
|
|
|
|
+ //
|
2018-08-26 20:11:49 +02:00
|
|
|
+ //world.a((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));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper end
|
|
|
|
if (!world.isClientSide) {
|
|
|
|
EntityThrownExpBottle entitythrownexpbottle = new EntityThrownExpBottle(world, entityhuman);
|
|
|
|
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();
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-26 20:11:49 +02:00
|
|
|
+ world.a((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
|
2018-09-01 00:56:57 +02:00
|
|
|
index ab7807d832..46c64c760f 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
|
2018-09-01 00:56:57 +02:00
|
|
|
@@ -7,12 +7,37 @@ public class ItemLingeringPotion extends ItemPotion {
|
2018-08-17 23:55:40 +02:00
|
|
|
|
|
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
|
|
|
- ItemStack itemstack1 = entityhuman.abilities.canInstantlyBuild ? itemstack.cloneItemStack() : itemstack.cloneAndSubtract(1);
|
2018-09-01 00:56:57 +02:00
|
|
|
- world.a((EntityHuman)null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_LINGERING_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (i.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper start - moved down
|
|
|
|
+ //ItemStack itemstack1 = entityhuman.abilities.canInstantlyBuild ? itemstack.cloneItemStack() : itemstack.cloneAndSubtract(1);
|
2018-09-01 00:56:57 +02:00
|
|
|
+
|
2018-08-26 20:11:49 +02:00
|
|
|
+ //world.a((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));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper end
|
|
|
|
if (!world.isClientSide) {
|
|
|
|
+ // 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
|
|
|
|
EntityPotion entitypotion = new EntityPotion(world, entityhuman, itemstack1);
|
|
|
|
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();
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-26 20:11:49 +02:00
|
|
|
+ world.a((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
|
2018-08-26 20:11:49 +02:00
|
|
|
index 332145c32b..5c23c9ae0c 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
|
|
|
|
@@ -21,15 +21,23 @@ public class ItemSnowball extends Item {
|
|
|
|
EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman);
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2018-08-26 20:11:49 +02:00
|
|
|
- world.a((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();
|
2018-08-26 20:11:49 +02:00
|
|
|
+ world.a((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();
|
|
|
|
+ }
|
|
|
|
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
|
|
|
}
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemSplashPotion.java b/src/main/java/net/minecraft/server/ItemSplashPotion.java
|
2018-09-01 00:56:57 +02:00
|
|
|
index 426b42a12c..a4e2f70c7c 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
|
2018-09-01 00:56:57 +02:00
|
|
|
@@ -7,12 +7,36 @@ public class ItemSplashPotion extends ItemPotion {
|
2018-08-17 23:55:40 +02:00
|
|
|
|
|
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
|
|
|
- ItemStack itemstack1 = entityhuman.abilities.canInstantlyBuild ? itemstack.cloneItemStack() : itemstack.cloneAndSubtract(1);
|
2018-09-01 00:56:57 +02:00
|
|
|
- world.a((EntityHuman)null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (i.nextFloat() * 0.4F + 0.8F));
|
2018-08-26 20:11:49 +02:00
|
|
|
+ // Paper start - moved sound down, clone handled diff
|
2018-08-17 23:55:40 +02:00
|
|
|
+ //ItemStack itemstack1 = entityhuman.abilities.canInstantlyBuild ? itemstack.cloneItemStack() : itemstack.cloneAndSubtract(1);
|
2018-09-01 00:56:57 +02:00
|
|
|
+ //world.a((EntityHuman)null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (i.nextFloat() * 0.4F + 0.8F));
|
2018-08-17 23:55:40 +02:00
|
|
|
+ // Paper end
|
|
|
|
if (!world.isClientSide) {
|
|
|
|
+ // 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
|
|
|
|
EntityPotion entitypotion = new EntityPotion(world, entityhuman, itemstack1);
|
|
|
|
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();
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-26 20:11:49 +02:00
|
|
|
+ world.a((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));
|
|
|
|
--
|
2018-08-18 00:01:37 +02:00
|
|
|
2.18.0
|
2018-08-17 23:55:40 +02:00
|
|
|
|