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