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


Java IGrowable.grow方法代码示例

本文整理汇总了Java中net.minecraft.block.IGrowable.grow方法的典型用法代码示例。如果您正苦于以下问题:Java IGrowable.grow方法的具体用法?Java IGrowable.grow怎么用?Java IGrowable.grow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.block.IGrowable的用法示例。


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

示例1: safeImpact

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, box, box);
	BlockPos posF = pos.add(-box, -box, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
	for (BlockPos spot : spots) {
		IBlockState state = world.getBlockState(spot);
		boolean place = amplifier > 2 || world.rand.nextBoolean();
		if (place && state.getBlock() instanceof IGrowable) {
			IGrowable crop = (IGrowable) state.getBlock();
			if (crop.canGrow(world, spot, state, false))
				crop.grow(world, world.rand, spot, state);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:19,代码来源:FertilizeBrew.java

示例2: applyBonemeal

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target)
{
    IBlockState iblockstate = worldIn.getBlockState(target);

    if (iblockstate.getBlock() instanceof IGrowable)
    {
        IGrowable igrowable = (IGrowable)iblockstate.getBlock();

        if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
        {
            if (!worldIn.isRemote)
            {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
                {
                    igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
                }

                --stack.stackSize;
            }

            return true;
        }
    }

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

示例3: applyBonemeal

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target)
{
    IBlockState iblockstate = worldIn.getBlockState(target);

    if (iblockstate.getBlock() instanceof IGrowable)
    {
        IGrowable igrowable = (IGrowable)iblockstate.getBlock();

        if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
        {
            if (!worldIn.isRemote)
            {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
                {
                    igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
                }

                stack.func_190918_g(1);
            }

            return true;
        }
    }

    return false;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:ItemDye.java

示例4: applyBonemeal

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, @javax.annotation.Nullable EnumHand hand) {
    if (!(state.getBlock() instanceof BlockGrass) || player.isSneaking()) {

        int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, state, stack, hand);
        if (hook != 0) return hook > 0;

        IGrowable igrowable = (IGrowable) state.getBlock();
        if (igrowable.canGrow(worldIn, pos, state, worldIn.isRemote)) {
            if (!worldIn.isRemote) {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, state)) {
                    igrowable.grow(worldIn, worldIn.rand, pos, state);
                }
                stack.damageItem(1, player);
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:NightKosh,项目名称:Gravestone-mod-Extended,代码行数:20,代码来源:ItemBoneHoe.java

示例5: applyUnko

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
private boolean applyUnko(ItemStack stack, World worldIn, BlockPos pos, EntityPlayer player) {
       IBlockState iblockstate = worldIn.getBlockState(pos);
       Block block = iblockstate.getBlock();

       if (block instanceof IGrowable)
       {
           IGrowable igrowable = (IGrowable)block;

           if (igrowable.isStillGrowing(worldIn, pos, iblockstate, worldIn.isRemote))
           {
               if (!worldIn.isRemote)
               {
                   if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, iblockstate))
                   {
                       igrowable.grow(worldIn, worldIn.rand, pos, iblockstate);
                   }

                   --stack.stackSize;
               }

               return true;
           }
       }

       return false;
}
 
开发者ID:shu3,项目名称:FatCatMOD,代码行数:27,代码来源:ItemFatCatUnko.java

示例6: applyBonemeal

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player)
{
    IBlockState iblockstate = worldIn.getBlockState(target);

    int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, target, iblockstate, stack);
    if (hook != 0) return hook > 0;

    if (iblockstate.getBlock() instanceof IGrowable)
    {
        IGrowable igrowable = (IGrowable)iblockstate.getBlock();

        if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
        {
            if (!worldIn.isRemote)
            {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
                {
                    igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
                }

                --stack.stackSize;
            }

            return true;
        }
    }

    return false;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:30,代码来源:ItemDye.java

示例7: applyBonemeal

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player)
{
	IBlockState iblockstate = worldIn.getBlockState(target);

	int hook = net.minecraftforge.event.ForgeEventFactory
		           .onApplyBonemeal(player, worldIn, target, iblockstate, stack);
	if (hook != 0)
		return hook > 0;

	if (iblockstate.getBlock() instanceof IGrowable)
	{
		IGrowable igrowable = (IGrowable) iblockstate.getBlock();

		if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
		{
			if (!worldIn.isRemote)
			{
				if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
				{
					igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
				}

				stack.damageItem(10, player);
			}

			return true;
		}
	}

	return false;
}
 
开发者ID:MinestrapTeam,项目名称:Minestrappolation-4,代码行数:32,代码来源:ItemMHoe.java

示例8: applyBonemeal

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player)
{
	IBlockState iblockstate = worldIn.getBlockState(target);

	int hook = net.minecraftforge.event.ForgeEventFactory
		           .onApplyBonemeal(player, worldIn, target, iblockstate, stack);
	if (hook != 0)
		return hook > 0;

	if (iblockstate.getBlock() instanceof IGrowable)
	{
		IGrowable igrowable = (IGrowable) iblockstate.getBlock();

		if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
		{
			if (!worldIn.isRemote)
			{
				if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
				{
					igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
				}

				--stack.stackSize;
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:MinestrapTeam,项目名称:Minestrappolation-4,代码行数:30,代码来源:ItemGuano.java

示例9: debugActionBlockClicked

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
@Override
public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return;
    }

    // Start with the position of the block that was clicked on. '7' is gray. Btw, the chat font is not fixed width. :(
    StringBuilder outputRaw = new StringBuilder(String.format("\u00A77%1$4d,%2$4d,%3$4d\u00A7r ", pos.getX(), pos.getY(), pos.getZ()));

    // Check if the clicked on block has the IGrowable interface.
    final IGrowable crop = WorldHelper.getBlock(world, pos, IGrowable.class).orElse(null);
    if (crop == null) {
        // If it does not, add a nicely formatted report, then skip onward.
        outputRaw.append(chatNotIG);
    } else {
        // Otherwise run the tests and record the results.
        IBlockState state = world.getBlockState(pos);
        outputRaw.append(crop.canGrow(world, pos, state, false)             ? chatTrue : chatFalse); // canGrow
        outputRaw.append(crop.canUseBonemeal(world, world.rand, pos, state) ? chatTrue : chatFalse); // canUseBonemeal
        crop.grow(world, world.rand, pos, state);                                                    // grow

        // It's also helpful to also make clear what block was being tested.
        outputRaw.append("\u00A73"); // '3' is dark aqua.
        outputRaw.append(crop.toString().replaceFirst("Block",""));
        outputRaw.append("\u00A7r");
    }

    // Ellipsis are added as a clue that there's more text.
    outputRaw.append(" \u00A78[...]\u00A7r"); // '8' is dark gray.

    // Create a hover box with explanatory information.
    TextComponentString hoverComponent  = new TextComponentString(chatInfo);
    HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent);

    // Turn the output String into a chat message.
    TextComponentString outputComponent = new TextComponentString(outputRaw.toString());

    // Add the hover box to the chat message.
    outputComponent.getStyle().setHoverEvent(hoverEvent);

    // Now send the completed chat message.
    player.sendMessage(outputComponent);
}
 
开发者ID:AgriCraft,项目名称:AgriCraft,代码行数:44,代码来源:DebugModeIGrowable.java


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