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