public KnowledgeObject(T holder, String unlocalizedTooltip) { this.globalID = ++prevID; this.holder = holder; this.tooltip = unlocalizedTooltip; this.parents = new ArrayList<>(1); this.children = new ArrayList<>(4); this.fragments = new LinkedHashSet<>(6); this.parentLineNodes = CollectionUtil.newList(new short[] {0, 0}); this.childLineNodes = CollectionUtil.newList(new short[] {0, 0}); allObjects.put(globalID, this); }
public static @Nullable <T extends Entity> T closest(Entity targetEntity, List<T> entities) { return CollectionUtil.min( entities, entity -> entity.isDead || entity == targetEntity ? Double.MAX_VALUE : targetEntity.getDistanceSqToEntity(entity)) .orElse(null); }