PaperMC/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch
CraftBukkit/Spigot 8398e12b34 Update to Minecraft 1.20.3
By: md_5 <git@md-5.net>
2023-12-06 03:40:00 +11:00

56 lines
3.3 KiB
Diff

--- a/net/minecraft/world/item/ItemTrident.java
+++ b/net/minecraft/world/item/ItemTrident.java
@@ -68,9 +68,12 @@
if (k <= 0 || entityhuman.isInWaterOrRain()) {
if (!world.isClientSide) {
+ // CraftBukkit - moved down
+ /*
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand());
});
+ */
if (k == 0) {
EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack);
@@ -79,16 +82,39 @@
entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
}
- world.addFreshEntity(entitythrowntrident);
+ // CraftBukkit start
+ if (!world.addFreshEntity(entitythrowntrident)) {
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
+ }
+ return;
+ }
+
+ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
+ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand());
+ });
+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved
+ // CraftBukkit end
+
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
if (!entityhuman.getAbilities().instabuild) {
entityhuman.getInventory().removeItem(itemstack);
}
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
+ } else {
+ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
+ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand());
+ });
+ // CraftBukkkit end
}
}
entityhuman.awardStat(StatisticList.ITEM_USED.get(this));
if (k > 0) {
+ // CraftBukkit start
+ org.bukkit.event.player.PlayerRiptideEvent event = new org.bukkit.event.player.PlayerRiptideEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack));
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
float f = entityhuman.getYRot();
float f1 = entityhuman.getXRot();
float f2 = -MathHelper.sin(f * 0.017453292F) * MathHelper.cos(f1 * 0.017453292F);