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


Java IPlantable.getPlant方法代码示例

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


在下文中一共展示了IPlantable.getPlant方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) {
    IBlockState plant = plantable.getPlant(world, pos.offset(direction));
    net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

    switch (plantType) {
        case Crop:
        case Plains:
            return true;
        case Desert:
        case Nether:
        case Cave:
        case Water:
        case Beach:
        default:
            return false;
    }
}
 
开发者ID:McJty,项目名称:AquaMunda,代码行数:19,代码来源:CustomFarmLand.java

示例2: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
	IBlockState plant = plantable.getPlant(world, pos.offset(direction));
	net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

	if(plantType == EnumPlantType.Crop)
		return true;

	if(plantType == EnumPlantType.Plains)
		return true;

	if(plantable == TFCBlocks.Sapling)
		return true;

	return false;
}
 
开发者ID:Deadrik,项目名称:TFC2,代码行数:18,代码来源:BlockFarmland.java

示例3: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
	IBlockState plant = plantable.getPlant(world, pos.offset(direction));
	EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

	VegType veg = (VegType)state.getValue(META_PROPERTY);
	if(plant.getBlock() == this)
	{
		if(veg == VegType.DoubleGrassBottom && plant.getValue(META_PROPERTY) == VegType.DoubleGrassTop)
			return true;
		if(veg == VegType.DoubleGrassBottomLush && plant.getValue(META_PROPERTY) == VegType.DoubleGrassTopLush)
			return true;
	}
	return false;
}
 
开发者ID:Deadrik,项目名称:TFC2,代码行数:17,代码来源:BlockVegetation.java

示例4: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
	IBlockState plant = plantable.getPlant(world, pos.offset(direction));
	net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

	if(plant.getBlock() == Blocks.SAPLING)
		return false;//This may break some cross mod compatability but for now its needed to prevent vanilla and some pam trees from generating

	if(plantType == EnumPlantType.Plains)
		return true;

	if(plant.getBlock() == TFCBlocks.VegDesert)
		return true;
	return false;
}
 
开发者ID:Deadrik,项目名称:TFC2,代码行数:17,代码来源:BlockGrass.java

示例5: tryPlantSeed

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
public static ItemStack tryPlantSeed(World world, BlockPos posForPlant, ItemStack stack) {
  BlockPos posSoil = posForPlant.down();
  if (stack != null && stack.getItem() instanceof IPlantable) {
    IPlantable seed = (IPlantable) stack.getItem();
    IBlockState crop = seed.getPlant(world, posForPlant);
    if (crop != null) {
      // mimic exactly what onItemUse.onItemUse is doing
      IBlockState state = world.getBlockState(posSoil);
      boolean canSustainPlant = state.getBlock().canSustainPlant(state, world, posSoil, EnumFacing.UP, seed);
      if (canSustainPlant) {
        if (world.isAirBlock(posForPlant)) {
          world.setBlockState(posForPlant, crop);
          stack.shrink(1);
          return stack;
        }
        else {
          return stack;// ie, dont do super
        }
      }
    }
  }
  return null;
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:24,代码来源:UtilPlantable.java

示例6: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable)
{
    Block block = plantable.getPlant(world, x, y + 1, z);
    int blockMeta = plantable.getPlantMetadata(world, x, y + 1, z);
    // EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z);



    if (plantable instanceof SubBlockBush)
    {
        return ((SubBlockBush) plantable).canPlaceOn(block, blockMeta, 0);
    }

    return super.canSustainPlant(world, x, y, z, direction, plantable);
}
 
开发者ID:katzenpapst,项目名称:amunra,代码行数:17,代码来源:BlockBasicMeta.java

示例7: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable)
{
	Block plant = plantable.getPlant(world, x, y + 1, z);
	EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z);

	switch (plantType)
	{
	case Desert:
		return false;
	case Nether:
		return false;
	case Crop:
		return true;
	case Cave:
		return false;
	case Plains:
		return false;
	case Water:
		return false;
	case Beach:
		return false;
	}

	return false;
}
 
开发者ID:MikeLydeamore,项目名称:IlluminatedBows,代码行数:27,代码来源:BlockIlluminatedFarmland.java

示例8: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable)
   {
   Block plant = plantable.getPlant(world, x, y + 1, z);
   EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z);
   switch (plantType)
   {
case Beach:
	break;
case Cave:
	break;
case Crop:
	break;
case Desert:
	break;
case Nether:
	break;
case Plains:
	break;
case Water:
	break;
default:
	break;
   }
   return false;
   }
 
开发者ID:RamiLego4Game,项目名称:GalacticraftPixelGalaxy,代码行数:26,代码来源:PixelItemSeed.java

