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


Java IGrowable.canGrow方法代码示例

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


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

示例6: onItemUse

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);

	if (this.getMaterialName() == zivicioToolMaterial.toString() && PrimordialConfig.enableZivicioHoeSpeedup) {

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

		if (block != null && block instanceof IGrowable) {
			IGrowable igrowable = (IGrowable) block;
			if (igrowable.canGrow(worldIn, pos, iblockstate, worldIn.isRemote)) {
				if (!worldIn.isRemote) {
					if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, iblockstate)) {
						//igrowable.grow(worldIn, worldIn.rand, pos, iblockstate); // no client side update
						//iblockstate.getBlock().updateTick(worldIn, pos, iblockstate, worldIn.rand); // no client side update
						//LogHelper.info("update");
						worldIn.scheduleUpdate(pos, block, 1);
					}
				} else {
					//LogHelper.info("spawn" + igrowable.toString());
					spawnBonemealParticles(worldIn, pos, 5);
				}
			}
		}
	}
	return EnumActionResult.PASS;
}
 
开发者ID:KillBait,项目名称:PrimordialCrops,代码行数:29,代码来源:PrimordialHoe.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: handleHarvest

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
@Override
public boolean handleHarvest(IBetterChest chest, IBlockState state, World world, BlockPos pos) {
	IGrowable growable = (IGrowable) state.getBlock();
	if (!growable.canGrow(world, pos, state, chest.getWorldObj().isRemote)) {
		PlantHarvestHelper.breakBlockHandleDrop(world, pos, state, chest);
		return true;
	}
	return false;
}
 
开发者ID:Aroma1997,项目名称:BetterChests,代码行数:10,代码来源:CropHandler.java

示例10: onUpdate

import net.minecraft.block.IGrowable; //导入方法依赖的package包/类
@Override
public void onUpdate() {
	float forwardOffset = 4.5f;
	super.onUpdate();
	if (!world.isRemote) {
		// bucket Down
		// break blocks first
		int angle;
		if (this.getControllingPassenger() != null) {
			this.Attribute2 = Attribute2 + 5;
		}
		if (this.isPlayerPushingSprintButton) {
			for (int j = 0; j < 2; j++) {
				for (int i = -4; i < 5; i++) {
					if (i == 0) {
						angle = 0;
					} else {
						angle = 90;
					}
					BlockPos bp;
					bp = new BlockPos(posX + calcTwoOffsetX(forwardOffset, angle, i), posY + j, posZ + calcTwoOffsetZ(forwardOffset, angle, i));
					if (world.getBlockState(bp).getBlock() instanceof IGrowable) {

						IGrowable iGrowable = (IGrowable) world.getBlockState(bp).getBlock();

						if (!iGrowable.canGrow(world, bp, world.getBlockState(bp), world.isRemote)) {

							BlockUtil.BreakBlock(world, bp, this.getControllingPassenger());

						}
					}

				}
			}

			AxisAlignedBB bucketboundingBox = new AxisAlignedBB(calcTwoOffsetX(forwardOffset - 1, 90, -5) + posX - 1d, posY, calcTwoOffsetZ(forwardOffset - 1, 90, -5) + posZ - 1d, calcTwoOffsetX(forwardOffset, 90, 5) + posX + 1d, posY + 1, calcTwoOffsetZ(forwardOffset, 90, 5) + posZ + 1d);

			List list = this.world.getEntitiesWithinAABBExcludingEntity(this, bucketboundingBox);
			collidedEntitiesInList(list);
		}
		if (this.isPlayerPushingJumpButton) {
			// bucket up
			// Drop blocks
			// TODO needs something to pace it a bit more now it drops
			// everything way to fast.
			for (int i = 0; i < SIZE; i++) {
				ItemStack item = this.inventory.getStackInSlot(i);

				if (item != null && item.getCount() > 0) {
					;

					EntityItem entityItem = new EntityItem(world, posX + calcOffsetX(forwardOffset), posY + 4, posZ + calcOffsetZ(forwardOffset), item);

					if (item.hasTagCompound()) {
						entityItem.getItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
					}

					float factor = 0.05F;
					// entityItem.motionX = rand.nextGaussian() * factor;
					entityItem.motionY = 0;
					// entityItem.motionZ = rand.nextGaussian() * factor;
					entityItem.forceSpawn = true;
					world.spawnEntity(entityItem);
					// item.stackSize = 0;
					inventory.extractItem(i, inventory.getStackInSlot(i).getCount(), false);
					// this.inventory.insertItem(i, ItemStack.EMPTY, false);
				}
			}
		}
	}

}
 
开发者ID:TechStack,项目名称:TechStack-s-HeavyMachineryMod,代码行数:73,代码来源:EntityCombine.java


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