@SuppressWarnings({"unchecked", "rawtypes"})
public EntityNetworkController<CommonEntity<T>> getNetworkController() {
if (EntityRef.world.getInternal(getHandle()) == null) {
return null;
}
final EntityNetworkController result;
final Object entityTrackerEntry = WorldUtil.getTrackerEntry(entity);
if (entityTrackerEntry == null) {
return null;
} else if (entityTrackerEntry instanceof NMSEntityTrackerEntry) {
result = ((NMSEntityTrackerEntry) entityTrackerEntry).getController();
} else if (EntityTrackerEntry.class.equals(entityTrackerEntry.getClass())) {
result = new DefaultEntityNetworkController();
result.bind(this, entityTrackerEntry);
} else {
result = new ExternalEntityNetworkController();
result.bind(this, entityTrackerEntry);
}
return result;
}