geforkt von Mirrors/Paper
Check interactable items before event. Fixes BUKKIT-4576
Items that cause entities to change state, including tags, chest, and leashes, do not update the client properly following the firing of PlayerInteractEntityEvent. This change makes the item checks occur before the event fires, to concur with the client's assumptions.
Dieser Commit ist enthalten in:
Ursprung
1192f2a53a
Commit
e88cea8402
@ -24,7 +24,6 @@ import org.bukkit.craftbukkit.util.Waitable;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
@ -35,7 +34,6 @@ import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
@ -1083,18 +1081,26 @@ public class PlayerConnection extends Connection {
|
||||
ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit
|
||||
if (packet7useentity.action == 0) {
|
||||
// CraftBukkit start
|
||||
boolean triggerTagUpdate = itemInHand != null && itemInHand.id == Item.NAME_TAG.id && entity instanceof EntityInsentient;
|
||||
boolean triggerChestUpdate = itemInHand != null && itemInHand.id == Block.CHEST.id && entity instanceof EntityHorse;
|
||||
boolean triggerLeashUpdate = itemInHand != null && itemInHand.id == Item.LEASH.id && entity instanceof EntityInsentient;
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
|
||||
this.server.getPluginManager().callEvent(event);
|
||||
|
||||
if (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().id != Item.LEASH.id)) {
|
||||
// Refresh the current leash state
|
||||
this.sendPacket(new Packet39AttachEntity(1, entity, ((EntityInsentient) entity).bI()));
|
||||
}
|
||||
|
||||
if (triggerTagUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().id != Item.NAME_TAG.id)) {
|
||||
// Refresh the current entity metadata
|
||||
this.sendPacket(new Packet40EntityMetadata(entity.id, entity.datawatcher, true));
|
||||
}
|
||||
if (triggerChestUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().id != Block.CHEST.id)) {
|
||||
this.sendPacket(new Packet40EntityMetadata(entity.id, entity.datawatcher, true));
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
if (itemInHand != null && itemInHand.id == Item.LEASH.id && entity instanceof EntityInsentient) {
|
||||
// Refresh the current leash state
|
||||
this.sendPacket(new Packet39AttachEntity(1, entity, ((EntityInsentient) entity).bI()));
|
||||
}
|
||||
if (itemInHand != null && itemInHand.id == Item.NAME_TAG.id && entity instanceof EntityInsentient) {
|
||||
// Refresh the current entity metadata
|
||||
this.sendPacket(new Packet40EntityMetadata(entity.id, entity.datawatcher, true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren