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

28 lines
1.8 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/ItemSnowball.java
+++ b/net/minecraft/world/item/ItemSnowball.java
2024-10-23 02:15:00 +11:00
@@ -23,13 +23,21 @@
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.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
2024-10-23 02:15:00 +11:00
+ // CraftBukkit start - moved down
2021-11-22 09:00:00 +11:00
+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_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(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F);
+ if (IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isAlive()) {
2024-04-24 01:15:00 +10:00
+ itemstack.consume(1, entityhuman);
+
2021-11-22 09:00:00 +11:00
+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
2021-03-16 09:00:00 +11:00
+ } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
+ }
2024-10-23 02:15:00 +11:00
+ // CraftBukkit end
}
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);
+ // itemstack.consume(1, entityhuman); // CraftBukkit - moved up
2024-10-23 02:15:00 +11:00
return EnumInteractionResult.SUCCESS;
2019-12-11 09:00:00 +11:00
}
2024-04-24 01:15:00 +10:00