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


Java BlockSapling类代码示例

本文整理汇总了Java中net.minecraft.block.BlockSapling的典型用法代码示例。如果您正苦于以下问题:Java BlockSapling类的具体用法?Java BlockSapling怎么用?Java BlockSapling使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: growCrop

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
@Override
public void growCrop(World world, int cropId, Vect pos) {

	if (cropId == Block.sapling.blockID) {
		((BlockSapling) Block.sapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
	}

	if (cropId == ForestryBlock.firsapling.blockID) {
		((BlockFirSapling) ForestryBlock.firsapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
	}

	if (cropId == ForestryBlock.sapling.blockID) {
		((BlockSaplings) ForestryBlock.sapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
	}

	if (cropId == Block.crops.blockID) {
		((BlockCrops) Block.crops).fertilize(world, pos.x, pos.y, pos.z);
	}

	if (cropId == Block.netherStalk.blockID) {
		world.setBlockAndMetadataWithNotify(pos.x, pos.y, pos.z, Block.netherStalk.blockID, 3);
	}
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:24,代码来源:MillForester.java

示例2: isCorrectBlock

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
private boolean isCorrectBlock(BlockPos pos)
{
	Block block = WBlock.getBlock(pos);
	
	if(!(block instanceof IGrowable) || block instanceof BlockGrass
		|| !((IGrowable)block).canGrow(WMinecraft.getWorld(), pos,
			WBlock.getState(pos), false))
		return false;
	
	if(block instanceof BlockSapling)
		return saplings.isChecked();
	else if(block instanceof BlockCrops)
		return crops.isChecked();
	else if(block instanceof BlockStem)
		return stems.isChecked();
	else if(block instanceof BlockCocoa)
		return cocoa.isChecked();
	else
		return other.isChecked();
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:21,代码来源:BonemealAuraMod.java

示例3: countResources

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
private void countResources() {
	shouldCountResources = false;
	saplingCount = 0;
	bonemealCount = 0;
	ItemStack stack = ItemStackTools.getEmptyStack();
	for (int i = 27; i < 33; i++) {
		stack = inventory.getStackInSlot(i);
		if (!ItemStackTools.isValid(stack)) {
			continue;
		}
		if (stack.getItem() instanceof ItemBlock) {
			ItemBlock item = (ItemBlock) stack.getItem();
			if (item.getBlock() instanceof BlockSapling) {
				saplingCount += ItemStackTools.getStackSize(stack);
			}
		} else if (stack.getItem() == Items.DYE
				&& stack.getItemDamage() == EnumDyeColor.WHITE.getDyeDamage()) {
			bonemealCount += ItemStackTools.getStackSize(stack);
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:22,代码来源:WorksiteTreeFarm.java

示例4: scanBlockPosition

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
@Override
protected void scanBlockPosition(BlockPos pos) {
	IBlockState state;
	if (getWorld().isAirBlock(pos)) {
		state = getWorld().getBlockState(pos.down());
		if (state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.GRASS) {
			blocksToPlant.add(pos);
		}
	} else {
		state = getWorld().getBlockState(pos);
		if (state.getBlock() instanceof BlockSapling) {
			blocksToFertilize.add(pos);
		} else if (TreeUtil.isLog(state)) {
			if (!blocksToChop.contains(pos)) {
				addTreeBlocks(pos);
			}
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:20,代码来源:WorksiteTreeFarm.java

示例5: placeHut

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
public static void placeHut(final World world, BlockPos startpos, int[][][] data, IBlockState[] states, Random rand) {
  for (int pass = 0; pass <= 1; pass++) {
    for (int y = 0; y < data.length; y++) {
      for (int x = 0; x < 6; x++) {
        for (int z = 0; z < 6; z++) {
          BlockPos pos = startpos.add(x + 5, -y + 5, z + 5);
          if (data[y][z][x] != -1) {
            IBlockState state = states[data[y][z][x]];
            if (state == null || (pass == 0 && (state.getBlock() instanceof BlockCarpet || state.getBlock() instanceof BlockSapling))) {
              world.setBlockToAir(pos);
            } else if (state.getBlock() instanceof BlockFalling) {
              while (world.getBlockState(pos).getBlock().isReplaceable(world, pos) && !world.isAirBlock(new BlockPos(pos.getX(), 0, pos.getZ()))) {
                world.setBlockState(pos, state);
                world.immediateBlockTick(pos, state, rand);
              }
            } else if (!(state.getBlock() instanceof BlockSlab)
                || (world.getBlockState(pos).getBlock().isReplaceable(world, pos) && world.getBlockState(pos).getMaterial() != Material.WATER)) {
              world.setBlockState(pos, state);
            }
          }
        }
      }
    }
  }
}
 
开发者ID:HenryLoenwind,项目名称:TravelHut,代码行数:26,代码来源:WorldGenHandler.java

示例6: onSaplingGrow

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
@SubscribeEvent
public void onSaplingGrow(SaplingGrowTreeEvent ev)
{
    IBlockState state = ev.getWorld().getBlockState(ev.getPos());
    Block block = state.getBlock();
    if (block == Blocks.sapling)
    {
        BlockPlanks.EnumType type = state.getValue(BlockSapling.TYPE);

        switch (type)
        {
            case OAK:
                ev.setResult(Event.Result.DENY);
                new BirchTreeGenerator().generateTreeAt(ev.getWorld(), ev.getPos(), ev.getRand());
                break;
        }
    }
}
 
开发者ID:gigaherz,项目名称:NaturalTrees,代码行数:19,代码来源:NaturalTrees.java

示例7: growCrop

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
@Override
public void growCrop(ItemStack crop, BlockPosition blockPos) {
	if (crop.isItemEqual(new ItemStack(Blocks.sapling))) {
		((BlockSapling) Blocks.sapling).func_149853_b(worldObj, worldObj.rand, blockPos.x, blockPos.y, blockPos.z);
	}
	if (ForestryProxy.moduleArboricultureEnabled) {
		if (crop.isItemEqual(new ItemStack(ForestryProxy.blockSapling))) {
			ForestryProxy.blockSapling.func_149853_b(worldObj, worldObj.rand, blockPos.x, blockPos.y, blockPos.z);
		}
	}
	if (crop.getItem() == Item.getItemFromBlock(Blocks.wheat)) {
		((BlockCrops) Blocks.wheat).func_149853_b(worldObj, worldObj.rand, blockPos.x, blockPos.y, blockPos.z);
	}
	if (crop.isItemEqual(new ItemStack(Blocks.nether_wart))) {
		blockPos.setBlock(worldObj, blockPos.getBlock(worldObj), 3);
	}
}
 
开发者ID:covers1624,项目名称:LegacyFarms,代码行数:18,代码来源:TileMillForester.java

示例8: func_150532_c

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
private boolean func_150532_c(World p_150532_1_, Random p_150532_2_, int p_150532_3_, int p_150532_4_, int p_150532_5_)
{
    Block block = p_150532_1_.getBlock(p_150532_3_, p_150532_4_ - 1, p_150532_5_);

    boolean isSoil = block.canSustainPlant(p_150532_1_, p_150532_3_, p_150532_4_ - 1, p_150532_5_, ForgeDirection.UP, (BlockSapling)Blocks.sapling);
    if (isSoil && p_150532_4_ >= 2)
    {
        onPlantGrow(p_150532_1_, p_150532_3_,     p_150532_4_ - 1, p_150532_5_,     p_150532_3_, p_150532_4_, p_150532_5_);
        onPlantGrow(p_150532_1_, p_150532_3_ + 1, p_150532_4_ - 1, p_150532_5_,     p_150532_3_, p_150532_4_, p_150532_5_);
        onPlantGrow(p_150532_1_, p_150532_3_,     p_150532_4_ - 1, p_150532_5_ + 1, p_150532_3_, p_150532_4_, p_150532_5_);
        onPlantGrow(p_150532_1_, p_150532_3_ + 1, p_150532_4_ - 1, p_150532_5_ + 1, p_150532_3_, p_150532_4_, p_150532_5_);
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:TheDarkEra,项目名称:TheDarkEra,代码行数:19,代码来源:TDEWorldGenHugeTree.java

示例9: onEntityItemExpire

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
@SubscribeEvent
public void onEntityItemExpire(ItemExpireEvent parEvent)
{
	if (!REFORESTATION) return;
	if (!(Block.getBlockFromItem(parEvent.entityItem.getEntityItem().getItem()) instanceof BlockSapling)) return;

	BlockSapling sapling = (BlockSapling) Block.getBlockFromItem(parEvent.entityItem.getEntityItem().getItem());
	int x = (int) (parEvent.entity.posX);
	int y = (int) (parEvent.entity.posY + 0.5);
	int z = (int) (parEvent.entity.posZ);
	BlockPos pos = new BlockPos(x, y, z);

	if (sapling.canBlockStay(parEvent.entity.worldObj, pos, sapling.getDefaultState()))
	{
		parEvent.entity.worldObj.setBlockState(pos, sapling.getStateFromMeta(parEvent.entityItem.getEntityItem().getItemDamage()), 3);
	}
	else
	{
		parEvent.extraLife = parEvent.entityItem.lifespan - REFOREST_AGE;
		parEvent.setCanceled(true);
	}
}
 
开发者ID:andykuo1,项目名称:mcplus_mods,代码行数:23,代码来源:EventHandlerOvergrowth.java

示例10: func_150540_a

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
private void func_150540_a(World p_150540_1_, int p_150540_2_, int p_150540_3_, int p_150540_4_)
{
    for (int l = p_150540_3_ + 2; l >= p_150540_3_ - 3; --l)
    {
        Block block = p_150540_1_.getBlock(p_150540_2_, l, p_150540_4_);

        if (block.canSustainPlant(p_150540_1_, p_150540_2_, l, p_150540_4_, ForgeDirection.UP, (BlockSapling)Blocks.sapling))
        {
            this.setBlockAndNotifyAdequately(p_150540_1_, p_150540_2_, l, p_150540_4_, Blocks.dirt, 2);
            break;
        }

        if (block.isAir(p_150540_1_, p_150540_2_, l, p_150540_4_) && l < p_150540_3_)
        {
            break;
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:19,代码来源:WorldGenMegaPineTree.java

示例11: pickupSaplings

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
private void pickupSaplings() {
	BlockPos p1 = getWorkBoundsMin();
	BlockPos p2 = getWorkBoundsMax().add(1, 1, 1);
	AxisAlignedBB bb = new AxisAlignedBB(p1, p2);
	List<EntityItem> items = getWorld().getEntitiesWithinAABB(EntityItem.class, bb);
	ItemStack stack;
	for (EntityItem item : items) {
		stack = item.getEntityItem();
		if (!ItemStackTools.isValid(stack)) {
			continue;
		}
		if (stack.getItem() == Items.APPLE) {
			item.setDead();
			addStackToInventory(stack, RelativeSide.TOP);
			continue;
		}
		if (stack.getItem() instanceof ItemBlock) {
			ItemBlock ib = (ItemBlock) stack.getItem();
			if (ib.getBlock() instanceof BlockSapling) {
				if (!ItemUtil.canInventoryHold(inventory, inventory
						.getRawIndicesCombined(RelativeSide.FRONT,
								RelativeSide.TOP), stack)) {
					break;
				}
				item.setDead();
				addStackToInventory(stack, RelativeSide.FRONT,
						RelativeSide.TOP);
			}
			if (TreeUtil.isLog(stack)) {
				if (!ItemUtil.canInventoryHold(inventory, inventory
						.getRawIndicesCombined(RelativeSide.TOP), stack)) {
					break;
				}
				item.setDead();
				addStackToInventory(stack, RelativeSide.TOP);
			}
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:40,代码来源:WorksiteTreeFarm.java

示例12: validTreeLocation

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
/**
 * Returns a boolean indicating whether or not the current location for the tree, spanning basePos to to the height
 * limit, is valid.
 */
boolean validTreeLocation()
{
    int[] aint = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]};
    int[] aint1 = new int[] {this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2]};
    Block block = this.worldObj.getBlock(this.basePos[0], this.basePos[1] - 1, this.basePos[2]);

    boolean isSoil = block.canSustainPlant(worldObj, basePos[0], basePos[1] - 1, basePos[2], ForgeDirection.UP, (BlockSapling)Blocks.sapling);
    if (!isSoil)
    {
        return false;
    }
    else
    {
        int i = this.checkBlockLine(aint, aint1);

        if (i == -1)
        {
            return true;
        }
        else if (i < 6)
        {
            return false;
        }
        else
        {
            this.heightLimit = i;
            return true;
        }
    }
}
 
开发者ID:GhostMonk3408,项目名称:MidgarCrusade,代码行数:35,代码来源:WorldGenBigTreesDim.java

示例13: seedMap

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
private void seedMap() {
	// Iterate through the blockmap looking for known pattern types.
	// Though they probably should all be registered with Forge
	// dictionary it's not a requirement.
	final Iterator<Block> itr = Block.REGISTRY.iterator();
	while (itr.hasNext()) {
		final Block block = itr.next();
		final String blockName = MCHelper.nameOf(block);
		if (block instanceof BlockCrops) {
			final BlockCrops crop = (BlockCrops) block;
			if (crop.getMaxAge() == 3) {
				this.registerBlocks("#beets", blockName);
			} else if (blockName.equals("minecraft:wheat")) {
				this.registerBlocks("#wheat", blockName);
			} else if (crop.getMaxAge() == 7) {
				this.registerBlocks("#crop", blockName);
			}
		} else if (block instanceof BlockSapling) {
			this.registerBlocks("#sapling", blockName);
		} else if (block instanceof BlockReed) {
			this.registerBlocks("#reed", blockName);
		} else if (block instanceof BlockFence) {
			this.registerBlocks("#fence", blockName);
		} else if (block instanceof BlockFlower || block instanceof BlockMushroom) {
			this.registerBlocks("NOT_EMITTER", blockName);
		} else if (block instanceof BlockLog || block instanceof BlockPlanks) {
			this.registerBlocks("wood", blockName);
		} else if (block instanceof BlockDoor) {
			this.registerBlocks("bluntwood", blockName);
		} else if (block instanceof BlockLeaves) {
			this.registerBlocks("leaves", blockName);
		} else if (block instanceof BlockOre) {
			this.registerBlocks("ore", blockName);
		} else if (block instanceof BlockIce) {
			this.registerBlocks("ice", blockName);
		}
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:39,代码来源:FootstepsRegistry.java

示例14: registerVanillaVariantProps

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
private static void registerVanillaVariantProps() {
	// TODO: omit similar blocks
	registerVariantProperty(BlockStone.VARIANT);
	registerVariantProperty(BlockPlanks.VARIANT);
	registerVariantProperty(BlockSapling.TYPE);
	registerVariantProperty(BlockDirt.VARIANT);
	registerVariantProperty(BlockSand.VARIANT);
	registerVariantProperty(BlockOldLog.VARIANT);
	registerVariantProperty(BlockNewLog.VARIANT);
	registerVariantProperty(BlockOldLeaf.VARIANT);
	registerVariantProperty(BlockNewLeaf.VARIANT);
	registerVariantProperty(BlockSandStone.TYPE);
	registerVariantProperty(BlockTallGrass.TYPE);
	registerVariantProperty(BlockPistonExtension.TYPE);
	registerVariantProperty(BlockColored.COLOR);
	registerVariantProperty(BlockPistonMoving.TYPE);
	registerVariantProperty(Blocks.YELLOW_FLOWER.getTypeProperty());
	registerVariantProperty(Blocks.RED_FLOWER.getTypeProperty());
	registerVariantProperty(BlockStoneSlab.VARIANT);
	registerVariantProperty(BlockWoodSlab.VARIANT);
	registerVariantProperty(BlockAnvil.DAMAGE);
	registerVariantProperty(BlockQuartz.VARIANT);
	registerVariantProperty(BlockCarpet.COLOR);
	registerVariantProperty(BlockDoublePlant.VARIANT);
	registerVariantProperty(BlockStainedGlass.COLOR);
	registerVariantProperty(BlockStainedGlassPane.COLOR);
	registerVariantProperty(BlockPrismarine.VARIANT);
	registerVariantProperty(BlockRedSandstone.TYPE);
	registerVariantProperty(BlockStoneSlabNew.VARIANT);
}
 
开发者ID:Earthcomputer,项目名称:Easy-Editors,代码行数:31,代码来源:BlockPropertyRegistry.java

示例15: func_150532_c

import net.minecraft.block.BlockSapling; //导入依赖的package包/类
public boolean func_150532_c(World world, Random rand, int x, int y, int z) {
		while (world.isAirBlock(x, y, z) && y > 2) {
			y--;
		}
		Block block = world.getBlock(x, y, z);
		if (block != Blocks.grass && block != Blocks.dirt && block != TDEBlocks.dark_grass && block != TDEBlocks.dark_dirt ) {
			return false;
		} else {
			for (int i = -2; i <= 2; i++) {
				for (int j = -2; j <= 2; j++) {
					if (world.isAirBlock(x + i, y - 1, z + j) && world.isAirBlock(x + i, y - 2, z + j) && !world.isAirBlock(x + i, y, z + j)) {
						return false;
					}
				}
			}
	
	boolean isSoil = block.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, (BlockSapling) Blocks.sapling);
	if (isSoil && y >= 2) {
		onPlantGrow(world, x, y - 1, z, x, y, z);
		onPlantGrow(world, x + 1, y - 1, z, x, y, z);
		onPlantGrow(world, x, y - 1, z + 1, x, y, z);
		onPlantGrow(world, x + 1, y - 1, z + 1, x, y, z);
		return true;
	} else {
		return false;		
}
		}
	}
 
开发者ID:TheDarkEra,项目名称:TheDarkEra,代码行数:29,代码来源:WorldGenDarkJungleTree.java


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