Search in sources :

Example 1 with FountainEffect

use of hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect in project AstralSorcery by HellFirePvP.

the class TileFountain method replaceEffect.

@OnlyIn(Dist.CLIENT)
public static void replaceEffect(PktPlayEffect pktPlayEffect) {
    BlockPos at = ByteBufUtils.readPos(pktPlayEffect.getExtraData());
    World world = Minecraft.getInstance().world;
    if (world == null) {
        return;
    }
    TileFountain fountain = MiscUtils.getTileAt(world, at, TileFountain.class, false);
    if (fountain == null) {
        return;
    }
    FountainEffect effect = fountain.getCurrentEffect();
    if (effect == null) {
        return;
    }
    effect.onReplace(fountain, fountain.effectContext, null, LogicalSide.CLIENT);
}
Also used : FountainEffect(hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 2 with FountainEffect

use of hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect in project AstralSorcery by HellFirePvP.

the class TileFountain method tick.

@Override
public void tick() {
    super.tick();
    if (!getWorld().isRemote()) {
        if (this.hasMultiblock()) {
            this.updateFountainComponents();
            this.drawLiquidStarlight();
            FountainEffect effect = this.getCurrentEffect();
            if (effect != null) {
                FountainEffect.EffectContext ctx = this.effectContext;
                if (!this.consumeLiquidStarlight(1)) {
                    this.setCurrentEffect(null);
                    this.replaceCurrentEffect(effect, ctx, null);
                    return;
                }
                FountainEffect.OperationSegment segment = getSegment();
                if (segment != FountainEffect.OperationSegment.RUNNING) {
                    this.tickActiveFountainEffect++;
                }
                FountainEffect.OperationSegment nextSegment = getSegment();
                if (segment != nextSegment) {
                    effect.transition(this, ctx, LogicalSide.SERVER, segment, nextSegment);
                    PktPlayEffect pkt = new PktPlayEffect(PktPlayEffect.Type.FOUNTAIN_TRANSITION_SEGMENT).addData(buf -> {
                        ByteBufUtils.writePos(buf, pos);
                        ByteBufUtils.writeEnumValue(buf, segment);
                        ByteBufUtils.writeEnumValue(buf, nextSegment);
                    });
                    PacketChannel.CHANNEL.sendToAllAround(pkt, PacketChannel.pointFromPos(world, pos, 32));
                }
                effect.tick(this, ctx, this.tickActiveFountainEffect, LogicalSide.SERVER, this.getSegment());
            }
        }
    } else {
        if (this.hasMultiblock()) {
            FountainEffect effect = this.getCurrentEffect();
            if (effect != null) {
                effect.tick(this, this.effectContext, this.tickActiveFountainEffect, LogicalSide.CLIENT, getSegment());
            }
        }
    }
}
Also used : FountainEffect(hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect) PktPlayEffect(hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect)

Example 3 with FountainEffect

use of hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect in project AstralSorcery by HellFirePvP.

the class TileFountain method updateFountainComponents.

private void updateFountainComponents() {
    FountainEffect prevEffect = this.getCurrentEffect();
    FountainEffect.EffectContext prevContext = this.effectContext;
    BlockState primeState = world.getBlockState(pos.down());
    if (primeState.getBlock() instanceof BlockFountainPrime) {
        if (this.setCurrentEffect(((BlockFountainPrime) primeState.getBlock()).provideEffect()) && prevEffect != null) {
            this.replaceCurrentEffect(prevEffect, prevContext, this.getCurrentEffect());
        }
    } else {
        if (this.setCurrentEffect(null) && prevEffect != null) {
            this.replaceCurrentEffect(prevEffect, prevContext, null);
        }
    }
}
Also used : FountainEffect(hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect) BlockState(net.minecraft.block.BlockState) BlockFountainPrime(hellfirepvp.astralsorcery.common.block.tile.fountain.BlockFountainPrime)

Example 4 with FountainEffect

use of hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect in project AstralSorcery by HellFirePvP.

the class TileFountain method playTransitionEffect.

@OnlyIn(Dist.CLIENT)
public static void playTransitionEffect(PktPlayEffect pktPlayEffect) {
    BlockPos at = ByteBufUtils.readPos(pktPlayEffect.getExtraData());
    FountainEffect.OperationSegment segment = ByteBufUtils.readEnumValue(pktPlayEffect.getExtraData(), FountainEffect.OperationSegment.class);
    FountainEffect.OperationSegment nextSegment = ByteBufUtils.readEnumValue(pktPlayEffect.getExtraData(), FountainEffect.OperationSegment.class);
    World world = Minecraft.getInstance().world;
    if (world == null) {
        return;
    }
    TileFountain fountain = MiscUtils.getTileAt(world, at, TileFountain.class, false);
    if (fountain == null) {
        return;
    }
    FountainEffect effect = fountain.getCurrentEffect();
    if (effect == null) {
        return;
    }
    effect.transition(fountain, fountain.effectContext, LogicalSide.CLIENT, segment, nextSegment);
}
Also used : FountainEffect(hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

FountainEffect (hellfirepvp.astralsorcery.common.crafting.nojson.fountain.FountainEffect)4 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)2 BlockFountainPrime (hellfirepvp.astralsorcery.common.block.tile.fountain.BlockFountainPrime)1 PktPlayEffect (hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect)1 BlockState (net.minecraft.block.BlockState)1