Search in sources :

Example 1 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 blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
        for (Block block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock(); block == Blocks.FLOWING_WATER || block == Blocks.WATER || block instanceof BlockFluidBase; block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock()) {
            ++i;
            blockpos$mutableblockpos.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 blockpos;
        for (blockpos = new BlockPos(this.entity); (this.blockaccess.getBlockState(blockpos).getMaterial() == Material.AIR || this.blockaccess.getBlockState(blockpos).getBlock().isPassable(this.blockaccess, blockpos)) && blockpos.getY() > 0; blockpos = blockpos.down()) {
        }
        i = blockpos.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 pathnodetype = this.getPathNodeType(this.entity, blockpos1);
            if (this.entity.getPathPriority(pathnodetype) >= 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 2 with BlockFluidBase

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

the class PathNavigateGroundMP method getPathablePosY.

private int getPathablePosY() {
    if (this.entity.isInWater() && this.getCanSwim()) {
        int i = (int) this.entity.getEntityBoundingBox().minY;
        Block block = this.world.getBlockState(new BlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ))).getBlock();
        int j = 0;
        while (block == Blocks.FLOWING_WATER || block == Blocks.WATER || block instanceof BlockFluidBase && this.world.getBlockState(new BlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ))).getMaterial() == Material.WATER) {
            ++i;
            block = this.world.getBlockState(new BlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ))).getBlock();
            ++j;
            if (j > 16) {
                return (int) this.entity.getEntityBoundingBox().minY;
            }
        }
        return i;
    } else {
        return (int) (this.entity.getEntityBoundingBox().minY + 0.5D);
    }
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project BuildCraft by BuildCraft.

the class OilPopulateOld method getTopBlock.

private int getTopBlock(World world, int x, int z) {
    BlockPos pos = new BlockPos(x, 0, z);
    Chunk chunk = world.getChunkFromBlockCoords(pos);
    int y = chunk.getTopFilledSegment() + 15;
    pos = pos.up(y);
    int trimmedX = x & 15;
    int trimmedZ = z & 15;
    for (; y > 0; --y) {
        Block block = chunk.getBlock(trimmedX, y, trimmedZ);
        if (block.isAir(world, pos)) {
            continue;
        }
        if (block instanceof BlockStaticLiquid) {
            return y;
        }
        if (block instanceof BlockFluidBase) {
            return y;
        }
        if (block instanceof IFluidBlock) {
            return y;
        }
        if (!block.getMaterial().blocksMovement()) {
            continue;
        }
        if (block instanceof BlockFlower) {
            continue;
        }
        return y - 1;
    }
    return -1;
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) BlockStaticLiquid(net.minecraft.block.BlockStaticLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) BlockPos(net.minecraft.util.math.BlockPos) Chunk(net.minecraft.world.chunk.Chunk) BlockFlower(net.minecraft.block.BlockFlower)

Example 4 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project BuildCraft by BuildCraft.

the class TileFloodGate method placeFluid.

private boolean placeFluid(BlockPos pos, Fluid fluid) {
    Block block = BlockUtil.getBlockState(worldObj, pos).getBlock();
    if (canPlaceFluidAt(block, pos)) {
        boolean placed;
        Block b = TankUtils.getFluidBlock(fluid, true);
        if (b instanceof BlockFluidBase) {
            BlockFluidBase blockFluid = (BlockFluidBase) b;
            placed = worldObj.setBlockState(pos, blockFluid.getDefaultState(), 3);
        } else {
            placed = worldObj.setBlockState(pos, b.getDefaultState());
        }
        if (placed) {
            queueAdjacent(pos);
            expandQueue();
        }
        return placed;
    }
    return false;
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) Block(net.minecraft.block.Block)

Example 5 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project BuildCraft by BuildCraft.

the class BuildCraftCore method postInit.

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
    BCLog.logger.info("BuildCraft's fake player: UUID = " + gameProfile.getId().toString() + ", name = '" + gameProfile.getName() + "'!");
    BCRegistry.INSTANCE.save();
    for (Object o : Block.blockRegistry) {
        Block block = (Block) o;
        if (block instanceof BlockFluidBase || block instanceof BlockLiquid || block instanceof IPlantable) {
            BuildCraftAPI.softBlocks.add(block);
        }
    }
    BuildCraftAPI.softBlocks.add(Blocks.snow);
    BuildCraftAPI.softBlocks.add(Blocks.vine);
    BuildCraftAPI.softBlocks.add(Blocks.fire);
    CropManager.setDefaultHandler(new CropHandlerPlantable());
    CropManager.registerHandler(new CropHandlerReeds());
    BuildCraftAPI.registerWorldProperty("replaceable", new WorldPropertyIsReplaceable());
    BuildCraftAPI.registerWorldProperty("soft", new WorldPropertyIsSoft());
    BuildCraftAPI.registerWorldProperty("wood", new WorldPropertyIsWood());
    BuildCraftAPI.registerWorldProperty("leaves", new WorldPropertyIsLeaf());
    for (int i = 0; i < 4; i++) {
        BuildCraftAPI.registerWorldProperty("ore@hardness=" + i, new WorldPropertyIsOre(i));
    }
    BuildCraftAPI.registerWorldProperty("harvestable", new WorldPropertyIsHarvestable());
    BuildCraftAPI.registerWorldProperty("farmland", new WorldPropertyIsFarmland());
    BuildCraftAPI.registerWorldProperty("shoveled", new WorldPropertyIsShoveled());
    BuildCraftAPI.registerWorldProperty("dirt", new WorldPropertyIsDirt());
    BuildCraftAPI.registerWorldProperty("fluidSource", new WorldPropertyIsFluidSource());
    BuildCraftAPI.registerWorldProperty("freepath", new WorldPropertyIsFreePath());
    // Landmarks are often caught incorrectly, making building them counter-productive.
    SchematicRegistry.INSTANCE.registerSchematicBlock(markerBlock, SchematicIgnore.class);
    SchematicRegistry.INSTANCE.registerSchematicBlock(pathMarkerBlock, SchematicIgnore.class);
    ColorUtils.initialize();
    actionControl = new IActionExternal[IControllable.Mode.values().length];
    for (IControllable.Mode mode : IControllable.Mode.values()) {
        if (mode != IControllable.Mode.Unknown && mode != IControllable.Mode.Mode) {
            actionControl[mode.ordinal()] = new ActionMachineControl(mode);
        }
    }
    MinecraftForge.EVENT_BUS.register(ListOreDictionaryCache.INSTANCE);
    for (String s : OreDictionary.getOreNames()) {
        ListOreDictionaryCache.INSTANCE.registerName(s);
    }
    ListRegistry.registerHandler(new ListMatchHandlerOreDictionary());
}
Also used : IPlantable(net.minecraftforge.common.IPlantable) IControllable(buildcraft.api.tiles.IControllable) CropHandlerReeds(buildcraft.core.crops.CropHandlerReeds) BlockLiquid(net.minecraft.block.BlockLiquid) BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) Block(net.minecraft.block.Block) CropHandlerPlantable(buildcraft.core.crops.CropHandlerPlantable)

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