Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mod.adamDoesMods.Biomes.features;
- import java.util.List;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockSapling;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.IIcon;
- import net.minecraft.util.MathHelper;
- import net.minecraft.world.World;
- import net.minecraft.world.gen.feature.WorldGenBigTree;
- import net.minecraft.world.gen.feature.WorldGenCanopyTree;
- import net.minecraft.world.gen.feature.WorldGenForest;
- import net.minecraft.world.gen.feature.WorldGenMegaJungle;
- import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
- import net.minecraft.world.gen.feature.WorldGenSavannaTree;
- import net.minecraft.world.gen.feature.WorldGenTaiga2;
- import net.minecraft.world.gen.feature.WorldGenTrees;
- import net.minecraft.world.gen.feature.WorldGenerator;
- import net.mod.adamDoesMods.adamDoesMods;
- import net.mod.adamDoesMods.Biomes.features.WorldGenAphockTree;
- public class admSaplings extends BlockSapling {
- public static final String[] saplings = new String[] {"Aphock"};
- private static final IIcon[] icons = new IIcon[saplings.length];
- public admSaplings() {
- float var1 = 0.4F;
- this.setBlockBounds(0.5F - var1, 0.0F, 0.5F - var1, 0.5F + var1, var1 * 2.0F, 0.5F + var1);
- this.setCreativeTab(CreativeTabs.tabDecorations);
- }
- public void updateTick(World world, int x, int y, int z, Random random)
- {
- if (!world.isRemote)
- {
- super.updateTick(world, x, y, z, random);
- if (world.getBlockLightValue(x, y + 1, z) >= 9 && random.nextInt(7) == 0)
- {
- this.func_149879_c(world, x, y, z, random);
- }
- }
- }
- public IIcon getIcon(int side, int meta)
- {
- meta &= 7;
- return icons[MathHelper.clamp_int(meta, 0, 5)];
- }
- //markOrGrowMarked
- public void func_149879_c(World world, int x, int y, int z, Random random)
- {
- int i = world.getBlockMetadata(x, y, z);
- if ((i & 8) == 0)
- {
- world.setBlockMetadataWithNotify(x, y, z, i | 8, 4);
- }
- else
- {
- this.func_149878_d(world, x, y, z, random);
- }
- }
- //growTree
- @Override
- public void func_149878_d(World world, int x, int y, int z, Random random)
- {
- if(!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, random, x, y, z)) return;
- int var6 = world.getBlockMetadata(x, y, z) & 7;
- Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
- int var8 = 0;
- int var9 = 0;
- boolean var10 = false;
- switch (var6)
- {
- case 0:
- break;
- case 1:
- object = new WorldGenAphockTree(adamDoesMods.logs, adamDoesMods.leaves, 0, 0, false, 9, 15, false);
- break;
- case 3:
- break;
- case 4:
- break;
- case 5:
- break;
- default:
- break;
- }
- Block var11 = Blocks.air;
- if (var10)
- {
- world.setBlock(x + var8, y, z + var9, var11, 0, 4);
- world.setBlock(x + var8 + 1, y, z + var9, var11, 0, 4);
- world.setBlock(x + var8, y, z + var9 + 1, var11, 0, 4);
- world.setBlock(x + var8 + 1, y, z + var9 + 1, var11, 0, 4);
- }
- else
- {
- world.setBlock(x, y, z, var11, 0, 4);
- }
- if (!((WorldGenerator)object).generate(world, random, x + var8, y, z + var9))
- {
- if (var10)
- {
- world.setBlock(x + var8, y, z + var9, this, var6, 4);
- world.setBlock(x + var8 + 1, y, z + var9, this, var6, 4);
- world.setBlock(x + var8, y, z + var9 + 1, this, var6, 4);
- world.setBlock(x + var8 + 1, y, z + var9 + 1, this, var6, 4);
- }
- else
- {
- world.setBlock(x, y, z, this, var6, 4);
- }
- }
- }
- //isSameSapling
- public boolean func_149880_a(World world, int w, int x, int y, int z)
- {
- return world.getBlock(w, x, y) == this && (world.getBlockMetadata(w, x, y) & 7) == z;
- }
- public int damageDropped(int x)
- {
- return MathHelper.clamp_int(x & 7, 0, 5);
- }
- public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
- for(int i = 0; i < saplings.length; i++) {
- list.add(new ItemStack(item, 1, i));
- }
- }
- public void registerBlockIcons(IIconRegister register)
- {
- for (int i = 0; i < icons.length; i++)
- {
- icons[i] = register.registerIcon("adamdoesmods" + ":" +"sapling" + saplings[i]);
- }
- }
- public boolean func_149851_a(World world, int x, int y, int z, boolean myBoolean)
- {
- return true;
- }
- public boolean func_149852_a(World world, Random random, int x, int y, int z)
- {
- return (double)world.rand.nextFloat() < 0.45D;
- }
- public void func_149853_b(World world, Random random, int x, int y, int z)
- {
- this.func_149879_c(world, x, y, z, random);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement