Fix up self disguises flicking and Evoker Fangs
This commit is contained in:
		| @@ -209,7 +209,7 @@ public abstract class Disguise { | |||||||
|                     if (getType() == DisguiseType.FIREWORK) { |                     if (getType() == DisguiseType.FIREWORK) { | ||||||
|                         refreshDisguise++; |                         refreshDisguise++; | ||||||
|  |  | ||||||
|                         if (refreshDisguise % 40 == 0) { |                         if (refreshDisguise == 40) { | ||||||
|                             refreshDisguise = 0; |                             refreshDisguise = 0; | ||||||
|  |  | ||||||
|                             DisguiseUtilities.refreshTrackers(disguise); |                             DisguiseUtilities.refreshTrackers(disguise); | ||||||
| @@ -218,7 +218,7 @@ public abstract class Disguise { | |||||||
|                     else if (getType() == DisguiseType.EVOKER_FANGS) { |                     else if (getType() == DisguiseType.EVOKER_FANGS) { | ||||||
|                         refreshDisguise++; |                         refreshDisguise++; | ||||||
|  |  | ||||||
|                         if (refreshDisguise % 20 == 0) { |                         if (refreshDisguise == 23) { | ||||||
|                             refreshDisguise = 0; |                             refreshDisguise = 0; | ||||||
|  |  | ||||||
|                             DisguiseUtilities.refreshTrackers(disguise); |                             DisguiseUtilities.refreshTrackers(disguise); | ||||||
|   | |||||||
| @@ -880,7 +880,10 @@ public class DisguiseUtilities { | |||||||
|         if (mainThread != Thread.currentThread()) |         if (mainThread != Thread.currentThread()) | ||||||
|             throw new IllegalStateException("Cannot modify disguises on an async thread"); |             throw new IllegalStateException("Cannot modify disguises on an async thread"); | ||||||
|  |  | ||||||
|         if (disguise.getEntity().isValid()) { |         if (!disguise.getEntity().isValid()) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); |         PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
| @@ -942,12 +945,8 @@ public class DisguiseUtilities { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|             catch ( |         catch (Exception ex) { | ||||||
|  |  | ||||||
|             Exception ex) { |  | ||||||
|             ex.printStackTrace(); |             ex.printStackTrace(); | ||||||
|  |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import java.util.List; | |||||||
|  |  | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
|  |  | ||||||
|  | import com.comphenix.protocol.PacketType; | ||||||
| import com.comphenix.protocol.PacketType.Play.Server; | import com.comphenix.protocol.PacketType.Play.Server; | ||||||
| import com.comphenix.protocol.ProtocolLibrary; | import com.comphenix.protocol.ProtocolLibrary; | ||||||
| import com.comphenix.protocol.events.ListenerPriority; | import com.comphenix.protocol.events.ListenerPriority; | ||||||
| @@ -46,6 +47,14 @@ public class PacketListenerViewDisguises extends PacketAdapter { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (!DisguiseAPI.isSelfDisguised(observer)) { |             if (!DisguiseAPI.isSelfDisguised(observer)) { | ||||||
|  |                 if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) { | ||||||
|  |                     Disguise disguise = DisguiseAPI.getDisguise(observer, observer); | ||||||
|  |  | ||||||
|  |                     if (disguise != null && disguise.isSelfDisguiseVisible()) { | ||||||
|  |                         event.setCancelled(true); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user