spenk

BlockSeedPot

Aug 22nd, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.62 KB | None | 0 0
  1. package net.bplaced.spenk.drugmod.Blocks;
  2.  
  3. import java.util.Random;
  4.  
  5. import cpw.mods.fml.relauncher.Side;
  6. import cpw.mods.fml.relauncher.SideOnly;
  7.  
  8. import net.bplaced.spenk.drugmod.ClientProxy;
  9. import net.bplaced.spenk.drugmod.DrugsMod;
  10. import net.bplaced.spenk.drugmod.tileentities.TileEntitySeedPot;
  11. import net.minecraft.block.Block;
  12. import net.minecraft.block.BlockContainer;
  13. import net.minecraft.block.material.Material;
  14. import net.minecraft.client.renderer.texture.IconRegister;
  15. import net.minecraft.creativetab.CreativeTabs;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.item.Item;
  18. import net.minecraft.item.ItemStack;
  19. import net.minecraft.tileentity.TileEntity;
  20. import net.minecraft.util.AxisAlignedBB;
  21. import net.minecraft.util.Icon;
  22. import net.minecraft.world.World;
  23. import net.minecraftforge.common.EnumPlantType;
  24. import net.minecraftforge.common.ForgeDirection;
  25. import net.minecraftforge.common.IPlantable;
  26.  
  27. public class BlockSeedpot extends Block {
  28.  
  29.     public BlockSeedpot(int i) {
  30.         super(i, Material.circuits);
  31.         setBlockConfigurations();
  32.         setBlockBoundsForItemRender();
  33.     }
  34.  
  35.     private void setBlockConfigurations() {
  36.         setUnlocalizedName("BlockSeedPot");
  37.         func_111022_d("drugmod:Seedpot");
  38.         setStepSound(Block.soundPowderFootstep);
  39.         setHardness(0F).setResistance(0.1F);
  40.         setCreativeTab(null);
  41.     }
  42.    
  43.     public void setBlockBoundsForItemRender()
  44.     {
  45.         float f = 0.375F;
  46.         float f1 = f / 2.0F;
  47.         this.setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, f, 0.5F + f1);
  48.     }
  49.      
  50.     public boolean renderAsNormalBlock() {
  51.         return false;
  52.     }
  53.  
  54.     public int getRenderType() {
  55.         return ClientProxy.seedPotRender;
  56.     }
  57.  
  58.     public boolean isOpaqueCube() {
  59.         return false;
  60.     }
  61.  
  62.     public int getRenderBlockPass() {
  63.         return 1;
  64.     }
  65.    
  66.     public boolean canRenderInPass(int pass) {
  67.         ClientProxy.renderPass = pass;
  68.         return true;
  69.     }
  70.    
  71.     public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
  72.         super.updateTick(par1World, par2, par3, par4, par5Random);
  73.         System.out.println("===============HERPDERP===============");
  74.     }
  75.    
  76.     public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
  77.     {
  78.         ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem();
  79.  
  80.         if (itemstack == null)
  81.         {
  82.             return false;
  83.         }
  84.         else if (par1World.getBlockMetadata(par2, par3, par4) != 0)
  85.         {
  86.             return false;
  87.         }
  88.         else
  89.         {
  90.             int i1 = getMetaForPlant(itemstack);
  91.  
  92.             if (i1 > 0)
  93.             {
  94.                 par1World.playSoundEffect((double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), Block.cactus.stepSound.getPlaceSound(), (Block.cactus.stepSound.getVolume() + 1.0F) / 2.0F, Block.cactus.stepSound.getPitch() * 0.8F);
  95.                 par1World.setBlockMetadataWithNotify(par2, par3, par4, i1, 2);
  96.                 if (!par5EntityPlayer.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
  97.                 {
  98.                     par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, (ItemStack)null);
  99.                 }
  100.  
  101.                 return true;
  102.             }
  103.             else
  104.             {
  105.                 return false;
  106.             }
  107.         }
  108.     }
  109.  
  110.     @SideOnly(Side.CLIENT)
  111.  
  112.     public int idPicked(World par1World, int par2, int par3, int par4)
  113.     {
  114.         ItemStack itemstack = getPlantForMeta(par1World.getBlockMetadata(par2, par3, par4));
  115.         return itemstack == null ? DrugsMod.itemSeedpot.itemID : itemstack.itemID;
  116.     }
  117.  
  118.     public int getDamageValue(World par1World, int par2, int par3, int par4)
  119.     {
  120.         ItemStack itemstack = getPlantForMeta(par1World.getBlockMetadata(par2, par3, par4));
  121.         return itemstack == null ? DrugsMod.itemSeedpot.itemID : itemstack.getItemDamage();
  122.     }
  123.  
  124.     @SideOnly(Side.CLIENT)
  125.  
  126.     public boolean isFlowerPot()
  127.     {
  128.         return true;
  129.     }
  130.  
  131.     public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
  132.     {
  133.         return super.canPlaceBlockAt(par1World, par2, par3, par4) && par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4);
  134.     }
  135.  
  136.     public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
  137.     {
  138.         if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
  139.         {
  140.             this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
  141.             par1World.setBlockToAir(par2, par3, par4);
  142.         }
  143.     }
  144.  
  145.     public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
  146.     {
  147.         super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7);
  148.  
  149.         if (par5 > 0)
  150.         {
  151.             ItemStack itemstack = getPlantForMeta(par5);
  152.  
  153.             if (itemstack != null)
  154.             {
  155.                 this.dropBlockAsItem_do(par1World, par2, par3, par4, itemstack);
  156.             }
  157.         }
  158.     }
  159.  
  160.     public int idDropped(int par1, Random par2Random, int par3)
  161.     {
  162.         return DrugsMod.itemSeedpot.itemID;
  163.     }
  164.  
  165.     public static ItemStack getPlantForMeta(int par0) {
  166.         switch (par0) {
  167.         default:
  168.             return null;
  169.         case 1:
  170.             return new ItemStack(DrugsMod.itemCanabisPlant);
  171.         }
  172.     }
  173.  
  174.     public static int getMetaForPlant(ItemStack par0ItemStack) {
  175.         int i = par0ItemStack.getItem().itemID;
  176.  
  177.         if (i == DrugsMod.itemCanabisSeed.itemID) {
  178.             return 1;
  179.         }
  180.  
  181.         return 0;
  182.     }
  183. }
Advertisement
Add Comment
Please, Sign In to add comment