public EngineNiard setFluid(Fluid fluid) { if (fluid.canBePlacedInWorld()) { this.radiusItr = radius >= 0 ? new RadiusIterator(owner.getLocation(), radius) : null; this.fluid = fluid; this.downflowDirection = fluid.getDensity() > 0 ? ForgeDirection.DOWN : ForgeDirection.UP; block = fluid.getBlock(); if (block instanceof BlockFluidClassic) { type = FluidType.CLASSIC; } else if (block instanceof BlockFluidFinite) { type = FluidType.FINITE; } else if (block instanceof BlockLiquid) { type = FluidType.VANILLA; } else { this.fluid = null; } } else { this.fluid = null; } return this; }
private void setSourceBlock(BlockCoord bc) { Block blockToSet = block; int metaToSet = 0; final World world = owner.getWorldObj(); switch (type) { case CLASSIC: metaToSet = ((BlockFluidClassic) block).getMaxRenderHeightMeta(); break; case FINITE: metaToSet = ((BlockFluidFinite) block).getMaxRenderHeightMeta(); break; case VANILLA: if (world.provider.isHellWorld && fluid == FluidRegistry.WATER && !niardAllowWaterInHell.getBoolean()) { world.playSoundEffect(bc.x + 0.5F, bc.y + 0.1F, bc.z + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { spawnParticle(world, "largesmoke", bc.x - 1 + 3 * Math.random(), bc.y + Math.random(), bc.z - 1 + 3 * Math.random(), 0.0D, 0.0D, 0.0D); } setVerticalBlock(bc, false); return; } metaToSet = 0; break; } world.setBlock(bc.x, bc.y, bc.z, blockToSet, metaToSet, 3); }
private FluidHelper(@Nonnull World world, @Nonnull FluidStack stack, @Nullable BlockCoord startbc) throws Exception { this.world = world; this.stack = stack; this.fluid = notnullF(stack.getFluid(), "FluidStack.getFluid()"); this.block = notnull(fluid.getBlock(), "Invalid Fluid (it has no source block)"); this.downflowDirection = fluid.getDensity() > 0 ? ForgeDirection.DOWN : ForgeDirection.UP; this.upflowDirection = downflowDirection == ForgeDirection.UP ? ForgeDirection.DOWN : ForgeDirection.UP; if (this.block instanceof BlockFluidClassic) { this.type = FluidType.CLASSIC; } else if (this.block instanceof BlockFluidFinite) { this.type = FluidType.FINITE; } else if (this.block instanceof BlockLiquid) { this.type = FluidType.VANILLA; } else { throw new Exception(); } this.startbc = startbc; }
public static boolean isSourceBlock(@Nonnull World world, @Nonnull BlockCoord bc) { if (!world.blockExists(bc.x, bc.y, bc.z)) { return false; } Block block = bc.getBlock(world); if (block instanceof BlockFluidClassic) { return ((BlockFluidClassic) block).isSourceBlock(world, bc.x, bc.y, bc.z); } else if (block instanceof BlockFluidFinite) { return ((BlockFluidFinite)block).canDrain(world, bc.x, bc.y, bc.z); } else if (block instanceof BlockLiquid) { return world.getBlockMetadata(bc.x, bc.y, bc.z) == 0; } else { return false; } }
public BlockFluidBase makeBlock(){ return new BlockFluidFinite(this, Material.water); }