use of hellfirepvp.astralsorcery.common.constellation.ConstellationTile in project AstralSorcery by HellFirePvP.
the class CopyConstellation 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 ConstellationTile && stack.getItem() instanceof ConstellationItem) {
IWeakConstellation main = ((ConstellationTile) tile).getAttunedConstellation();
IMinorConstellation trait = ((ConstellationTile) tile).getTraitConstellation();
((ConstellationItem) stack.getItem()).setAttunedConstellation(stack, main);
((ConstellationItem) stack.getItem()).setTraitConstellation(stack, trait);
}
}
return stack;
}
use of hellfirepvp.astralsorcery.common.constellation.ConstellationTile 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.constellation.ConstellationTile 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));
}
}
}
Aggregations