From 251ca9b7e11b217fe9bd7d5270a8c0b19462cb01 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 30 Nov 2020 03:19:57 +1300 Subject: [PATCH] Let disguised dogs be sittable --- .../disguise/utilities/DisguiseUtilities.java | 17 +++++++++++++++++ .../PacketListenerClientInteract.java | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 104c1776..cf53ff8b 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -134,6 +134,7 @@ public class DisguiseUtilities { public static final Random random = new Random(); private static final LinkedHashMap clonedDisguises = new LinkedHashMap<>(); private static final List isNoInteract = new ArrayList<>(); + private static final List isSpecialInteract = new ArrayList<>(); /** * A hashmap of the uuid's of entitys, alive and dead. And their disguises in use */ @@ -445,6 +446,12 @@ public class DisguiseUtilities { } } + public static boolean isSpecialInteract(int entityId) { + synchronized (isSpecialInteract) { + return isSpecialInteract.contains(entityId); + } + } + public static boolean isGrabSkinCommandUsed() { return grabSkinCommandUsed; } @@ -688,6 +695,12 @@ public class DisguiseUtilities { break; } } + + synchronized (isSpecialInteract) { + if (disguise.getEntity() instanceof Wolf && disguise.getType() != DisguiseType.WOLF) { + isSpecialInteract.add(entityId); + } + } } if ("a%%__USER__%%a".equals("a12345a") || (LibsPremium.getUserID().matches("[0-9]+") && @@ -1543,6 +1556,10 @@ public class DisguiseUtilities { synchronized (isNoInteract) { isNoInteract.remove((Object) disguise.getEntity().getEntityId()); } + + synchronized (isSpecialInteract) { + isSpecialInteract.remove((Object) disguise.getEntity().getEntityId()); + } } } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientInteract.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientInteract.java index dd9e463b..6affacff 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientInteract.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerClientInteract.java @@ -50,6 +50,8 @@ public class PacketListenerClientInteract extends PacketAdapter { event.setCancelled(true); } else if (DisguiseUtilities.isNotInteractable(packet.getIntegers().read(0))) { event.setCancelled(true); + }else if (DisguiseUtilities.isSpecialInteract(packet.getIntegers().read(0)) && packet.getHands().read(0) == EnumWrappers.Hand.OFF_HAND) { + event.setCancelled(true); } if (event.isAsync()) {