本文整理汇总了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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
}