Java Code Examples for net.minecraft.block.material.Material#VINE
The following examples show how to use
net.minecraft.block.material.Material#VINE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemEnderSword.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public float getDestroySpeed(ItemStack stack, IBlockState state) { if (this.isToolBroken(stack)) { return 0.2f; } if (state.getBlock() == Blocks.WEB) { return 15.0f; } Material material = state.getMaterial(); if (material == Material.PLANTS || material == Material.VINE || material == Material.CORAL || material == Material.LEAVES || material == Material.GOURD) { return 1.5f; } return 1.0f; }
Example 2
Source File: ToolSword.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { String tool = block.getBlock().getHarvestTool(block); return (tool != null && tool.equals("sword")) || block.getMaterial() == Material.LEAVES || block.getMaterial() == Material.GOURD || block.getMaterial() == Material.VINE || block.getMaterial() == Material.WEB || block.getMaterial() == Material.CLOTH || block.getMaterial() == Material.CARPET || block.getMaterial() == Material.PLANTS || block.getMaterial() == Material.CACTUS || block.getMaterial() == Material.CAKE || block.getMaterial() == Material.TNT || block.getMaterial() == Material.SPONGE; }
Example 3
Source File: WorldGenPatch.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(this.size - 2) + 2; int j = 1; for (int k = position.getX() - i; k <= position.getX() + i; ++k) { for (int l = position.getZ() - i; l <= position.getZ() + i; ++l) { int i1 = k - position.getX(); int j1 = l - position.getZ(); if (i1 * i1 + j1 * j1 <= i * i) { for (int k1 = position.getY() - 1; k1 <= position.getY() + 1; ++k1) { BlockPos blockpos = new BlockPos(k, k1, l); Block block = worldIn.getBlockState(blockpos).getBlock(); if (replaceableBlocks.contains(block)) { worldIn.setBlockState(blockpos, state, 2); if (worldIn.getBlockState(blockpos.up()).getMaterial() == Material.VINE) worldIn.setBlockToAir(blockpos.up()); } } } } } return true; }
Example 4
Source File: WorldGenSurfacePatch.java From Traverse-Legacy-1-12-2 with MIT License | 5 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(this.size - 2) + 2; int j = 1; for (int k = position.getX() - i; k <= position.getX() + i; ++k) { for (int l = position.getZ() - i; l <= position.getZ() + i; ++l) { int i1 = k - position.getX(); int j1 = l - position.getZ(); if (i1 * i1 + j1 * j1 <= i * i) { for (int k1 = position.getY() - 1; k1 <= position.getY() + 1; ++k1) { BlockPos blockpos = new BlockPos(k, k1, l); if (worldIn.isAirBlock(blockpos.up()) || worldIn.getBlockState(blockpos.up()).getMaterial() == Material.VINE) { Block block = worldIn.getBlockState(blockpos).getBlock(); if (replaceableBlocks.contains(block)) { worldIn.setBlockState(blockpos, state, 2); if (worldIn.getBlockState(blockpos.up()).getMaterial() == Material.VINE) worldIn.setBlockToAir(blockpos.up()); } } } } } } return true; }
Example 5
Source File: BlockCactus.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public BlockCactus() { super(Material.VINE, META_PROPERTY); this.setCreativeTab(TFCTabs.TFCBuilding); setSoundType(SoundType.GROUND); this.setTickRandomly(true); this.setDefaultState(this.blockState.getBaseState().withProperty(META_PROPERTY, DesertCactusType.Barrel).withProperty(BLOOM, false)); float f = 0.35F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f); }
Example 6
Source File: ItemKotachi.java From Sakura_mod with MIT License | 5 votes |
public float getDestroySpeed(ItemStack stack, IBlockState state) { Block block = state.getBlock(); if (block == Blocks.WEB) { return 15.0F; } Material material = state.getMaterial(); return material != Material.PLANTS && material != Material.VINE && material != Material.CORAL && material != Material.LEAVES && material != Material.GOURD ? 1.0F : 1.5F; }
Example 7
Source File: ItemKatana.java From Sakura_mod with MIT License | 5 votes |
public float getDestroySpeed(ItemStack stack, IBlockState state) { Block block = state.getBlock(); if (block == Blocks.WEB) { return 15.0F; } Material material = state.getMaterial(); return material != Material.PLANTS && material != Material.VINE && material != Material.CORAL && material != Material.LEAVES && material != Material.GOURD ? 1.0F : 1.5F; }
Example 8
Source File: WorldGenSurfacePatch.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(this.size - 2) + 2; int j = 1; for (int k = position.getX() - i; k <= position.getX() + i; ++k) { for (int l = position.getZ() - i; l <= position.getZ() + i; ++l) { int i1 = k - position.getX(); int j1 = l - position.getZ(); if (i1 * i1 + j1 * j1 <= i * i) { for (int k1 = position.getY() - 1; k1 <= position.getY() + 1; ++k1) { BlockPos blockpos = new BlockPos(k, k1, l); if (worldIn.isAirBlock(blockpos.up()) || worldIn.getBlockState(blockpos.up()).getMaterial() == Material.VINE) { Block block = worldIn.getBlockState(blockpos).getBlock(); if (replaceableBlocks.contains(block)) { worldIn.setBlockState(blockpos, state, 2); if (worldIn.getBlockState(blockpos.up()).getMaterial() == Material.VINE) worldIn.setBlockToAir(blockpos.up()); } } } } } } return true; }
Example 9
Source File: ToolSense.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { return block.getMaterial() == Material.PLANTS || block.getMaterial() == Material.LEAVES || block.getMaterial() == Material.VINE || block.getBlock() instanceof BlockCrops; }
Example 10
Source File: ToolSense.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onBlockPreBreak(ItemStack stack, BlockPos blockPos, EntityPlayer player) { if (player.world.isRemote || player.capabilities.isCreativeMode) { return false; } ToolMetaItem<?> toolMetaItem = (ToolMetaItem<?>) stack.getItem(); int damagePerBlockBreak = getToolDamagePerBlockBreak(stack); for(int x = -5; x <= 5; x++) { for(int z = -5; z <= 5; z++) { for(int y = -5; y <= 5; y++) {BlockPos offsetPos = blockPos.add(x, y, z); IBlockState blockState = player.world.getBlockState(offsetPos); if(player.world.isBlockModifiable(player, offsetPos) && toolMetaItem.isUsable(stack, damagePerBlockBreak)) { if(blockState.getBlock() instanceof BlockCrops) { player.world.playEvent(2001, offsetPos, Block.getStateId(blockState)); ToolUtility.applyHarvestBehavior(offsetPos, player); toolMetaItem.damageItem(stack, damagePerBlockBreak, false); } else if(blockState.getMaterial() == Material.PLANTS || blockState.getMaterial() == Material.LEAVES || blockState.getMaterial() == Material.VINE) { player.world.playEvent(2001, offsetPos, Block.getStateId(blockState)); player.world.setBlockToAir(offsetPos); toolMetaItem.damageItem(stack, damagePerBlockBreak, false); } } } } } return true; }
Example 11
Source File: ToolUniversalSpade.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { String tool = block.getBlock().getHarvestTool(block); return (tool != null && (tool.equals("shovel") || tool.equals("axe") || tool.equals("saw") || tool.equals("sword") || tool.equals("crowbar"))) || block.getMaterial() == Material.SAND || block.getMaterial() == Material.GRASS || block.getMaterial() == Material.GROUND || block.getMaterial() == Material.SNOW || block.getMaterial() == Material.CLAY || block.getMaterial() == Material.CRAFTED_SNOW || block.getMaterial() == Material.LEAVES || block.getMaterial() == Material.VINE || block.getMaterial() == Material.WOOD || block.getMaterial() == Material.CACTUS || block.getMaterial() == Material.CIRCUITS || block.getMaterial() == Material.GOURD || block.getMaterial() == Material.WEB || block.getMaterial() == Material.CLOTH || block.getMaterial() == Material.CARPET || block.getMaterial() == Material.PLANTS || block.getMaterial() == Material.CAKE || block.getMaterial() == Material.TNT || block.getMaterial() == Material.SPONGE; }
Example 12
Source File: ToolSaw.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { String tool = block.getBlock().getHarvestTool(block); return (tool != null && (tool.equals("axe") || tool.equals("saw"))) || block.getMaterial() == Material.LEAVES || block.getMaterial() == Material.VINE || block.getMaterial() == Material.WOOD || block.getMaterial() == Material.CACTUS || block.getMaterial() == Material.ICE || block.getMaterial() == Material.PACKED_ICE; }
Example 13
Source File: ItemEnderTool.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean canHarvestBlock(IBlockState state, ItemStack stack) { if (this.isToolBroken(stack)) { return false; } ToolType tool = ToolType.fromStack(stack); if (tool.equals(ToolType.PICKAXE)) // Ender Pickaxe { if (state.getMaterial() == Material.ROCK || state.getMaterial() == Material.GLASS || state.getMaterial() == Material.ICE || state.getMaterial() == Material.PACKED_ICE || state.getMaterial() == Material.REDSTONE_LIGHT || state.getMaterial() == Material.PISTON || state.getMaterial() == Material.IRON || state.getMaterial() == Material.ANVIL) { //System.out.println("canHarvestBlock(): true; Pickaxe"); return true; } } else if (tool.equals(ToolType.AXE)) // Ender Axe { if (state.getMaterial() == Material.WOOD || state.getMaterial() == Material.LEAVES || state.getMaterial() == Material.GOURD || state.getMaterial() == Material.CARPET || state.getMaterial() == Material.CLOTH || state.getMaterial() == Material.PLANTS || state.getMaterial() == Material.VINE) { //System.out.println("canHarvestBlock(): true; Axe"); return true; } } else if (tool.equals(ToolType.SHOVEL)) // Ender Shovel { if (state.getMaterial() == Material.GROUND || state.getMaterial() == Material.GRASS || state.getMaterial() == Material.SAND || state.getMaterial() == Material.SNOW || state.getMaterial() == Material.CRAFTED_SNOW || state.getMaterial() == Material.CLAY) { //System.out.println("canHarvestBlock(): true; Shovel"); return true; } } //System.out.println("canHarvestBlock(): false"); return false; }
Example 14
Source File: WorldGenTofuTrees.java From TofuCraftReload with MIT License | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(3) + 4; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn,blockpos$mutableblockpos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { IBlockState state = worldIn.getBlockState(position.down()); int j1; if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, BlockLoader.TOFU_SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { j1 = i / 3; for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { BlockPos blockpos = new BlockPos(k1, i3, i2); state = worldIn.getBlockState(blockpos); if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, blockpos, BlockLoader.TOFU_LEAVE.getDefaultState()); } } } } for (int j3 = 0; j3 < i; ++j3) { BlockPos upN = position.up(j3); state = worldIn.getBlockState(upN); if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.up(j3), BlockLoader.ISHITOFU.getDefaultState()); } } return true; } else { return false; } } } else { return false; } }
Example 15
Source File: WorldGenFallenTree.java From Traverse-Legacy-1-12-2 with MIT License | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int num = rand.nextInt(5); EnumFacing orientation; if (num == 0) { orientation = EnumFacing.EAST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.WEST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.SOUTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } else { orientation = EnumFacing.NORTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } int i = rand.nextInt(2) + this.minTreeLength; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int j3 = 0; j3 < i; ++j3) { BlockPos offsetPos = position.offset(orientation, j3); state = worldIn.getBlockState(offsetPos); if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood); } } return true; } else { return false; } } } else { return false; } }
Example 16
Source File: WorldGenFallenTree.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int num = rand.nextInt(5); EnumFacing orientation; if (num == 0) { orientation = EnumFacing.EAST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.WEST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.SOUTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } else { orientation = EnumFacing.NORTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } int i = rand.nextInt(2) + this.minTreeLength; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int j3 = 0; j3 < i; ++j3) { BlockPos offsetPos = position.offset(orientation, j3); state = worldIn.getBlockState(offsetPos); if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood); } } return true; } else { return false; } } } else { return false; } }
Example 17
Source File: WorldGenSakuraTree.java From Sakura_mod with MIT License | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(3) + this.minTreeHeight; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, blockpos$mutableblockpos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { int i4 = i3 - (position.getY() + i); int j1 = 1 - i4 / 2; for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { int l1 = k1 - position.getX(); for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { int j2 = i2 - position.getZ(); if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { BlockPos blockpos = new BlockPos(k1, i3, i2); state = worldIn.getBlockState(blockpos); if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); } } } } } for (int j3 = 0; j3 < i; ++j3) { BlockPos upN = position.up(j3); state = worldIn.getBlockState(upN); if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); } } return true; } return false; } return false; }
Example 18
Source File: WorldGenMapleTreeGreen.java From Sakura_mod with MIT License | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(3) + this.minTreeHeight; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, blockpos$mutableblockpos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { int i4 = i3 - (position.getY() + i); int j1 = 1 - i4 / 2; for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { int l1 = k1 - position.getX(); for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { int j2 = i2 - position.getZ(); if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { BlockPos blockpos = new BlockPos(k1, i3, i2); state = worldIn.getBlockState(blockpos); if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); BlockPos fruitBlockPos = new BlockPos(k1, i3 - 1, i2); BlockPos blockBelowFruitPos = new BlockPos(k1, i3 - 2, i2); if (worldIn.isAirBlock(fruitBlockPos)) if (worldIn.isAirBlock(blockBelowFruitPos) && i3 > 2) if (rand.nextInt(4) == 0) this.setBlockAndNotifyAdequately(worldIn,fruitBlockPos, BlockLoader.CHESTNUTBURR.getDefaultState()); } } } } } for (int j3 = 0; j3 < i; ++j3) { BlockPos upN = position.up(j3); state = worldIn.getBlockState(upN); if (state.getBlock().isAir(state, worldIn, upN) || this.isBurr(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); if (this.generateSap && j3 == 1) { if (worldIn.getBlockState(position.add(0, j3, 0))==this.metaWood) { this.addSapLog(worldIn, position.add(0, j3, 0)); } } } } fallenLeaves(worldIn, position,4,2,4, this.metaFallenLeaves); return true; } return false; } return false; }
Example 19
Source File: BlockUnderVine.java From TofuCraftReload with MIT License | 4 votes |
protected BlockUnderVine() { super(Material.VINE); this.setSoundType(SoundType.PLANT); this.setTickRandomly(true); }
Example 20
Source File: WorldGenApricotTrees.java From TofuCraftReload with MIT License | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(3) + 4; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, blockpos$mutableblockpos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, BlockLoader.APRICOT_SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { int i4 = i3 - (position.getY() + i); int j1 = 1 - i4 / 2; for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { int l1 = k1 - position.getX(); for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { int j2 = i2 - position.getZ(); if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { BlockPos blockpos = new BlockPos(k1, i3, i2); state = worldIn.getBlockState(blockpos); if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, blockpos, BlockLoader.APRICOT_LEAVE.getDefaultState()); } } } } } for (int j3 = 0; j3 < i; ++j3) { BlockPos upN = position.up(j3); state = worldIn.getBlockState(upN); if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.up(j3), Blocks.LOG.getDefaultState()); } } return true; } else { return false; } } } else { return false; } }