use of net.silentchaos512.gear.api.part.PartDataList in project Silent-Gear by SilentChaos512.
the class GearData method removeExcessParts.
public static void removeExcessParts(ItemStack gear, PartType partType) {
// Mostly just to correct https://github.com/SilentChaos512/Silent-Gear/issues/242
PartDataList parts = getConstructionParts(gear);
List<PartData> partsOfType = new ArrayList<>(parts.getPartsOfType(partType));
int maxCount = partType.getMaxPerItem(GearHelper.getType(gear));
int removed = 0;
while (partsOfType.size() > maxCount) {
PartData toRemove = partsOfType.get(0);
partsOfType.remove(toRemove);
parts.remove(toRemove);
toRemove.onRemoveFromGear(gear);
++removed;
SilentGear.LOGGER.debug("Removed excess part '{}' from '{}'", toRemove.getDisplayName(gear).getString(), gear.getHoverName().getString());
}
if (removed > 0) {
writeConstructionParts(gear, parts);
}
}
use of net.silentchaos512.gear.api.part.PartDataList in project Silent-Gear by SilentChaos512.
the class GearHelper method getNamePrefixes.
private static Collection<Component> getNamePrefixes(ItemStack gear, PartDataList parts) {
GearNamePrefixesEvent event = new GearNamePrefixesEvent(gear, parts);
MinecraftForge.EVENT_BUS.post(event);
return event.getPrefixes();
}
use of net.silentchaos512.gear.api.part.PartDataList in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method getPartsInRenderOrder.
private static PartDataList getPartsInRenderOrder(ItemStack stack) {
PartDataList unsorted = GearData.getConstructionParts(stack);
PartDataList ret = PartDataList.of();
ICoreItem item = (ICoreItem) stack.getItem();
for (PartType partType : item.getRenderParts()) {
ret.addAll(unsorted.getPartsOfType(partType));
}
for (PartData part : unsorted) {
if (!ret.contains(part)) {
ret.add(part);
}
}
return ret;
}
Aggregations