當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。