Search in sources :

Example 21 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project Railcraft by Railcraft.

the class FluidTools method drainVanillaFluid.

@Nullable
private static FluidStack drainVanillaFluid(IBlockState state, World world, BlockPos pos, boolean doDrain, Fluids fluid, Block... blocks) {
    boolean matches = false;
    for (Block block : blocks) {
        if (state.getBlock() == block)
            matches = true;
    }
    if (!matches)
        return null;
    if (!(state.getBlock() instanceof BlockLiquid))
        return null;
    int level = state.getValue(BlockLiquid.LEVEL);
    if (level != 0)
        return null;
    if (doDrain)
        WorldPlugin.isBlockAir(world, pos);
    return fluid.getBucket();
}
Also used : BlockLiquid(net.minecraft.block.BlockLiquid) Block(net.minecraft.block.Block) Nullable(org.jetbrains.annotations.Nullable)

Example 22 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project Railcraft by Railcraft.

the class ParticleDrip method onUpdate.

/**
 * Called to update the entity's position/logic.
 */
@Override
public void onUpdate() {
    this.prevPosX = posX;
    this.prevPosY = posY;
    this.prevPosZ = posZ;
    this.motionY -= (double) particleGravity;
    if (bobTimer > 0) {
        this.motionX *= 0.02D;
        this.motionY *= 0.02D;
        this.motionZ *= 0.02D;
        setParticleTextureIndex(113);
    } else
        setParticleTextureIndex(112);
    this.bobTimer--;
    move(motionX, motionY, motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;
    if (particleMaxAge <= 0)
        setExpired();
    this.particleMaxAge--;
    if (onGround) {
        setParticleTextureIndex(114);
        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }
    BlockPos pos = new BlockPos(posX, posY, posZ);
    IBlockState blockState = world.getBlockState(pos);
    Material material = blockState.getMaterial();
    if (material.isLiquid() || material.isSolid()) {
        double filledPercent = 0.0D;
        if (blockState.getBlock() instanceof BlockLiquid) {
            filledPercent = (double) BlockLiquid.getLiquidHeightPercent(blockState.getValue(BlockLiquid.LEVEL));
        }
        double surfaceY = (double) (MathHelper.floor(posY) + 1) - filledPercent;
        if (posY < surfaceY) {
            setExpired();
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) BlockPos(net.minecraft.util.math.BlockPos) Material(net.minecraft.block.material.Material)

Example 23 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project ImmersiveEngineering by BluSunrize.

the class ParticleFluidSplash method onUpdate.

@Override
public void onUpdate() {
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= (double) this.particleGravity;
    this.move(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;
    if (this.particleMaxAge-- <= 0)
        this.setExpired();
    if (this.onGround) {
        if (Math.random() < 0.5D)
            this.setExpired();
        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }
    BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
    IBlockState iblockstate = this.world.getBlockState(blockpos);
    Material material = iblockstate.getMaterial();
    if (material.isLiquid() || material.isSolid()) {
        double d0;
        if (iblockstate.getBlock() instanceof BlockLiquid)
            d0 = (double) (1.0F - BlockLiquid.getLiquidHeightPercent(iblockstate.getValue(BlockLiquid.LEVEL).intValue()));
        else
            d0 = iblockstate.getBoundingBox(this.world, blockpos).maxY;
        double d1 = (double) MathHelper.floor(this.posY) + d0;
        if (this.posY < d1)
            this.setExpired();
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) BlockPos(net.minecraft.util.math.BlockPos) Material(net.minecraft.block.material.Material)

Example 24 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project Engine by VoltzEngine-Project.

the class FluidUtility method isFillableBlock.

/**
 * Checks to see if a non-fluid block is able to be filled with fluid
 */
public static boolean isFillableBlock(World world, Pos node) {
    if (world == null || node == null) {
        return false;
    }
    Block block = node.getBlock(world);
    int meta = node.getBlockMetadata(world);
    if (drainBlock(world, node, false) != null) {
        return false;
    } else if (block.isAir(world, node.xi(), node.yi(), node.zi())) {
        return true;
    } else if (!(block instanceof IFluidBlock || block instanceof BlockLiquid) && block.isReplaceable(world, node.xi(), node.yi(), node.zi()) || replacableBlockMeta.contains(new Pair(block, meta)) || replacableBlocks.contains(block)) {
        return true;
    }
    return false;
}
Also used : BlockLiquid(net.minecraft.block.BlockLiquid) Block(net.minecraft.block.Block) Pair(com.builtbroken.jlib.type.Pair)

Example 25 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project RFToolsDimensions by McJty.

the class DimletDebug method dumpBlock.

private static void dumpBlock(Block block) {
    if (block instanceof BlockLiquid) {
        return;
    }
    Set<Filter.Feature> features = KnownDimletConfiguration.getBlockFeatures(block);
    String mod = Block.blockRegistry.getNameForObject(block).getResourceDomain();
    for (IBlockState state : block.getBlockState().getValidStates()) {
        int meta = state.getBlock().getMetaFromState(state);
        List<IProperty> propertyNames = new ArrayList<>(state.getPropertyNames());
        propertyNames.sort((o1, o2) -> o1.getName().compareTo(o2.getName()));
        ImmutableMap<IProperty, Comparable> properties = state.getProperties();
        Map<String, String> props = new HashMap<>();
        for (Map.Entry<IProperty, Comparable> entry : properties.entrySet()) {
            props.put(entry.getKey().getName(), entry.getValue().toString());
        }
        DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
        Settings settings = DimletRules.getSettings(key, mod, features, props);
        Logging.log(key + " (" + state.toString() + "): " + settings.toString());
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IProperty(net.minecraft.block.properties.IProperty) ImmutableMap(com.google.common.collect.ImmutableMap) Settings(mcjty.rftoolsdim.config.Settings)

Aggregations

BlockLiquid (net.minecraft.block.BlockLiquid)57 IBlockState (net.minecraft.block.state.IBlockState)44 Block (net.minecraft.block.Block)27 BlockPos (net.minecraft.util.math.BlockPos)22 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)20 Material (net.minecraft.block.material.Material)11 ItemStack (net.minecraft.item.ItemStack)8 EnumFacing (net.minecraft.util.EnumFacing)5 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)5 BlockPos (net.minecraft.util.BlockPos)4 BlockFluidBase (net.minecraftforge.fluids.BlockFluidBase)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)4 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)3 Entity (net.minecraft.entity.Entity)3 World (net.minecraft.world.World)3 IPlantable (net.minecraftforge.common.IPlantable)3 Location (com.builtbroken.mc.imp.transform.vector.Location)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2