craftbukkit/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch

23 lines
1.5 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/ItemEnderPearl.java
+++ b/net/minecraft/world/item/ItemEnderPearl.java
2024-10-23 02:15:00 +11:00
@@ -21,10 +21,17 @@
public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) {
2021-11-22 09:00:00 +11:00
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
2021-11-22 09:00:00 +11:00
- world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
2024-10-23 02:15:00 +11:00
if (world instanceof WorldServer worldserver) {
- IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F);
+ // CraftBukkit start
+ if (IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isRemoved()) {
2021-03-16 09:00:00 +11:00
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
+ }
2024-10-23 02:15:00 +11:00
+ return EnumInteractionResult.FAIL;
+ }
}
2021-11-22 09:00:00 +11:00
+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ // CraftBukkit end
2024-10-23 02:15:00 +11:00
2021-11-22 09:00:00 +11:00
entityhuman.awardStat(StatisticList.ITEM_USED.get(this));
2024-04-24 01:15:00 +10:00
itemstack.consume(1, entityhuman);