use of hellfirepvp.astralsorcery.common.perk.node.RootPerk in project AstralSorcery by HellFirePvP.
the class PreparedPerkTreeData method create.
static PreparedPerkTreeData create(Collection<LoadedPerkData> perks) {
PreparedPerkTreeData treeData = new PreparedPerkTreeData();
perks.stream().map(LoadedPerkData::getPerk).forEach(perk -> {
if (perk instanceof RootPerk) {
treeData.rootPerks.put(((RootPerk) perk).getConstellation(), (RootPerk) perk);
}
PerkTreePoint<? extends AbstractPerk> offsetPoint = perk.getPoint();
if (treeData.treePoints.contains(offsetPoint)) {
throw new IllegalArgumentException("Tried to register perk-point at already placed position: " + offsetPoint.getOffset().toString());
}
treeData.treePoints.add((PerkTreePoint<AbstractPerk>) offsetPoint);
});
perks.forEach(perkData -> {
for (ResourceLocation connection : perkData.getConnections()) {
AbstractPerk perkTo = treeData.getPerk(perk -> connection.equals(perk.getRegistryName())).orElseThrow(() -> new JsonParseException("Cannot connect to unknown perk: " + connection));
treeData.getConnector(perkTo).ifPresent(connector -> {
connector.connect(perkData.getPerk());
});
}
});
treeData.version = treeData.computeTreeHash();
return treeData;
}
Aggregations