Search in sources :

Example 1 with TileRitualPedestal

use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.

the class StarlightReceiverRitualPedestal method updateFromTileEntity.

@Override
public <T extends TileEntity> boolean updateFromTileEntity(T tile) {
    if (!(tile instanceof TileRitualPedestal)) {
        // Whatever.
        return super.updateFromTileEntity(tile);
    }
    TileRitualPedestal trp = (TileRitualPedestal) tile;
    if (this.channelingType != trp.getRitualConstellation() || (this.attributes != null && trp.getAttributes() == null) || this.hasMultiblock != trp.hasMultiblock()) {
        this.effect = null;
        this.offsetMirrors.clear();
        if (trp.isWorking() || !trp.getMirrors().isEmpty()) {
            this.markForTileSync();
        }
    }
    boolean ritualLinkChanged;
    if (this.ritualLinkPos == null) {
        ritualLinkChanged = trp.getRitualLinkTo() != null;
    } else {
        ritualLinkChanged = !this.ritualLinkPos.equals(trp.getRitualLinkTo());
    }
    this.doesSeeSky = trp.doesSeeSky();
    this.hasMultiblock = trp.hasMultiblock();
    this.channelingType = trp.getRitualConstellation();
    this.channelingTrait = trp.getRitualTrait();
    this.attributes = trp.getAttributes();
    this.ritualLinkPos = trp.getRitualLinkTo();
    if (this.channelingType != null && this.attributes != null && this.hasMultiblock && (this.effect == null || ritualLinkChanged)) {
        this.effect = ConstellationEffectRegistry.createInstance(this, this.channelingType);
        this.markForTileSync();
    }
    if (!this.hasMultiblock || this.effect == null) {
        this.collectedStarlight = 0;
    }
    this.markDirty(trp.getWorld());
    return super.updateFromTileEntity(tile);
}
Also used : TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal)

Example 2 with TileRitualPedestal

use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.

the class ConstellationEffect method getPedestal.

@Nullable
public TileRitualPedestal getPedestal(World world, BlockPos pos) {
    TileEntity te = MiscUtils.getTileAt(world, pos, TileEntity.class, false);
    if (te instanceof TileRitualLink) {
        TileRitualLink link = (TileRitualLink) te;
        pos = link.getLinkedTo();
        if (pos != null) {
            pos = pos.subtract(TileRitualPedestal.RITUAL_ANCHOR_OFFEST);
            return MiscUtils.getTileAt(world, pos, TileRitualPedestal.class, false);
        }
    }
    return te instanceof TileRitualPedestal ? (TileRitualPedestal) te : null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) TileRitualLink(hellfirepvp.astralsorcery.common.tile.TileRitualLink) Nullable(javax.annotation.Nullable)

Example 3 with TileRitualPedestal

use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.

the class RegistryCrystalProperties method initDefaultAttributes.

