本文整理汇总了Java中net.minecraft.block.BlockNetherWart类的典型用法代码示例。如果您正苦于以下问题:Java BlockNetherWart类的具体用法?Java BlockNetherWart怎么用?Java BlockNetherWart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockNetherWart类属于net.minecraft.block包,在下文中一共展示了BlockNetherWart类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemUse
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (stack.getItemDamage() == EnumItems.TIMEMEAL.ordinal() && player.canPlayerEdit(pos, facing, stack)) {
Block crops = world.getBlockState(pos).getBlock();
if (crops != null && crops instanceof BlockCrops) {
if (crops != UCBlocks.cropMerlinia)
world.setBlockState(pos, ((BlockCrops)crops).withAge(0), 2);
else if (crops == UCBlocks.cropMerlinia)
((Merlinia)crops).merliniaGrowth(world, pos, world.rand.nextInt(1) + 1);
else if (crops instanceof BlockNetherWart)
((BlockNetherWart)crops).updateTick(world, pos, world.getBlockState(pos), world.rand);
if (!player.capabilities.isCreativeMode && !player.worldObj.isRemote)
stack.stackSize--;
UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() - 0.5D, pos.getY(), pos.getZ() - 0.5D, 6));
return EnumActionResult.SUCCESS;
}
}
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
示例2: onItemUse
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
ItemStack stack = player.getHeldItem(hand);
if(ItemStackTools.isValid(stack) && stack.getMetadata() == BoneType.BONEMEAL.getMetadata()){
IBlockState state = world.getBlockState(pos);
if(state.getBlock() == Blocks.NETHER_WART){
int i = state.getValue(BlockNetherWart.AGE).intValue();
if (i < 3 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(world, pos, state, true))
{
state = state.withProperty(BlockNetherWart.AGE, Integer.valueOf(i + 1));
world.setBlockState(pos, state, 2);
net.minecraftforge.common.ForgeHooks.onCropsGrowPost(world, pos, state, world.getBlockState(pos));
if(!player.capabilities.isCreativeMode){
player.setHeldItem(hand, ItemUtil.consumeItem(stack));
}
return EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.PASS;
}
示例3: isGrown
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
@Override
public boolean isGrown(Point3I plantPoint, Block plantBlock, IBlockState state, World worldObj) {
int metadata = plantBlock.getMetaFromState(state);
//check pumpkins and mellons first
if (plantBlock instanceof BlockStem) {
for (EnumFacing facing : EnumFacing.Plane.HORIZONTAL) {
Block testBlock = worldObj.getBlockState(plantPoint.toPosition().offset(facing)).getBlock();
if ( (testBlock == Blocks.MELON_BLOCK) || (testBlock == Blocks.PUMPKIN) )
return true;
}
} else if (plantBlock instanceof IGrowable) {
return !((IGrowable)plantBlock).canGrow(worldObj, plantPoint.toPosition(), state, true);
} else if (plantBlock instanceof BlockNetherWart) { //nether wart
return (metadata >= 3);
} else if (plantBlock == Blocks.REEDS) { // sugar cane
return (worldObj.getBlockState(plantPoint.toPosition().up()).getBlock() == Blocks.REEDS);
} else if (plantBlock == Blocks.CACTUS) { //cactus
return (worldObj.getBlockState(plantPoint.toPosition().up()).getBlock() == Blocks.CACTUS);
}
return false;
}
示例4: isGrownCrop
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
public static boolean isGrownCrop(World world, BlockPos pos)
{
if (world.isAirBlock(pos)) {
return false;
}
boolean found = false;
IBlockState state = world.getBlockState(pos);
Block bi = state.getBlock();
for (int a = 0; a < 16; a++) {
if ((getCrops(CropType.NORMAL).contains(bi.getUnlocalizedName() + a)) || (getCrops(CropType.STACKED).contains(bi.getUnlocalizedName() + a)) || (getCrops(CropType.CLICKABLE).contains(bi.getUnlocalizedName() + a)))
{
found = true;
break;
}
}
Block biB = world.getBlockState(pos.down()).getBlock();
int md = bi.getMetaFromState(state);
if ((((bi instanceof IGrowable)) && (!((IGrowable)bi).canGrow(world, pos, state, world.isRemote)) && (!(bi instanceof BlockStem)))
|| (((bi instanceof BlockCrops)) && ((BlockCrops)bi).isMaxAge(state) && (!found))
|| ((bi == Blocks.NETHER_WART) && (state.getValue(BlockNetherWart.AGE).intValue() >= 3))
|| ((bi == Blocks.COCOA) && (state.getValue(BlockCocoa.AGE).intValue() >= 2))
|| (getCrops(CropType.NORMAL).contains(bi.getUnlocalizedName() + md)) || (getCrops(CropType.STACKED).contains(bi.getUnlocalizedName() + md)) || ((getCrops(CropType.CLICKABLE).contains(bi.getUnlocalizedName() + md)) && (biB == bi))) {
return true;
}
return false;
}
示例5: isPlant
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
@Override
public boolean isPlant(Block plantBlock, IBlockState state) {
if (plantBlock instanceof IGrowable) return true;
if (plantBlock instanceof BlockNetherWart) return true;
if (plantBlock == Blocks.REEDS) return true;
if (plantBlock == Blocks.CACTUS) return true;
return false;
}
示例6: handleHarvest
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
@Override
public boolean handleHarvest(IBetterChest chest, IBlockState state, World world, BlockPos pos) {
if (state.getValue(BlockNetherWart.AGE) == 3) {
PlantHarvestHelper.breakBlockHandleDrop(world, pos, state, chest);
return true;
}
return false;
}
示例7: canBeHarvested
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
@Override
public boolean canBeHarvested(World world, BlockPos pos, IBlockState blockState) {
return blockState.getBlock() instanceof BlockNetherWart && blockState.getValue(BlockNetherWart.AGE) >= 3;
}
示例8: canBeHarvested
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
@Override
public boolean canBeHarvested() {
return this.state.getValue(BlockNetherWart.AGE) == 3;
}
示例9: canHandleHarvest
import net.minecraft.block.BlockNetherWart; //导入依赖的package包/类
@Override
public boolean canHandleHarvest(IBlockState state, World world, BlockPos pos) {
return state.getPropertyKeys().contains(BlockNetherWart.AGE);
}