Search in sources :

Example 1 with CrystalAttributeItem

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

the class BlockCrystalContainer method getPickBlock.

@Override
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) {
    ItemStack stack = super.getPickBlock(state, target, world, pos, player);
    if (stack.getItem() instanceof CrystalAttributeItem) {
        CrystalAttributeTile cat = MiscUtils.getTileAt(world, pos, CrystalAttributeTile.class, true);
        if (cat != null) {
            ((CrystalAttributeItem) stack.getItem()).setAttributes(stack, cat.getAttributes());
        }
    }
    if (stack.getItem() instanceof ConstellationItem) {
        ConstellationTile ct = MiscUtils.getTileAt(world, pos, ConstellationTile.class, true);
        if (ct != null) {
            ((ConstellationItem) stack.getItem()).setAttunedConstellation(stack, ct.getAttunedConstellation());
            ((ConstellationItem) stack.getItem()).setTraitConstellation(stack, ct.getTraitConstellation());
        }
    }
    return stack;
}
Also used : ItemStack(net.minecraft.item.ItemStack) CrystalAttributeItem(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem) CrystalAttributeTile(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile) ConstellationItem(hellfirepvp.astralsorcery.common.constellation.ConstellationItem) ConstellationTile(hellfirepvp.astralsorcery.common.constellation.ConstellationTile)

Example 2 with CrystalAttributeItem

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

the class ConstellationBaseMergeStatsRecipe method setStats.

private void setStats(ItemStack out, Iterable<ItemStack> inventoryContents) {
    if (!(out.getItem() instanceof CrystalAttributeItem)) {
        return;
    }
    CrystalAttributes.Builder builder = CrystalAttributes.Builder.newBuilder(true);
    for (ItemStack stack : inventoryContents) {
        if (stack.getItem() instanceof CrystalAttributeItem) {
            CrystalAttributes attr = ((CrystalAttributeItem) stack.getItem()).getAttributes(stack);
            if (attr != null) {
                builder.addAll(attr);
            }
        }
    }
    CrystalAttributes attr = builder.build();
    if (!attr.isEmpty()) {
        ((CrystalAttributeItem) out.getItem()).setAttributes(out, attr);
    }
}
Also used : CrystalAttributes(hellfirepvp.astralsorcery.common.crystal.CrystalAttributes) CrystalAttributeItem(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem) ItemStack(net.minecraft.item.ItemStack)

Example 3 with CrystalAttributeItem

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

the class TileRitualPedestal method setReceiverData.

// Stuff sent over from StarlightReceiverRitualPedestal
public void setReceiverData(boolean working, Map<BlockPos, Boolean> mirrorData, @Nullable CrystalAttributes newAttributes) {
    this.working = working;
    this.offsetMirrors = new HashMap<>(mirrorData);
    ItemStack crystal = this.getCurrentCrystal();
    if (!crystal.isEmpty() && crystal.getItem() instanceof CrystalAttributeItem) {
        if (newAttributes == null) {
            this.tryPlaceCrystalInPedestal(ItemStack.EMPTY);
        } else {
            this.setAttributes(newAttributes.copy());
        }
    }
    this.markForUpdate();
    this.preventNetworkSync();
}
Also used : ItemStack(net.minecraft.item.ItemStack) CrystalAttributeItem(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem)

Example 4 with CrystalAttributeItem

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

the class CopyCrystalProperties method doApply.

@Override
protected ItemStack doApply(ItemStack stack, LootContext context) {
    if (context.has(LootParameters.BLOCK_ENTITY)) {
        TileEntity tile = context.get(LootParameters.BLOCK_ENTITY);
        if (tile instanceof CrystalAttributeTile && stack.getItem() instanceof CrystalAttributeItem) {
            CrystalAttributes attr = ((CrystalAttributeTile) tile).getAttributes();
            if (attr == null) {
                attr = ((CrystalAttributeTile) tile).getMissingAttributes();
            }
            ((CrystalAttributeItem) stack.getItem()).setAttributes(stack, attr);
        }
    }
    return stack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CrystalAttributes(hellfirepvp.astralsorcery.common.crystal.CrystalAttributes) CrystalAttributeItem(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem) CrystalAttributeTile(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile)

Example 5 with CrystalAttributeItem

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

the class FormCelestialCrystalClusterRecipe method doServerCraftTick.

@Override
public void doServerCraftTick(ItemEntity trigger, World world, BlockPos at) {
    Random r = new Random(MathHelper.getPositionRandom(at));
    if (!world.isRemote() && getAndIncrementCraftingTick(trigger) > 50 + r.nextInt(20)) {
        ItemStack crystalFound;
        if (consumeItemEntityInBlock(world, at, ItemsAS.STARDUST) != null && (crystalFound = consumeItemEntityInBlock(world, at, 1, stack -> stack.getItem() instanceof ItemCrystalBase)) != null) {
            if (world.setBlockState(at, BlocksAS.CELESTIAL_CRYSTAL_CLUSTER.getDefaultState())) {
                TileCelestialCrystals cluster = MiscUtils.getTileAt(world, at, TileCelestialCrystals.class, true);
                if (cluster != null) {
                    CrystalAttributes attr = ((CrystalAttributeItem) crystalFound.getItem()).getAttributes(crystalFound);
                    ItemStack targetCrystal = new ItemStack(ItemsAS.CELESTIAL_CRYSTAL);
                    ((CrystalAttributeItem) crystalFound.getItem()).setAttributes(targetCrystal, attr);
                    cluster.setAttributes(CrystalGenerator.upgradeProperties(targetCrystal));
                }
            }
        }
    }
}
Also used : CrystalAttributes(hellfirepvp.astralsorcery.common.crystal.CrystalAttributes) ItemCrystalBase(hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase) ItemStack(net.minecraft.item.ItemStack) CrystalAttributeItem(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem) TileCelestialCrystals(hellfirepvp.astralsorcery.common.tile.TileCelestialCrystals)

Aggregations

CrystalAttributeItem (hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem)8 ItemStack (net.minecraft.item.ItemStack)6 CrystalAttributes (hellfirepvp.astralsorcery.common.crystal.CrystalAttributes)5 CrystalAttributeTile (hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile)3 ConstellationItem (hellfirepvp.astralsorcery.common.constellation.ConstellationItem)2 ConstellationTile (hellfirepvp.astralsorcery.common.constellation.ConstellationTile)2 WellLiquefactionContext (hellfirepvp.astralsorcery.common.crafting.recipe.WellLiquefactionContext)1 ItemCrystalBase (hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase)1 TileCelestialCrystals (hellfirepvp.astralsorcery.common.tile.TileCelestialCrystals)1 Item (net.minecraft.item.Item)1 TileEntity (net.minecraft.tileentity.TileEntity)1