public static void initDefaultAttributes() {
    SOURCE_RITUAL_PEDESTAL = new PropertySource<StarlightReceiverRitualPedestal, Ritual>(AstralSorcery.key("ritual_network")) {

        @Override
        public Ritual createInstance(StarlightReceiverRitualPedestal obj) {
            return new Ritual(this, obj.getChannelingType(), obj.getChannelingTrait());
        }
    };
    SOURCE_TILE_RITUAL_PEDESTAL = new PropertySource<TileRitualPedestal, Ritual>(AstralSorcery.key("ritual_tile")) {

        @Override
        public Ritual createInstance(TileRitualPedestal obj) {
            return new Ritual(this, obj.getRitualConstellation(), obj.getRitualTrait());
        }
    };
    SOURCE_COLLECTOR_CRYSTAL = new PropertySource<IndependentCrystalSource, Crystal>(AstralSorcery.key("crystal_network")) {

        @Override
        public Crystal createInstance(IndependentCrystalSource obj) {
            return new Crystal(this, obj.getStarlightType());
        }
    };
    SOURCE_TILE_COLLECTOR_CRYSTAL = new PropertySource<TileCollectorCrystal, Crystal>(AstralSorcery.key("crystal_tile")) {

        @Override
        public Crystal createInstance(TileCollectorCrystal obj) {
            return new Crystal(this, obj.getAttunedConstellation());
        }
    };
    CREATIVE_CRYSTAL_TOOL_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_SIZE, 3).addProperty(PROPERTY_SHAPE, 3).addProperty(PROPERTY_TOOL_DURABILITY, 3).addProperty(PROPERTY_TOOL_EFFICIENCY, 3).build();
    WORLDGEN_SHRINE_COLLECTOR_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_SIZE, 2).addProperty(PROPERTY_SHAPE, 2).addProperty(PROPERTY_PURITY, 2).addProperty(PROPERTY_COLLECTOR_COLLECTION_RATE, 2).build();
    CREATIVE_ROCK_COLLECTOR_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_SIZE, 3).addProperty(PROPERTY_SHAPE, 3).addProperty(PROPERTY_PURITY, 2).addProperty(PROPERTY_COLLECTOR_COLLECTION_RATE, 3).build();
    CREATIVE_CELESTIAL_COLLECTOR_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_SIZE, 3).addProperty(PROPERTY_SHAPE, 3).addProperty(PROPERTY_PURITY, 2).addProperty(PROPERTY_COLLECTOR_COLLECTION_RATE, 3).build();
    LENS_PRISM_CREATIVE_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_PURITY, 2).addProperty(PROPERTY_SHAPE, 3).build();
}
Also used : TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) IndependentCrystalSource(hellfirepvp.astralsorcery.common.starlight.transmission.base.crystal.IndependentCrystalSource) StarlightReceiverRitualPedestal(hellfirepvp.astralsorcery.common.tile.network.StarlightReceiverRitualPedestal) Ritual(hellfirepvp.astralsorcery.common.crystal.source.Ritual) TileCollectorCrystal(hellfirepvp.astralsorcery.common.tile.TileCollectorCrystal) Crystal(hellfirepvp.astralsorcery.common.crystal.source.Crystal) TileCollectorCrystal(hellfirepvp.astralsorcery.common.tile.TileCollectorCrystal)

Example 4 with TileRitualPedestal

use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.

the class BlockRitualPedestal method neighborChanged.

@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
    super.neighborChanged(state, world, pos, block, fromPos, isMoving);
    TileRitualPedestal te = MiscUtils.getTileAt(world, pos, TileRitualPedestal.class, true);
    if (te != null && !world.isRemote()) {
        BlockPos toCheck = pos.up();
        BlockState other = world.getBlockState(toCheck);
        if (Block.doesSideFillSquare(other.getCollisionShape(world, pos), Direction.DOWN)) {
            ItemUtils.dropItem(world, pos.getX() + 0.5, pos.getY() + 0.8, pos.getZ() + 0.5, te.getCurrentCrystal());
            te.tryPlaceCrystalInPedestal(ItemStack.EMPTY);
        }
    }
}
Also used : TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with TileRitualPedestal

use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.

the class BlockRitualPedestal method onBlockActivated.

@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rtr) {
    if (world.isRemote()) {
        return ActionResultType.SUCCESS;
    }
    TileRitualPedestal pedestal = MiscUtils.getTileAt(world, pos, TileRitualPedestal.class, true);
    if (pedestal == null) {
        return ActionResultType.PASS;
    }
    ItemStack heldItem = player.getHeldItem(hand);
    ItemStack in = pedestal.getCurrentCrystal();
    if (player.isSneaking()) {
        pedestal.tryPlaceCrystalInPedestal(ItemStack.EMPTY);
        if (player.getHeldItem(hand).isEmpty()) {
            player.setHeldItem(hand, in);
        } else {
            player.inventory.placeItemBackInInventory(world, in);
        }
    } else {
        player.setHeldItem(hand, pedestal.tryPlaceCrystalInPedestal(heldItem));
    }
    return ActionResultType.SUCCESS;
}
Also used : TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileRitualPedestal (hellfirepvp.astralsorcery.common.tile.TileRitualPedestal)5 Crystal (hellfirepvp.astralsorcery.common.crystal.source.Crystal)1 Ritual (hellfirepvp.astralsorcery.common.crystal.source.Ritual)1 IndependentCrystalSource (hellfirepvp.astralsorcery.common.starlight.transmission.base.crystal.IndependentCrystalSource)1 TileCollectorCrystal (hellfirepvp.astralsorcery.common.tile.TileCollectorCrystal)1 TileRitualLink (hellfirepvp.astralsorcery.common.tile.TileRitualLink)1 StarlightReceiverRitualPedestal (hellfirepvp.astralsorcery.common.tile.network.StarlightReceiverRitualPedestal)1 Nullable (javax.annotation.Nullable)1 BlockState (net.minecraft.block.BlockState)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1