Don't use ProtocolLib's EntityModifier
This commit is contained in:
parent
86d45754c3
commit
c66e0a88e4
@ -1826,6 +1826,18 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Entity getEntity(World world, int entityId) {
|
||||||
|
for (Entity e : world.getEntities()) {
|
||||||
|
if (e.getEntityId() != entityId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Y level to add to the disguise for realism.
|
* Get the Y level to add to the disguise for realism.
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +17,7 @@ import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
||||||
import me.libraryaddict.disguise.events.DisguiseInteractEvent;
|
import me.libraryaddict.disguise.events.DisguiseInteractEvent;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
@ -40,9 +41,11 @@ public class PacketListenerClientInteract extends PacketAdapter {
|
|||||||
|
|
||||||
PacketContainer packet = event.getPacket();
|
PacketContainer packet = event.getPacket();
|
||||||
|
|
||||||
StructureModifier<Entity> entityModifer = packet.getEntityModifier(observer.getWorld());
|
Entity entity = DisguiseUtilities.getEntity(observer.getWorld(), packet.getIntegers().read(0));
|
||||||
|
|
||||||
Entity entity = entityModifer.read(0);
|
if (entity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow ||
|
if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow ||
|
||||||
entity == observer) {
|
entity == observer) {
|
||||||
|
@ -11,6 +11,8 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
|||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.EntityPose;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -35,13 +37,15 @@ public class PacketListenerMain extends PacketAdapter {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// First get the entity, the one sending this packet
|
// First get the entity, the one sending this packet
|
||||||
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());
|
|
||||||
|
|
||||||
org.bukkit.entity.Entity entity = entityModifer.read((Server.COLLECT == event.getPacketType() ? 1 : 0));
|
int entityId = event.getPacket().getIntegers().read(Server.COLLECT == event.getPacketType() ? 1 : 0);
|
||||||
|
|
||||||
|
Entity entity = DisguiseUtilities.getEntity(observer.getWorld(), entityId);
|
||||||
|
|
||||||
// If the entity is the same as the sender. Don't disguise!
|
// If the entity is the same as the sender. Don't disguise!
|
||||||
// Prevents problems and there is no advantage to be gained.
|
// Prevents problems and there is no advantage to be gained.
|
||||||
if (entity == observer)
|
// Or if they are null and there's no disguise
|
||||||
|
if (entity == observer || entity == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
final Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
||||||
|
@ -249,7 +249,11 @@ public class PacketListenerSounds extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// It made a damage animation
|
// It made a damage animation
|
||||||
Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0);
|
Entity entity = DisguiseUtilities.getEntity(observer.getWorld(), event.getPacket().getIntegers().read(0));
|
||||||
|
|
||||||
|
if (entity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user