本文整理汇总了Java中net.minecraftforge.common.IPlantable.getPlantMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java IPlantable.getPlantMetadata方法的具体用法?Java IPlantable.getPlantMetadata怎么用?Java IPlantable.getPlantMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.common.IPlantable
的用法示例。
在下文中一共展示了IPlantable.getPlantMetadata方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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;
}
示例4: 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);
}
示例5: 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;
}
示例6: getPlantMetadata
import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
private static int getPlantMetadata (IBlockAccess world, int x, int y, int z, IPlantable plant, int defaultMeta) {
if (plant == null)
return 0;
Block itemBlock = plant.getPlant(world, x, y, z);
int itemMeta = defaultMeta;
if (itemBlock != null) {
int plantMeta = plant.getPlantMetadata(world, x, y, z);
if (plantMeta > 0)
itemMeta = plantMeta;
}
return itemMeta;
}
示例7: getPlantInfo
import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
public IPlantInfo getPlantInfo (IBlockAccess world, IPlantable plant) {
Block block = plant.getPlant(world, 0, 0, 0);
int meta = plant.getPlantMetadata(world, 0, 0, 0);
return getPlantInfo(block, meta);
}
示例8: canSustainPlantActivated
import net.minecraftforge.common.IPlantable; //导入方法依赖的package包/类
protected boolean canSustainPlantActivated (IBlockAccess world, int x, int y, int z, IPlantable plantable) {
TileEntityLargePot te = getTileEntity(world, x, y, z);
if (te == null || te.getSubstrate() == null)
return false;
Block substrate = Block.getBlockFromItem(te.getSubstrate());
if (substrate == null)
return false;
EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z);
Block plant = plantable.getPlant(world, x, y + 1, z);
if (plant == null && plantable instanceof Block)
plant = (Block) plantable;
if (plant != null) {
ItemStack plantItem = new ItemStack(plant, 1, plantable.getPlantMetadata(world, x, y, z));
if (PlantRegistry.instance().isBlacklisted(plantItem))
return false;
}
// TODO: Non-compliant IPlantable, use config
if (plantType == null)
plantType = EnumPlantType.Plains;
if (plant == Blocks.cactus)
return false;
switch (plantType) {
case Desert:
return substrate == Blocks.sand;
case Nether:
return substrate == Blocks.soul_sand;
//case Crop:
// return substrate == Blocks.dirt || substrate == Blocks.farmland;
case Cave:
return true;
case Plains:
return substrate == Blocks.grass || substrate == Blocks.dirt;
case Beach:
return substrate == Blocks.grass || substrate == Blocks.dirt || substrate == Blocks.sand;
case Water:
return substrate == Blocks.water;
default:
return false;
}
}