Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tristanvo.mod;
- import java.util.List;
- import java.util.Random;
- import com.tristanvo.mod.Generation.WorldGenMangoTree;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockBush;
- import net.minecraft.block.IGrowable;
- 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;
- public class mangoSapling extends BlockBush implements IGrowable
- {
- public static final String[] sapling = new String[] {"Mango"};
- private static final IIcon[] saplingIcon = new IIcon[sapling.length];
- protected mangoSapling()
- {
- float f = 0.4F;
- this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
- this.setStepSound(this.soundTypeGrass);
- }
- /**
- * Ticks the block if it's been scheduled
- */
- public void updateTick(World world, int par2, int par3, int par4, Random random)
- {
- if (!world.isRemote)
- {
- super.updateTick(world, par2, par3, par4, random);
- if (world.getBlockLightValue(par2, par3 + 1, par4) >= 9 && random.nextInt(7) == 0)
- {
- this.func_149879_c(world, par2, par3, par4, random);
- }
- }
- }
- /**
- * Gets the block's texture. Args: side, meta
- */
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(int side, int meta)
- {
- meta &= 7;
- return saplingIcon[MathHelper.clamp_int(meta, 0, 5)];
- }
- public void func_149879_c(World world, int par2, int par3, int par4, Random random)
- {
- int l = world.getBlockMetadata(par2, par3, par4);
- if ((l & 8) == 0)
- {
- world.setBlockMetadataWithNotify(par2, par3, par4, l | 8, 4);
- }
- else
- {
- this.func_149878_d(world, par2, par3, par4, random);
- }
- }
- public void func_149878_d(World world, int par2, int par3, int par4, Random random)
- {
- if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, random, par2, par3, par4)) return;
- int l = world.getBlockMetadata(par2, par3, par4) & 7;
- Object object = random.nextInt(10) == 0 ? new WorldGenMangoTree(mod.mangoLog, mod.mangoLeaf, 1, 1, false, 10, 15, false) : new WorldGenMangoTree(mod.mangoLog, mod.mangoLeaf, 1, 1, false, 10, 15, false);
- int i1 = 0;
- int j1 = 0;
- boolean flag = false;
- switch (l)
- {
- case 0:
- default:
- break;
- case 1:
- label78:
- for (i1 = 0; i1 >= -1; --i1)
- {
- for (j1 = 0; j1 >= -1; --j1)
- {
- if (this.func_149880_a(world, par2 + i1, par3, par4 + j1, 1) && this.func_149880_a(world, par2 + i1 + 1, par3, par4 + j1, 1) && this.func_149880_a(world, par2 + i1, par3, par4 + j1 + 1, 1) && this.func_149880_a(world, par2 + i1 + 1, par3, par4 + j1 + 1, 1))
- {
- object = new WorldGenMegaPineTree(false, random.nextBoolean());
- flag = true;
- break label78;
- }
- }
- }
- if (!flag)
- {
- j1 = 0;
- i1 = 0;
- object = new WorldGenTaiga2(true);
- }
- break;
- case 2:
- object = new WorldGenForest(true, false);
- break;
- case 3:
- label93:
- for (i1 = 0; i1 >= -1; --i1)
- {
- for (j1 = 0; j1 >= -1; --j1)
- {
- if (this.func_149880_a(world, par2 + i1, par3, par4 + j1, 3) && this.func_149880_a(world, par2 + i1 + 1, par3, par4 + j1, 3) && this.func_149880_a(world, par2 + i1, par3, par4 + j1 + 1, 3) && this.func_149880_a(world, par2 + i1 + 1, par3, par4 + j1 + 1, 3))
- {
- object = new WorldGenMegaJungle(true, 10, 20, 3, 3);
- flag = true;
- break label93;
- }
- }
- }
- if (!flag)
- {
- j1 = 0;
- i1 = 0;
- object = new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, false);
- }
- break;
- case 4:
- object = new WorldGenSavannaTree(true);
- break;
- case 5:
- label108:
- for (i1 = 0; i1 >= -1; --i1)
- {
- for (j1 = 0; j1 >= -1; --j1)
- {
- if (this.func_149880_a(world, par2 + i1, par3, par4 + j1, 5) && this.func_149880_a(world, par2 + i1 + 1, par3, par4 + j1, 5) && this.func_149880_a(world, par2 + i1, par3, par4 + j1 + 1, 5) && this.func_149880_a(world, par2 + i1 + 1, par3, par4 + j1 + 1, 5))
- {
- object = new WorldGenCanopyTree(true);
- flag = true;
- break label108;
- }
- }
- }
- if (!flag)
- {
- return;
- }
- }
- Block block = Blocks.air;
- if (flag)
- {
- world.setBlock(par2 + i1, par3, par4 + j1, block, 0, 4);
- world.setBlock(par2 + i1 + 1, par3, par4 + j1, block, 0, 4);
- world.setBlock(par2 + i1, par3, par4 + j1 + 1, block, 0, 4);
- world.setBlock(par2 + i1 + 1, par3, par4 + j1 + 1, block, 0, 4);
- }
- else
- {
- world.setBlock(par2, par3, par4, block, 0, 4);
- }
- if (!((WorldGenerator)object).generate(world, random, par2 + i1, par3, par4 + j1))
- {
- if (flag)
- {
- world.setBlock(par2 + i1, par3, par4 + j1, this, l, 4);
- world.setBlock(par2 + i1 + 1, par3, par4 + j1, this, l, 4);
- world.setBlock(par2 + i1, par3, par4 + j1 + 1, this, l, 4);
- world.setBlock(par2 + i1 + 1, par3, par4 + j1 + 1, this, l, 4);
- }
- else
- {
- world.setBlock(par2, par3, par4, this, l, 4);
- }
- }
- }
- public boolean func_149880_a(World world, int par2, int par3, int par4, int par5)
- {
- return world.getBlock(par2, par3, par4) == this && (world.getBlockMetadata(par2, par3, par4) & 7) == par5;
- }
- /**
- * Determines the damage on the item the block drops. Used in cloth and wood.
- */
- public int damageDropped(int par1)
- {
- return MathHelper.clamp_int(par1 & 7, 0, 5);
- }
- /**
- * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
- */
- @SideOnly(Side.CLIENT)
- public void getSubBlocks(Item item, CreativeTabs tabs, List list)
- {
- list.add(new ItemStack(item, 1, 0));
- }
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister icon)
- {
- for (int i = 0; i < saplingIcon.length; ++i)
- {
- saplingIcon[i] = icon.registerIcon("moem:SaplingMango");
- }
- }
- public boolean func_149851_a(World world, int par2, int par3, int par4, boolean par5)
- {
- return true;
- }
- public boolean func_149852_a(World world, Random random, int par3, int par4, int par5)
- {
- return (double)world.rand.nextFloat() < 0.45D;
- }
- public void func_149853_b(World world, Random random, int par3, int par4, int par5)
- {
- this.func_149879_c(world, par3, par4, par5, random);
- }
- }
Add Comment
Please, Sign In to add comment