當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。