Search in sources :

Example 1 with CrystalProperty

use of hellfirepvp.astralsorcery.common.crystal.CrystalProperty in project AstralSorcery by HellFirePvP.

the class ItemBlockCollectorCrystal method fillItemGroup.

@Override
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> stacks) {
    if (isInGroup(group)) {
        for (IWeakConstellation cst : ConstellationRegistry.getWeakConstellations()) {
            ItemStack stack = new ItemStack(this);
            setAttunedConstellation(stack, cst);
            CrystalProperty prop = CrystalPropertyRegistry.INSTANCE.getConstellationProperty(cst);
            CrystalAttributes attr = this.getCreativeTemplateAttributes();
            if (prop != null) {
                attr = attr.modifyLevel(prop, prop.getMaxTier());
            }
            attr.store(stack);
            stacks.add(stack);
        }
    }
}
Also used : CrystalAttributes(hellfirepvp.astralsorcery.common.crystal.CrystalAttributes) ItemStack(net.minecraft.item.ItemStack) CrystalProperty(hellfirepvp.astralsorcery.common.crystal.CrystalProperty)

Example 2 with CrystalProperty

use of hellfirepvp.astralsorcery.common.crystal.CrystalProperty in project AstralSorcery by HellFirePvP.

the class EntityCrystal method splitCrystal.

private boolean splitCrystal(CrystalAttributes thisAttributes, int fortuneLevel) {
    ItemCrystalBase newBase = ((ItemCrystalBase) this.getItem().getItem()).getInertDuplicateItem();
    if (newBase == null) {
        return false;
    }
    ItemStack created = new ItemStack(newBase);
    if (created.isEmpty()) {
        return false;
    }
    int maxSplit = MathHelper.ceil(thisAttributes.getTotalTierLevel() / 2F);
    if (maxSplit >= thisAttributes.getTotalTierLevel()) {
        return false;
    }
    int lostModifiers = 0;
    if (maxSplit > 1 && rand.nextFloat() < (0.6F / (fortuneLevel + 1))) {
        lostModifiers++;
        if (maxSplit > 2 && rand.nextFloat() < (0.2F / (fortuneLevel + 1))) {
            lostModifiers++;
        }
    }
    CrystalAttributes resultThisAttributes = thisAttributes;
    CrystalAttributes.Builder resultSplitAttributes = CrystalAttributes.Builder.newBuilder(false);
    for (int i = 0; i < maxSplit; i++) {
        CrystalProperty prop = MiscUtils.getRandomEntry(resultThisAttributes.getProperties(), rand);
        if (prop == null) {
            break;
        }
        resultThisAttributes = resultThisAttributes.modifyLevel(prop, -1);
        if (lostModifiers > 0) {
            lostModifiers--;
        } else {
            resultSplitAttributes.addProperty(prop, 1);
        }
    }
    ((ItemCrystalBase) this.getItem().getItem()).setAttributes(this.getItem(), resultThisAttributes);
    newBase.setAttributes(created, resultSplitAttributes.build());
    ItemUtils.dropItemNaturally(getEntityWorld(), this.getPosX(), this.getPosY() + 0.25F, this.getPosZ(), created);
    return true;
}
Also used : CrystalAttributes(hellfirepvp.astralsorcery.common.crystal.CrystalAttributes) ItemCrystalBase(hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase) ItemStack(net.minecraft.item.ItemStack) CrystalProperty(hellfirepvp.astralsorcery.common.crystal.CrystalProperty)

Aggregations

CrystalAttributes (hellfirepvp.astralsorcery.common.crystal.CrystalAttributes)2 CrystalProperty (hellfirepvp.astralsorcery.common.crystal.CrystalProperty)2 ItemStack (net.minecraft.item.ItemStack)2 ItemCrystalBase (hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase)1