|
1766 | 1766 | + return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(this.player);
|
1767 | 1767 | + });
|
1768 | 1768 | + if (result == null) {
|
1769 |
| -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); |
| 1769 | ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); |
1770 | 1770 | + } else { // Paper start - Call interact event
|
1771 | 1771 | + GameType gameType = this.player.gameMode.getGameModeForPlayer();
|
1772 | 1772 | + if (gameType == GameType.ADVENTURE && result.getHitBlock() != null) {
|
1773 |
| -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); |
| 1773 | ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); |
1774 | 1774 | + } else if (gameType != GameType.CREATIVE && result.getHitEntity() != null && origin.toVector().distanceSquared(result.getHitPosition()) > this.player.entityInteractionRange() * this.player.entityInteractionRange()) {
|
1775 |
| -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); |
| 1775 | ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); |
1776 | 1776 | + }
|
1777 | 1777 | + } // Paper end - Call interact event
|
1778 | 1778 | +
|
|
1908 | 1908 | - {
|
1909 | 1909 | + // CraftBukkit start
|
1910 | 1910 | + boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && target instanceof net.minecraft.world.entity.Mob;
|
1911 |
| -+ Item origItem = ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null ? null : ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem(); |
| 1911 | ++ Item origItem = ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() ? null : ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem(); |
1912 | 1912 | +
|
1913 | 1913 | + ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event);
|
1914 | 1914 | +
|
1915 | 1915 | + // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
1916 |
| -+ if ((target instanceof Bucketable && target instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) { |
| 1916 | ++ if ((target instanceof Bucketable && target instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem() != origItem)) { |
1917 | 1917 | + target.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it
|
1918 | 1918 | + ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote();
|
1919 | 1919 | + }
|
1920 | 1920 | +
|
1921 |
| -+ if (triggerLeashUpdate && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) { |
| 1921 | ++ if (triggerLeashUpdate && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem() != origItem)) { |
1922 | 1922 | + // Refresh the current leash state
|
1923 | 1923 | + ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(target, ((net.minecraft.world.entity.Mob) target).getLeashHolder()));
|
1924 | 1924 | + }
|
1925 | 1925 | +
|
1926 |
| -+ if (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem) { |
| 1926 | ++ if (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem() != origItem) { |
1927 | 1927 | + // Refresh the current entity metadata
|
1928 | 1928 | + target.refreshEntityData(ServerGamePacketListenerImpl.this.player);
|
1929 | 1929 | + // SPIGOT-7136 - Allays
|
|
2276 | 2276 | + if (this.player.containerMenu.quickcraftSlots.size() == 1) {
|
2277 | 2277 | + int index = containerMenu.quickcraftSlots.iterator().next().index;
|
2278 | 2278 | + containerMenu.resetQuickCraft();
|
2279 |
| -+ this.handleContainerClick(new ServerboundContainerClickPacket(packet.getContainerId(), packet.getStateId(), index, containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.getCarriedItem(), packet.getChangedSlots())); |
| 2279 | ++ this.handleContainerClick(new ServerboundContainerClickPacket(packet.containerId(), packet.stateId(), (short) index, (byte) containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.changedSlots(), packet.carriedItem())); |
2280 | 2280 | + return;
|
2281 | 2281 | + }
|
2282 | 2282 | + }
|
2283 | 2283 | + }
|
2284 | 2284 | + // Paper end - Fix CraftBukkit drag system
|
2285 |
| -+ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.getClickType(), this.player); |
| 2285 | ++ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.clickType(), this.player); |
2286 | 2286 | + break;
|
2287 | 2287 | + case PICKUP_ALL:
|
2288 | 2288 | + click = ClickType.DOUBLE_CLICK;
|
|
2353 | 2353 | + switch (event.getResult()) {
|
2354 | 2354 | + case ALLOW:
|
2355 | 2355 | + case DEFAULT:
|
2356 |
| -+ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.getClickType(), this.player); |
| 2356 | ++ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.clickType(), this.player); |
2357 | 2357 | + break;
|
2358 | 2358 | + case DENY:
|
2359 | 2359 | + /* Needs enum constructor in InventoryAction
|
|
0 commit comments