示例9: getForItem

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
public static PlantItem getForItem (IBlockAccess blockAccess, ItemStack itemStack) {
    if (itemStack == null || itemStack.getItem() == null)
        return null;

    IPlantable plantable = PlantRegistry.getPlantable(itemStack);
    if (plantable == null)
        return getForItem(itemStack);

    Block block = plantable.getPlant(blockAccess, 0, -1, 0);
    if (block == null)
        return getForItem(itemStack);

    int meta = plantable.getPlantMetadata(blockAccess, 0, -1, 0);
    if (meta == 0)
        meta = itemStack.getItemDamage();

    return new PlantItem(itemStack, block, meta);
}
 
开发者ID:jaquadro,项目名称:GardenCollection,代码行数:19,代码来源:PlantItem.java

示例10: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant (IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) {
    TileEntityLargePot te = getTileEntity(world, x, y, z);
    if (te == null || te.getSubstrate() == null)
        return false;

    EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z);
    Block plant = plantable.getPlant(world, x, y + 1, z);
    Block substrate = Block.getBlockFromItem(te.getSubstrate());

    ItemStack plantItem = new ItemStack(plant, 1, plantable.getPlantMetadata(world, x, y, z));
    if (PlantRegistry.instance().isBlacklisted(plantItem))
        return false;

    if (plant == Blocks.cactus)
        return substrate == Blocks.sand;

    return plantType == EnumPlantType.Crop && substrate == Blocks.farmland;
}
 
开发者ID:jaquadro,项目名称:ForgeMods,代码行数:20,代码来源:BlockLargePot.java

示例11: applyPlantable

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
protected void applyPlantable (World world, int x, int y, int z, TileEntityLargePot tile, EntityPlayer player, IPlantable plantable) {
    ItemStack itemStack = player.inventory.getCurrentItem();

    // TODO: Non-compliant IPlantable, use config
    Block itemBlock = plantable.getPlant(world, x, y, z);
    int itemMeta = itemStack.getItemDamage();
    if (itemBlock == null && plantable instanceof Block) {
        itemBlock = (Block) plantable;
    }
    else {
        int plantMeta = plantable.getPlantMetadata(world, x, y, z);
        if (plantMeta != world.getBlockMetadata(x, y, z))
            itemMeta = plantMeta;
    }

    world.setBlock(x, y + 1, z, ModBlocks.largePotPlantProxy, itemMeta, 3);
    if (itemBlock instanceof BlockDoublePlant || itemBlock.getRenderType() == 40)
        world.setBlock(x, y + 2, z, ModBlocks.largePotPlantProxy, itemMeta | 8, 3);

    tile.setItem(itemStack.getItem(), itemMeta);
    tile.markDirty();

    if (!player.capabilities.isCreativeMode && --itemStack.stackSize <= 0)
        player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
 
开发者ID:jaquadro,项目名称:ForgeMods,代码行数:26,代码来源:BlockLargePot.java

示例12: placeSeed

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
public static boolean placeSeed(IInventory inv, World world, int x, int y, int z, int invPos, ForgeDirection direction) {

        ItemStack currentItem = inv.getStackInSlot(invPos);
        if(currentItem == null || !(currentItem.getItem() instanceof IPlantable)) {
            return false;
        }

        IPlantable plantable = (IPlantable) currentItem.getItem();

        Block targetBlock = world.getBlock(x, y, z);
        if(targetBlock == null || !targetBlock.canSustainPlant(world, x, y, z, direction, plantable)) {
            return false;
        }

        if(!world.isAirBlock(x, y + 1, z)) {
            return false;
        }

        Block plantablePlant = plantable.getPlant(world, x, y + 1, z);
        int plantMeta = plantable.getPlantMetadata(world, x, y + 1, z);

        world.setBlock(x, y + 1, z, plantablePlant, plantMeta, 3);

        return true;
    }
 
开发者ID:portablejim,项目名称:PlanterHelper,代码行数:26,代码来源:PlantingLogic.java

示例13: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable)
{
    final int metadata = world.getBlockMetadata(x, y, z);

    if (metadata < 5 && metadata > 13)
    {
        return false;
    }

    plantable.getPlant(world, x, y + 1, z);

    return plantable instanceof BlockFlower;

}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:16,代码来源:BlockBasicMoon.java

示例14: canPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
public static boolean canPlant(World worldObj, BlockPos bc, IPlantable plantable) {
    IBlockState target = plantable.getPlant(worldObj, bc);
    BlockPos groundPos = bc.down();
    IBlockState groundBS = worldObj.getBlockState(groundPos);
    Block ground = groundBS.getBlock();
    if(target != null && target.getBlock().canPlaceBlockAt(worldObj, bc) &&        
        ground.canSustainPlant(groundBS, worldObj, groundPos, EnumFacing.UP, plantable)) {
      return true;
    }
    return false;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:12,代码来源:FarmUtil.java

示例15: canSustainPlant

import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
	IBlockState plant = plantable.getPlant(world, pos.offset(direction));
	EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

	if(plantable == TFCBlocks.Vegetation && (VegType)plant.getValue(BlockVegetation.META_PROPERTY) == VegType.Grass)
		return true;
	return false;
}
 
开发者ID:Deadrik,项目名称:TFC2,代码行数:11,代码来源:BlockStone.java


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