49 lines
2.7 KiB
Java
49 lines
2.7 KiB
Java
package net.minecraft.server;
|
|
|
|
public class ItemLingeringPotion extends ItemPotion {
|
|
|
|
public ItemLingeringPotion(Item.Info item_info) {
|
|
super(item_info);
|
|
}
|
|
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
|
/* // Paper start
|
|
ItemStack itemstack1 = entityhuman.abilities.canInstantlyBuild ? itemstack.cloneItemStack() : itemstack.cloneAndSubtract(1);
|
|
|
|
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));
|
|
*/ // 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);
|
|
// 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();
|
|
}
|
|
|
|
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));
|
|
} else {
|
|
if (entityhuman instanceof EntityPlayer) {
|
|
((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
}
|
|
return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
|
}
|
|
// Paper end
|
|
}
|
|
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
return new InteractionResultWrapper<>(EnumInteractionResult.SUCCESS, itemstack);
|
|
}
|
|
}
|