diff options
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/LeadItem.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/LeadItem.java.patch | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/LeadItem.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/LeadItem.java.patch new file mode 100644 index 0000000000..875c3ae2e9 --- /dev/null +++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/LeadItem.java.patch @@ -0,0 +1,82 @@ +--- a/net/minecraft/world/item/LeadItem.java ++++ b/net/minecraft/world/item/LeadItem.java +@@ -14,6 +14,10 @@ + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.phys.AABB; ++// CraftBukkit start ++import org.bukkit.craftbukkit.CraftEquipmentSlot; ++import org.bukkit.event.hanging.HangingPlaceEvent; ++// CraftBukkit end + + public class LeadItem extends Item { + +@@ -31,8 +34,8 @@ + if (blockstate.is(BlockTags.FENCES)) { + Player player = useoncontext.getPlayer(); + +- if (!level.isClientSide && player != null) { +- bindPlayerMobs(player, level, blockpos); ++ if (!world.isClientSide && entityhuman != null) { ++ bindPlayerMobs(entityhuman, world, blockposition, context.getHand()); // CraftBukkit - Pass hand + } + + return InteractionResult.sidedSuccess(level.isClientSide); +@@ -41,8 +44,8 @@ + } + } + +- public static InteractionResult bindPlayerMobs(Player player, Level level, BlockPos blockpos) { +- LeashFenceKnotEntity leashfenceknotentity = null; ++ public static InteractionResult bindPlayerMobs(Player entityhuman, Level world, BlockPos blockposition, net.minecraft.world.EnumHand enumhand) { // CraftBukkit - Add EnumHand ++ LeashFenceKnotEntity entityleash = null; + boolean flag = false; + double d0 = 7.0D; + int i = blockpos.getX(); +@@ -54,13 +57,30 @@ + while (iterator.hasNext()) { + Mob mob = (Mob) iterator.next(); + +- if (mob.getLeashHolder() == player) { +- if (leashfenceknotentity == null) { +- leashfenceknotentity = LeashFenceKnotEntity.getOrCreateKnot(level, blockpos); +- leashfenceknotentity.playPlacementSound(); ++ if (entityinsentient.getLeashHolder() == entityhuman) { ++ if (entityleash == null) { ++ entityleash = LeashFenceKnotEntity.getOrCreateKnot(world, blockposition); ++ ++ // CraftBukkit start - fire HangingPlaceEvent ++ org.bukkit.inventory.EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand); ++ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF, hand); ++ world.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ entityleash.discard(); ++ return InteractionResult.PASS; ++ } ++ // CraftBukkit end ++ entityleash.playPlacementSound(); + } + +- mob.setLeashedTo(leashfenceknotentity, true); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end ++ ++ entityinsentient.setLeashedTo(entityleash, true); + flag = true; + } + } +@@ -71,4 +91,10 @@ + + return flag ? InteractionResult.SUCCESS : InteractionResult.PASS; + } ++ ++ // CraftBukkit start ++ public static InteractionResult bindPlayerMobs(Player player, Level level, BlockPos pos) { ++ return bindPlayerMobs(player, level, pos, net.minecraft.world.EnumHand.MAIN_HAND); ++ } ++ // CraftBukkit end + } |