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));
}
}
}
}
}
Aggregations