当前位置: 首页>>代码示例>>Java>>正文


Java BlockLiquid类代码示例

本文整理汇总了Java中net.minecraft.block.BlockLiquid的典型用法代码示例。如果您正苦于以下问题:Java BlockLiquid类的具体用法?Java BlockLiquid怎么用?Java BlockLiquid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BlockLiquid类属于net.minecraft.block包,在下文中一共展示了BlockLiquid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTopBlock

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
public static BlockPos getTopBlock(World world, BlockPos pos)
{
	Chunk chunk = world.getChunkFromBlockCoords(pos);
       BlockPos blockpos;
       BlockPos blockpos1;

       for (blockpos = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1)
       {
           blockpos1 = blockpos.down();
           IBlockState state = chunk.getBlockState(blockpos1);
           if ((state.getMaterial().blocksMovement() && !state.getBlock().isLeaves(state, world, blockpos1) && !state.getBlock().isFoliage(world, blockpos1) && state.getBlock() != Blocks.LOG
           		&& state.getBlock() != Blocks.LOG2) || state.getBlock() instanceof BlockLiquid)
           	break;
       }
       return blockpos;		
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HarshenUtils.java

示例2: delayForHardBlocks

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
@Override
public void delayForHardBlocks(BlockPos pos, Consumer<BlockPos> nextJob) {
    World world = entity.getEntityWorld();
    if (world.isAirBlock(pos)) {
        return;
    }
    IBlockState state = world.getBlockState(pos);
    if (!allowedToHarvest(state, world, pos, GeneralTools.getHarvester())) {
        return;
    }
    Block block = state.getBlock();
    if (block instanceof BlockLiquid) {
        nextJob.accept(pos);
    } else {
        float hardness = state.getBlockHardness(world, pos);
        if (hardness < Config.delayAtHardness) {
            nextJob.accept(pos);
        } else {
            delay((int) (hardness * Config.delayFactor), () -> nextJob.accept(pos));
        }
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:23,代码来源:WorkerHelper.java

示例3: onAddCollisionBox

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
@SubscribeEvent
public void onAddCollisionBox(AddCollisionBoxToListEvent event) {
    if (getLocalPlayer() != null
            && (event.getBlock() instanceof BlockLiquid)
            && (EntityUtils.isDrivenByPlayer(event.getEntity()) || EntityUtils.isLocalPlayer(event.getEntity()))
            && !(event.getEntity() instanceof EntityBoat)
            && !getLocalPlayer().isSneaking()
            && getLocalPlayer().fallDistance < 3
            && !isInWater(getLocalPlayer())
            && (isAboveWater(getLocalPlayer(), false) || isAboveWater(getRidingEntity(), false))
            && isAboveBlock(getLocalPlayer(), event.getPos())) {
        AxisAlignedBB axisalignedbb = WATER_WALK_AA.offset(event.getPos());
        if (event.getEntityBox().intersects(axisalignedbb)) event.getCollidingBoxes().add(axisalignedbb);
        // cancel event, which will stop it from calling the original code
        event.setCanceled(true);
    }

}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:19,代码来源:Jesus.java

示例4: isInsideOfMaterial

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
/**
 * Checks if the current block the entity is within of the specified material type
 */
public boolean isInsideOfMaterial(Material materialIn)
{
    double d0 = this.posY + (double)this.getEyeHeight();
    BlockPos blockpos = new BlockPos(this.posX, d0, this.posZ);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Block block = iblockstate.getBlock();

    if (block.getMaterial() == materialIn)
    {
        float f = BlockLiquid.getLiquidHeightPercent(iblockstate.getBlock().getMetaFromState(iblockstate)) - 0.11111111F;
        float f1 = (float)(blockpos.getY() + 1) - f;
        boolean flag = d0 < (double)f1;
        return !flag && this instanceof EntityPlayer ? false : flag;
    }
    else
    {
        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:Entity.java

示例5: getBlockAtEntityViewpoint

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
public static Block getBlockAtEntityViewpoint(World worldIn, Entity p_180786_1_, float p_180786_2_)
{
    Vec3 vec3 = projectViewFromEntity(p_180786_1_, (double)p_180786_2_);
    BlockPos blockpos = new BlockPos(vec3);
    IBlockState iblockstate = worldIn.getBlockState(blockpos);
    Block block = iblockstate.getBlock();

    if (block.getMaterial().isLiquid())
    {
        float f = 0.0F;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            f = BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()) - 0.11111111F;
        }

        float f1 = (float)(blockpos.getY() + 1) - f;

        if (vec3.yCoord >= (double)f1)
        {
            block = worldIn.getBlockState(blockpos.up()).getBlock();
        }
    }

    return block;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:ActiveRenderInfo.java

示例6: getBlockStateAtEntityViewpoint

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
public static IBlockState getBlockStateAtEntityViewpoint(World worldIn, Entity entityIn, float p_186703_2_)
{
    Vec3d vec3d = projectViewFromEntity(entityIn, (double)p_186703_2_);
    BlockPos blockpos = new BlockPos(vec3d);
    IBlockState iblockstate = worldIn.getBlockState(blockpos);

    if (iblockstate.getMaterial().isLiquid())
    {
        float f = 0.0F;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            f = BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()) - 0.11111111F;
        }

        float f1 = (float)(blockpos.getY() + 1) - f;

        if (vec3d.yCoord >= (double)f1)
        {
            iblockstate = worldIn.getBlockState(blockpos.up());
        }
    }

    return iblockstate;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:ActiveRenderInfo.java

示例7: getTarget

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
public BlockData getTarget(BlockPos pos) {
    EnumFacing[] orderedFacingValues = new EnumFacing[] {
            EnumFacing.UP,
            EnumFacing.EAST,
            EnumFacing.NORTH,
            EnumFacing.WEST,
            EnumFacing.SOUTH,
            EnumFacing.DOWN
    };

    for (EnumFacing facing : orderedFacingValues) {
        BlockPos alteredPos = pos.add(facing.getOpposite().getDirectionVec());

        if (!mc.theWorld.getBlockState(alteredPos).getBlock().isReplaceable(mc.theWorld, alteredPos) && !(mc.theWorld.getBlockState(alteredPos).getBlock() instanceof BlockLiquid) && !(mc.theWorld.getBlockState(alteredPos).getBlock() instanceof BlockAir)) {
            return new BlockData(alteredPos, facing);
        }
    }

    return null;
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:21,代码来源:Scaffold.java

示例8: isTouchingLiquid

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
public static boolean isTouchingLiquid() {
	Minecraft mc = Minecraft.getMinecraft();
	boolean inLiquid = false;
	int y = (int) mc.player.boundingBox.minY;
	for (int x = floor_double(mc.player.boundingBox.minX); x < floor_double(mc.player.boundingBox.maxX) + 1; x++) {
		for (int z = floor_double(mc.player.boundingBox.minZ); z < floor_double(mc.player.boundingBox.maxZ)
				+ 1; z++) {
			net.minecraft.block.Block block = mc.world.getBlockState(new BlockPos(x, y, z)).getBlock();
			if ((block != null) && (!(block instanceof BlockAir))) {
				if (!(block instanceof BlockLiquid)) {
					return false;
				}
				inLiquid = true;
			}
		}
	}
	return inLiquid;
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:19,代码来源:IEntityPlayer.java

示例9: onAddCollisionBox

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
@Override
public AxisAlignedBB onAddCollisionBox(Block block, BlockPos pos, AxisAlignedBB box) {
	if (!isEnabled() || Wrapper.getPlayer() == null || !(block instanceof BlockLiquid)) {
		return box;
	}

	if (isInWater(Wrapper.getPlayer()) || Wrapper.getPlayer().isSneaking() || Wrapper.getPlayer().fallDistance > 3) {
		return box;
	}
	
	if (Wrapper.getPlayer().ridingEntity != null) {
		return box;
	}

	return new AxisAlignedBB(0, 0, 0, 1, 0.99, 1);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:Jesus.java

示例10: isInsideOfMaterial

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
/**
 * Checks if the current block the entity is within of the specified material type
 */
public boolean isInsideOfMaterial(Material materialIn)
{
    if (this.getRidingEntity() instanceof EntityBoat)
    {
        return false;
    }
    else
    {
        double d0 = this.posY + (double)this.getEyeHeight();
        BlockPos blockpos = new BlockPos(this.posX, d0, this.posZ);
        IBlockState iblockstate = this.world.getBlockState(blockpos);

        if (iblockstate.getMaterial() == materialIn)
        {
            float f = BlockLiquid.getLiquidHeightPercent(iblockstate.getBlock().getMetaFromState(iblockstate)) - 0.11111111F;
            float f1 = (float)(blockpos.getY() + 1) - f;
            boolean flag = d0 < (double)f1;
            return !flag && this instanceof EntityPlayer ? false : flag;
        }
        else
        {
            return false;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:29,代码来源:Entity.java

示例11: getFluidHandler

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
/**
 * Helper method to get an IFluidHandler for at a block position.
 *
 * Returns null if there is no valid fluid handler.
 */
@Nullable
public static IFluidHandler getFluidHandler(World world, BlockPos blockPos, @Nullable EnumFacing side)
{
    IBlockState state = world.getBlockState(blockPos);
    Block block = state.getBlock();

    if (block.hasTileEntity(state))
    {
        TileEntity tileEntity = world.getTileEntity(blockPos);
        if (tileEntity != null && tileEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
        {
            return tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
        }
    }
    else if (block instanceof IFluidBlock)
    {
        return new FluidBlockWrapper((IFluidBlock) block, world, blockPos);
    }
    else if (block instanceof BlockLiquid)
    {
        return new BlockLiquidWrapper((BlockLiquid) block, world, blockPos);
    }

    return null;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:31,代码来源:FluidUtil.java

示例12: tryPickUpFluid

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
/**
 * Attempts to pick up a fluid in the world and put it in an empty container item.
 *
 * @param emptyContainer The empty container to fill. Will not be modified.
 * @param playerIn       The player filling the container. Optional.
 * @param worldIn        The world the fluid is in.
 * @param pos            The position of the fluid in the world.
 * @param side           The side of the fluid that is being drained.
 * @return a filled container if it was successful. returns null on failure.
 */
@Nullable
public static ItemStack tryPickUpFluid(ItemStack emptyContainer, @Nullable EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side)
{
    if (emptyContainer == null || worldIn == null || pos == null) {
        return null;
    }

    IBlockState state = worldIn.getBlockState(pos);
    Block block = state.getBlock();

    if (block instanceof IFluidBlock || block instanceof BlockLiquid)
    {
        IFluidHandler targetFluidHandler = FluidUtil.getFluidHandler(worldIn, pos, side);
        if (targetFluidHandler != null)
        {
            return FluidUtil.tryFillContainer(emptyContainer, targetFluidHandler, Integer.MAX_VALUE, playerIn, true);
        }
    }
    return null;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:31,代码来源:FluidUtil.java

示例13: getFluidHeightForRender

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
public float getFluidHeightForRender(IBlockAccess world, BlockPos pos)
{
    IBlockState here = world.getBlockState(pos);
    IBlockState up = world.getBlockState(pos.down(densityDir));
    if (here.getBlock() == this)
    {
        if (up.getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock)
        {
            return 1;
        }

        if (getMetaFromState(here) == getMaxRenderHeightMeta())
        {
            return 0.875F;
        }
    }
    if (here.getBlock() instanceof BlockLiquid)
    {
        return Math.min(1 - BlockLiquid.getLiquidHeightPercent(here.getValue(BlockLiquid.LEVEL)), 14f / 16);
    }
    return !here.getMaterial().isSolid() && up.getBlock() == this ? 1 : this.getQuantaPercentage(world, pos) * 0.875F;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:BlockFluidBase.java

示例14: drain

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
    if (resource == null || resource.amount < Fluid.BUCKET_VOLUME)
    {
        return null;
    }

    IBlockState blockState = world.getBlockState(blockPos);
    if (blockState.getBlock() == blockLiquid && blockState.getValue(BlockLiquid.LEVEL) == 0)
    {
        FluidStack containedStack = getStack(blockState);
        if (containedStack != null && resource.containsFluid(containedStack))
        {
            if (doDrain)
            {
                world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), 11);
            }
            return containedStack;
        }

    }
    return null;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:BlockLiquidWrapper.java

示例15: getStack

import net.minecraft.block.BlockLiquid; //导入依赖的package包/类
@Nullable
private FluidStack getStack(IBlockState blockState)
{
    Material material = blockState.getMaterial();
    if (material == Material.WATER && blockState.getValue(BlockLiquid.LEVEL) == 0)
    {
        return new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME);
    }
    else if (material == Material.LAVA && blockState.getValue(BlockLiquid.LEVEL) == 0)
    {
        return new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME);
    }
    else
    {
        return null;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:BlockLiquidWrapper.java


注:本文中的net.minecraft.block.BlockLiquid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。