Search in sources :

Example 16 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project MorePlanets by SteveKunG.

the class WalkNodeProcessorMP method getStart.

@Override
public PathPoint getStart() {
    int i;
    if (this.getCanSwim() && this.entity.isInWater()) {
        i = (int) this.entity.getEntityBoundingBox().minY;
        BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
        for (Block block = this.blockaccess.getBlockState(mutablePos).getBlock(); block == Blocks.FLOWING_WATER || block == Blocks.WATER || block instanceof BlockFluidBase; block = this.blockaccess.getBlockState(mutablePos).getBlock()) {
            ++i;
            mutablePos.setPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
        }
    } else if (this.entity.onGround) {
        i = MathHelper.floor(this.entity.getEntityBoundingBox().minY + 0.5D);
    } else {
        BlockPos pos;
        for (pos = new BlockPos(this.entity); (this.blockaccess.getBlockState(pos).getMaterial() == Material.AIR || this.blockaccess.getBlockState(pos).getBlock().isPassable(this.blockaccess, pos)) && pos.getY() > 0; pos = pos.down()) {
        }
        i = pos.up().getY();
    }
    BlockPos blockpos2 = new BlockPos(this.entity);
    PathNodeType pathnodetype1 = this.getPathNodeType(this.entity, blockpos2.getX(), i, blockpos2.getZ());
    if (this.entity.getPathPriority(pathnodetype1) < 0.0F) {
        Set<BlockPos> set = new HashSet<>();
        set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, i, this.entity.getEntityBoundingBox().minZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, i, this.entity.getEntityBoundingBox().maxZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, i, this.entity.getEntityBoundingBox().minZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, i, this.entity.getEntityBoundingBox().maxZ));
        for (BlockPos blockpos1 : set) {
            PathNodeType type = this.getPathNodeType(this.entity, blockpos1);
            if (this.entity.getPathPriority(type) >= 0.0F) {
                return this.openPoint(blockpos1.getX(), blockpos1.getY(), blockpos1.getZ());
            }
        }
    }
    return this.openPoint(blockpos2.getX(), i, blockpos2.getZ());
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) PathNodeType(net.minecraft.pathfinding.PathNodeType) PathPoint(net.minecraft.pathfinding.PathPoint) HashSet(java.util.HashSet)

Example 17 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project Gaia-Dimension by Andromander.

the class GDFluidBlock method mixFluids.

public void mixFluids(World world, BlockPos pos) {
    for (EnumFacing side : EnumFacing.VALUES) {
        if (side != EnumFacing.DOWN) {
            IBlockState offset = world.getBlockState(pos.offset(side));
            if (offset.getMaterial().isLiquid()) {
                if ((offset.getMaterial() == Material.LAVA) && (offset.getBlock() != GDBlocks.superhot_magma_block) && (offset.getBlock() instanceof BlockFluidBase || offset.getBlock() instanceof BlockLiquid)) {
                    world.setBlockState(pos, GDBlocks.gaia_cobblestone.getDefaultState());
                    this.playSound(world, pos);
                    break;
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) EnumFacing(net.minecraft.util.EnumFacing)

Example 18 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project Gaia-Dimension by Andromander.

the class GDSuperhotMagma method mixFluids.

@Override
public void mixFluids(World world, BlockPos pos) {
    for (EnumFacing side : EnumFacing.VALUES) {
        if (side != EnumFacing.DOWN) {
            IBlockState offset = world.getBlockState(pos.offset(side));
            if (offset.getMaterial().isLiquid()) {
                if (offset.getBlock() instanceof GDFluidBlock) {
                    if (offset.getBlock() == GDBlocks.mineral_water_block) {
                        world.setBlockState(pos, GDBlocks.gaia_stone.getDefaultState());
                        this.playSound(world, pos);
                        break;
                    }
                    if (offset.getBlock() == GDBlocks.sweet_muck_block) {
                        world.setBlockState(pos, GDBlocks.primal_mass.getDefaultState());
                        this.playSound(world, pos);
                        break;
                    }
                } else if (offset.getBlock() instanceof BlockFluidBase || offset.getBlock() instanceof BlockLiquid) {
                    if (offset.getMaterial() == Material.WATER) {
                        world.setBlockState(pos, GDBlocks.gaia_cobblestone.getDefaultState());
                        this.playSound(world, pos);
                        break;
                    }
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) EnumFacing(net.minecraft.util.EnumFacing)

Aggregations

BlockFluidBase (net.minecraftforge.fluids.BlockFluidBase)18 Block (net.minecraft.block.Block)10 BlockPos (net.minecraft.util.math.BlockPos)6 BlockStaticLiquid (net.minecraft.block.BlockStaticLiquid)5 IBlockState (net.minecraft.block.state.IBlockState)5 BlockLiquid (net.minecraft.block.BlockLiquid)4 BlockDynamicLiquid (net.minecraft.block.BlockDynamicLiquid)3 ItemBlock (net.minecraft.item.ItemBlock)3 ItemStack (net.minecraft.item.ItemStack)3 EnumFacing (net.minecraft.util.EnumFacing)3 Fluid (net.minecraftforge.fluids.Fluid)3 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)3 HashSet (java.util.HashSet)2 BlockFlower (net.minecraft.block.BlockFlower)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 PathNodeType (net.minecraft.pathfinding.PathNodeType)2 PathPoint (net.minecraft.pathfinding.PathPoint)2 Chunk (net.minecraft.world.chunk.Chunk)2 IControllable (buildcraft.api.tiles.IControllable)1 CropHandlerPlantable (buildcraft.core.crops.CropHandlerPlantable)1