use of hellfirepvp.astralsorcery.common.fluid.FluidLiquidStarlight in project AstralSorcery by HellFirePvP.
the class TileFountain method drawLiquidStarlight.
private void drawLiquidStarlight() {
this.tickDrawLiquidStarlight--;
if (this.tickDrawLiquidStarlight <= 0) {
this.tickDrawLiquidStarlight = 100;
if (this.mbLiquidStarlight < (LIQUID_STARLIGHT_TANK_SIZE * 0.8F) && this.currentEffect != null) {
TileChalice chalice = MiscUtils.getTileAt(world, pos.up(), TileChalice.class, false);
if (chalice != null) {
FluidStack fluid = chalice.getTank().drain(400, IFluidHandler.FluidAction.SIMULATE);
if (!fluid.isEmpty() && fluid.getFluid() instanceof FluidLiquidStarlight) {
FluidStack drained = chalice.getTank().drain(new FluidStack(fluid, 400), IFluidHandler.FluidAction.EXECUTE);
this.mbLiquidStarlight += drained.getAmount();
this.markForUpdate();
}
}
}
}
}
use of hellfirepvp.astralsorcery.common.fluid.FluidLiquidStarlight in project AstralSorcery by HellFirePvP.
the class TileChalice method tickLightwellDraw.
private boolean tickLightwellDraw() {
if (getWorld().isBlockPowered(pos)) {
return false;
}
FluidStack thisFluid = this.getTank().getFluid();
if (!thisFluid.isEmpty() && (!(thisFluid.getFluid() instanceof FluidLiquidStarlight) || thisFluid.getAmount() + 100 >= TANK_SIZE)) {
return false;
}
Vector3 thisVector = new Vector3(this).add(0.5, 1.5, 0.5);
List<BlockPos> wellPositions = BlockDiscoverer.searchForBlocksAround(world, pos, 16, BlockPredicates.isBlock(BlocksAS.WELL));
wellPositions.removeIf(pos -> {
Vector3 wellVec = new Vector3(pos).add(0.5, 0.5, 0.5);
RaytraceAssist assist = new RaytraceAssist(thisVector, wellVec);
return !assist.isClear(world);
});
Collections.shuffle(wellPositions, rand);
for (BlockPos wellPos : wellPositions) {
TileWell well = MiscUtils.getTileAt(world, wellPos, TileWell.class, true);
if (well != null) {
FluidStack drained = well.getTank().drain(400, IFluidHandler.FluidAction.SIMULATE);
if (drained.getFluid() instanceof FluidLiquidStarlight && drained.getAmount() > 100) {
int maxFillable = this.getTank().getMaxAddable(drained.getAmount());
if (maxFillable > 0) {
FluidStack actual = well.getTank().drain(new FluidStack(drained, maxFillable), IFluidHandler.FluidAction.EXECUTE);
this.getTank().fill(actual, IFluidHandler.FluidAction.EXECUTE);
Vector3 wellVec = new Vector3(wellPos).add(0.5, 0.5, 0.5);
PktPlayEffect pkt = new PktPlayEffect(PktPlayEffect.Type.LIQUID_INTERACTION_LINE).addData(buf -> {
ByteBufUtils.writeVector(buf, wellVec);
ByteBufUtils.writeVector(buf, thisVector);
ByteBufUtils.writeFluidStack(buf, actual);
});
PacketChannel.CHANNEL.sendToAllAround(pkt, PacketChannel.pointFromPos(getWorld(), wellVec.toBlockPos(), 32));
return true;
}
// Cannot fill from any other either in this case.
return false;
}
}
}
return false;
}
use of hellfirepvp.astralsorcery.common.fluid.FluidLiquidStarlight in project AstralSorcery by HellFirePvP.
the class TileWell method doClientEffects.
@OnlyIn(Dist.CLIENT)
private void doClientEffects() {
ItemStack stack = this.inventory.getStackInSlot(0);
if (!stack.isEmpty()) {
runningRecipe = RecipeTypesAS.TYPE_WELL.findRecipe(new WellLiquefactionContext(this));
if (runningRecipe != null) {
Color color = Color.WHITE;
if (runningRecipe.getCatalystColor() != null) {
color = runningRecipe.getCatalystColor();
}
doCatalystEffect(color);
}
}
if (tank.getFluidAmount() > 0 && tank.getFluid().getFluid() instanceof FluidLiquidStarlight) {
BlockLiquidStarlight.playLiquidStarlightBlockEffect(rand, new Vector3(this).add(0, 0.4 + tank.getPercentageFilled() * 0.5, 0), 0.7F);
}
}
Aggregations