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