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