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

24 lines
1.8 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/ItemEgg.java
+++ b/net/minecraft/world/item/ItemEgg.java
2024-12-04 03:20:00 +11:00
@@ -25,10 +25,18 @@
2024-10-23 02:15:00 +11:00
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.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
2024-10-23 02:15:00 +11:00
if (world instanceof WorldServer worldserver) {
2024-12-04 03:20:00 +11:00
- IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, ItemEgg.PROJECTILE_SHOOT_POWER, 1.0F);
+ // CraftBukkit start
2024-12-04 03:20:00 +11:00
+ if (IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, ItemEgg.PROJECTILE_SHOOT_POWER, 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;
+ }
+ // CraftBukkit end
}
2021-11-22 09:00:00 +11:00
+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
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);