Search in sources :

Example 41 with BlockLiquid

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

the class TileQuarry method createColumnVisitList.

/**
 * Make the column visit list: called once per layer
 */
private void createColumnVisitList() {
    visitList.clear();
    boolean[][] blockedColumns = new boolean[builder.blueprint.size.getX() - 2][builder.blueprint.size.getZ() - 2];
    for (int searchY = pos.getY() + 3; searchY >= 1; --searchY) {
        int startX, endX, incX;
        if (searchY % 2 == 0) {
            startX = 0;
            endX = builder.blueprint.size.getX() - 2;
            incX = 1;
        } else {
            startX = builder.blueprint.size.getX() - 3;
            endX = -1;
            incX = -1;
        }
        for (int searchX = startX; searchX != endX; searchX += incX) {
            int startZ, endZ, incZ;
            if (searchX % 2 == searchY % 2) {
                startZ = 0;
                endZ = builder.blueprint.size.getZ() - 2;
                incZ = 1;
            } else {
                startZ = builder.blueprint.size.getZ() - 3;
                endZ = -1;
                incZ = -1;
            }
            for (int searchZ = startZ; searchZ != endZ; searchZ += incZ) {
                if (!blockedColumns[searchX][searchZ]) {
                    int bx = box.min().getX() + searchX + 1;
                    int by = searchY;
                    int bz = box.min().getZ() + searchZ + 1;
                    BlockPos pos = new BlockPos(bx, by, bz);
                    IBlockState state = worldObj.getBlockState(pos);
                    Block block = state.getBlock();
                    if (!BlockUtil.canChangeBlock(state, worldObj, pos)) {
                        blockedColumns[searchX][searchZ] = true;
                    } else if (!BuildCraftAPI.isSoftBlock(worldObj, pos) && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock)) {
                        visitList.add(new int[] { bx, by, bz });
                    }
                    // recompute prior to this
                    if (visitList.size() > builder.blueprint.size.getZ() * builder.blueprint.size.getX() * 2) {
                        return;
                    }
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Blueprint(buildcraft.core.blueprints.Blueprint) BptBuilderBlueprint(buildcraft.core.blueprints.BptBuilderBlueprint)

Example 42 with BlockLiquid

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

the class TileQuarry method isQuarriableBlock.

private boolean isQuarriableBlock(BlockPos pos) {
    IBlockState state = worldObj.getBlockState(pos);
    Block block = state.getBlock();
    return BlockUtil.canChangeBlock(state, worldObj, pos) && !BuildCraftAPI.isSoftBlock(worldObj, pos) && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock)

Example 43 with BlockLiquid

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

the class PipeItemsStripes method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    if (container.getWorld().isRemote) {
        return;
    }
    if (battery.getEnergyStored() >= 10) {
        EnumPipePart o = actionDir;
        if (o == EnumPipePart.CENTER) {
            o = EnumPipePart.fromFacing(getOpenOrientation());
        }
        if (o != EnumPipePart.CENTER) {
            Vec3d vec = Utils.convert(container.getPos()).add(Utils.convert(o.face));
            BlockPos veci = Utils.convertFloor(vec);
            if (!BlockUtil.isUnbreakableBlock(getWorld(), Utils.convertFloor(vec))) {
                IBlockState state = getWorld().getBlockState(Utils.convertFloor(vec));
                Block block = state.getBlock();
                if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
                    return;
                }
                ItemStack stack = new ItemStack(block, 1, block.getMetaFromState(state));
                EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(), veci).get();
                if (battery.useEnergy(10, 10, false) != 10) {
                    return;
                }
                for (IStripesHandler handler : PipeManager.stripesHandlers) {
                    if (handler.getType() == StripesHandlerType.BLOCK_BREAK && handler.shouldHandle(stack)) {
                        if (handler.handle(getWorld(), veci, o.face, stack, player, this)) {
                            return;
                        }
                    }
                }
                List<ItemStack> stacks = block.getDrops(getWorld(), veci, state, 0);
                if (stacks != null) {
                    for (ItemStack s : stacks) {
                        if (s != null) {
                            sendItem(s, o.opposite().face);
                        }
                    }
                }
                getWorld().setBlockToAir(veci);
            }
        }
        return;
    }
}
Also used : IStripesHandler(buildcraft.api.transport.IStripesHandler) IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) EnumPipePart(buildcraft.api.core.EnumPipePart) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) WorldServer(net.minecraft.world.WorldServer) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d)

Example 44 with BlockLiquid

use of net.minecraft.block.BlockLiquid in project TUMAT by canitzp.

the class RenderOverlay method renderMiss.

private static TooltipComponent renderMiss(WorldClient world, EntityPlayerSP player, RayTraceResult trace, boolean shouldCalculate) {
    TooltipComponent component = new TooltipComponent();
    if (!world.isAirBlock(trace.getBlockPos())) {
        IBlockState state = world.getBlockState(trace.getBlockPos());
        if (state.getBlock() instanceof BlockLiquid || state.getBlock() instanceof BlockFluidBase) {
            component.setName(new TextComponent(state.getBlock().getLocalizedName()));
            component.setModName(new TextComponent(InfoUtil.getModName(state.getBlock())));
            IconRenderer renderer;
            if (bucketCache.containsKey(state.getBlock().getRegistryName())) {
                component.setIconRenderer(bucketCache.get(state.getBlock().getRegistryName()));
            } else {
                Fluid fluid = FluidRegistry.lookupFluidForBlock(state.getBlock());
                if (fluid != null) {
                    renderer = new IconRenderer(FluidUtil.getFilledBucket(new FluidStack(fluid, 1000)));
                    bucketCache.put(state.getBlock().getRegistryName(), renderer);
                    component.setIconRenderer(renderer);
                }
            }
        }
        for (IWorldRenderer renderer : TUMATApi.getRegisteredComponents()) {
            if (renderer.shouldBeActive()) {
                renderer.renderMiss(world, player, trace, component, shouldCalculate);
            }
        }
    }
    return component;
}
Also used : TextComponent(de.canitzp.tumat.api.components.TextComponent) IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) TooltipComponent(de.canitzp.tumat.api.TooltipComponent) IWorldRenderer(de.canitzp.tumat.api.IWorldRenderer)

Example 45 with BlockLiquid

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

the class ParticleColoredDripParticle method onUpdate.

/**
 * Called to update the entity's position/logic.
 */
@Override
public void onUpdate() {
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= this.particleGravity;
    if (this.bobTimer-- > 0) {
        this.motionX *= 0.02D;
        this.motionY *= 0.02D;
        this.motionZ *= 0.02D;
        this.setParticleTextureIndex(113);
    } else {
        this.setParticleTextureIndex(112);
    }
    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) {
        this.setParticleTextureIndex(114);
        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 = 0.0D;
        if (iblockstate.getBlock() instanceof BlockLiquid) {
            d0 = BlockLiquid.getLiquidHeightPercent(iblockstate.getValue(BlockLiquid.LEVEL));
        }
        double d1 = MathHelper.floor(this.posY) + 1 - 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)

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