Search in sources :

Example 1 with TileCelestialCrystals

use of hellfirepvp.astralsorcery.common.tile.TileCelestialCrystals 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)1 CrystalAttributes (hellfirepvp.astralsorcery.common.crystal.CrystalAttributes)1 ItemCrystalBase (hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase)1 TileCelestialCrystals (hellfirepvp.astralsorcery.common.tile.TileCelestialCrystals)1 ItemStack (net.minecraft.item.ItemStack)1