Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.bplaced.spenk.drugmod.Blocks;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import java.util.ArrayList;
- import java.util.Random;
- import net.bplaced.spenk.drugmod.DrugsMod;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockCrops;
- import net.minecraft.block.BlockFlower;
- import net.minecraft.client.renderer.texture.IconRegister;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.Icon;
- import net.minecraft.util.MathHelper;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- import net.minecraftforge.common.ForgeDirection;
- public class BlockPotCanabis extends BlockCrops
- {
- @SideOnly(Side.CLIENT)
- private Icon[] iconArray;
- public BlockPotCanabis(int par1)
- {
- super(par1);
- this.setTickRandomly(true);
- float f = 0.125F;
- this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
- this.setCreativeTab(null);
- }
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) {
- return null;
- }
- @Override
- public boolean isOpaqueCube () {
- return false;
- }
- protected boolean canThisPlantGrowOnThisBlockID(int par1)
- {
- return par1 == DrugsMod.blockSeedpot.blockID;
- }
- public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
- {
- super.updateTick(par1World, par2, par3, par4, par5Random);
- System.out.println("===============SCHEDULED===============");
- if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 12)
- {
- float f = this.getGrowthModifier(par1World, par2, par3, par4);
- if (par5Random.nextInt((int)(25.0F / f) + 1) == 0)
- {
- int l = par1World.getBlockMetadata(par2, par3, par4);
- if (l < 3)//TODO
- {
- ++l;
- par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);
- }
- }
- }
- }
- private float getGrowthModifier(World par1World, int par2, int par3, int par4)
- {
- float f = 1.0F;
- int l = par1World.getBlockId(par2, par3, par4 - 1);
- int i1 = par1World.getBlockId(par2, par3, par4 + 1);
- int j1 = par1World.getBlockId(par2 - 1, par3, par4);
- int k1 = par1World.getBlockId(par2 + 1, par3, par4);
- int l1 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
- int i2 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
- int j2 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
- int k2 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
- boolean flag = j1 == this.blockID || k1 == this.blockID;
- boolean flag1 = l == this.blockID || i1 == this.blockID;
- boolean flag2 = l1 == this.blockID || i2 == this.blockID || j2 == this.blockID || k2 == this.blockID;
- for (int l2 = par2 - 1; l2 <= par2 + 1; ++l2)
- {
- for (int i3 = par4 - 1; i3 <= par4 + 1; ++i3)
- {
- int j3 = par1World.getBlockId(l2, par3 - 1, i3);
- float f1 = 0.0F;
- if (blocksList[j3] != null && blocksList[j3].canSustainPlant(par1World, l2, par3 - 1, i3, ForgeDirection.UP, this))
- {
- f1 = 1.0F;
- if (blocksList[j3].isFertile(par1World, l2, par3 - 1, i3))
- {
- f1 = 3.0F;
- }
- }
- if (l2 != par2 || i3 != par4)
- {
- f1 /= 4.0F;
- }
- f += f1;
- }
- }
- if (flag2 || flag && flag1)
- {
- f /= 2.0F;
- }
- return f;
- }
- /* public void setBlockBoundsForItemRender()
- {
- float f = 0.125F;
- this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
- }
- public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
- {
- this.maxY = (double)((float)(par1IBlockAccess.getBlockMetadata(par2, par3, par4) * 2 + 2) / 16.0F);
- float f = 0.125F;
- this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, (float)this.maxY, 0.5F + f);
- }*/
- public int getRenderType()
- {
- return 1;
- }
- public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
- {
- super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7);
- }
- public int idDropped(int par1, Random par2Random, int par3)
- {
- return par3 == 3 ? DrugsMod.itemCanabisPlant.itemID : -1;
- }
- public int quantityDropped(Random par1Random)
- {
- return 1;
- }
- @SideOnly(Side.CLIENT)
- public int idPicked(World par1World, int par2, int par3, int par4)
- {
- return par1World.getBlockMetadata(par2, par3, par4) == 3 ? DrugsMod.itemCanabisPlant.itemID : DrugsMod.itemCanabisPlant.itemID;
- }
- public Icon getIcon(int par1, int par2)
- {
- if (par2 < 0 || par2 > 3)
- {
- par2 = 3;
- }
- System.out.println(par2);
- return this.iconArray[par2];
- }
- @SideOnly(Side.CLIENT)
- public void registerIcons(IconRegister par1IconRegister)
- {
- this.iconArray = new Icon[4];
- for (int i = 0; i < this.iconArray.length; i++)
- {
- this.iconArray[i] = par1IconRegister.registerIcon("drugmod:canabis" + i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment