Fixed getEntity() NMS exception, closes #2
This commit is contained in:
parent
771a0210d9
commit
49e7fefe5f
1 changed files with 8 additions and 5 deletions
|
@ -239,14 +239,17 @@ public class MapWrapper {
|
||||||
@Override
|
@Override
|
||||||
public ItemFrame getItemFrameById(World world, int entityId) {
|
public ItemFrame getItemFrameById(World world, int entityId) {
|
||||||
Object worldHandle = ReflectionUtil.getHandle(world);
|
Object worldHandle = ReflectionUtil.getHandle(world);
|
||||||
Object nmsEntity = ReflectionUtil.callMethod(worldHandle, ReflectionUtil.supports(18) ? "a" : "getEntity");
|
Object nmsEntity = ReflectionUtil.callMethod(worldHandle, ReflectionUtil.supports(18) ? "a" : "getEntity", entityId);
|
||||||
if (nmsEntity == null) return null;
|
if (nmsEntity == null) return null;
|
||||||
|
|
||||||
if (!ReflectionUtil.supports(17)) {
|
Object craftEntity = ReflectionUtil.callMethod(nmsEntity, "getBukkitEntity");
|
||||||
nmsEntity = ReflectionUtil.callMethod(nmsEntity, "getBukkitEntity");
|
if (craftEntity == null) return null;
|
||||||
}
|
|
||||||
|
|
||||||
if (nmsEntity instanceof ItemFrame) return (ItemFrame) nmsEntity;
|
Class<?> itemFrameClass = ReflectionUtil.getNMSClass("world.entity.decoration", "EntityItemFrame");
|
||||||
|
if (itemFrameClass == null) return null;
|
||||||
|
|
||||||
|
if (craftEntity.getClass().isAssignableFrom(itemFrameClass))
|
||||||
|
return (ItemFrame) itemFrameClass.cast(craftEntity);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue