Search in sources :

Example 1 with CrystalAttributeTile

use of hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile 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 CrystalAttributeTile

use of hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile 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 3 with CrystalAttributeTile

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

the class BlockCrystalContainer method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
    Item i = stack.getItem();
    if (i instanceof CrystalAttributeItem) {
        CrystalAttributeTile cat = MiscUtils.getTileAt(world, pos, CrystalAttributeTile.class, true);
        if (cat != null) {
            cat.setAttributes(((CrystalAttributeItem) i).getAttributes(stack));
        }
    }
    if (i instanceof ConstellationItem) {
        ConstellationTile ct = MiscUtils.getTileAt(world, pos, ConstellationTile.class, true);
        if (ct != null) {
            ct.setAttunedConstellation(((ConstellationItem) i).getAttunedConstellation(stack));
            ct.setTraitConstellation(((ConstellationItem) i).getTraitConstellation(stack));
        }
    }
}
Also used : CrystalAttributeItem(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem) Item(net.minecraft.item.Item) ConstellationItem(hellfirepvp.astralsorcery.common.constellation.ConstellationItem) CrystalAttributeItem(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem) CrystalAttributeTile(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile) ConstellationItem(hellfirepvp.astralsorcery.common.constellation.ConstellationItem) ConstellationTile(hellfirepvp.astralsorcery.common.constellation.ConstellationTile)

Aggregations

CrystalAttributeItem (hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem)3 CrystalAttributeTile (hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile)3 ConstellationItem (hellfirepvp.astralsorcery.common.constellation.ConstellationItem)2 ConstellationTile (hellfirepvp.astralsorcery.common.constellation.ConstellationTile)2 CrystalAttributes (hellfirepvp.astralsorcery.common.crystal.CrystalAttributes)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1