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

38 lines
2 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
@@ -19,19 +19,32 @@
2016-11-17 12:41:03 +11:00
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
2021-06-11 15:00:00 +10:00
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
2019-12-11 09:00:00 +11:00
+ // CraftBukkit - moved down
2021-06-11 15:00:00 +10:00
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
if (!world.isClientSide) {
EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman);
2019-04-23 12:00:00 +10:00
entitysnowball.setItem(itemstack);
2021-06-11 15:00:00 +10:00
entitysnowball.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F);
- world.addEntity(entitysnowball);
+ if (world.addEntity(entitysnowball)) {
2021-06-11 15:00:00 +10:00
+ if (!entityhuman.getAbilities().instabuild) {
2016-11-17 12:41:03 +11:00
+ itemstack.subtract(1);
+ }
+
2021-06-11 15:00:00 +10:00
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), 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();
+ }
}
+ // CraftBukkit end
2018-07-15 10:00:00 +10:00
entityhuman.b(StatisticList.ITEM_USED.b(this));
2019-12-11 09:00:00 +11:00
+ // CraftBukkit start - moved up
+ /*
2021-06-11 15:00:00 +10:00
if (!entityhuman.getAbilities().instabuild) {
2019-12-11 09:00:00 +11:00
itemstack.subtract(1);
}
+ */
2021-06-11 15:00:00 +10:00
return InteractionResultWrapper.a(itemstack, world.isClientSide());
2019-12-11 09:00:00 +11:00
}