Search in sources :

Example 16 with PartDataList

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);
    }
}
Also used : PartDataList(net.silentchaos512.gear.api.part.PartDataList) PartData(net.silentchaos512.gear.gear.part.PartData) IPartData(net.silentchaos512.gear.api.part.IPartData)

Example 17 with PartDataList

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();
}
Also used : GearNamePrefixesEvent(net.silentchaos512.gear.api.event.GearNamePrefixesEvent)

Example 18 with PartDataList

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;
}
Also used : PartDataList(net.silentchaos512.gear.api.part.PartDataList) PartType(net.silentchaos512.gear.api.part.PartType) PartData(net.silentchaos512.gear.gear.part.PartData) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem)

Aggregations

PartDataList (net.silentchaos512.gear.api.part.PartDataList)15 PartData (net.silentchaos512.gear.gear.part.PartData)14 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)7 IPartData (net.silentchaos512.gear.api.part.IPartData)7 ItemStack (net.minecraft.world.item.ItemStack)5 PartType (net.silentchaos512.gear.api.part.PartType)5 GearType (net.silentchaos512.gear.api.item.GearType)3 StatGearKey (net.silentchaos512.gear.api.util.StatGearKey)3 CompoundTag (net.minecraft.nbt.CompoundTag)2 ListTag (net.minecraft.nbt.ListTag)2 ITrait (net.silentchaos512.gear.api.traits.ITrait)2 ArrayList (java.util.ArrayList)1 Tag (net.minecraft.nbt.Tag)1 Component (net.minecraft.network.chat.Component)1 TextComponent (net.minecraft.network.chat.TextComponent)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 GearNamePrefixesEvent (net.silentchaos512.gear.api.event.GearNamePrefixesEvent)1 GetTraitsEvent (net.silentchaos512.gear.api.event.GetTraitsEvent)1 ICoreTool (net.silentchaos512.gear.api.item.ICoreTool)1