Advertisement
MintTheFox

seed bag

Dec 16th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.82 KB | None | 0 0
  1. package mint.mintmats.items;
  2.  
  3. import mint.mintmats.core.ClientProxy;
  4. import net.minecraft.block.Block;
  5. import net.minecraft.creativetab.CreativeTabs;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.world.World;
  10.  
  11. public class itemGrassSeedBag extends Item
  12. {
  13.     public itemGrassSeedBag(int id)
  14.     {
  15.         super(id);
  16.         this.setMaxStackSize(64);
  17.         this.setCreativeTab(CreativeTabs.tabMaterials);
  18.     }
  19.  
  20.     @Override
  21.     public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10)
  22.     {
  23.         int detectedBlock = world.getBlockId(x, y, z);
  24.        
  25.         if(detectedBlock == Block.dirt.blockID)
  26.         {
  27.             boolean planted = false;
  28.             for (int posX = x - 2; posX <= x + 2; posX++)
  29.             {
  30.                 for (int posZ = z - 2; posZ <= z + 2; posZ++)
  31.                 {
  32.                     if (player.canPlayerEdit(posX, y, posZ, side, stack))
  33.                     {
  34.                         if (world.getBlockId(posX, y, posZ) == Block.dirt.blockID)
  35.                         {
  36.                             world.setBlockWithNotify(posX, y, posZ, Block.grass.blockID);
  37.                             planted = true;
  38.                         }
  39.                     }
  40.                 }
  41.             }
  42.        
  43.             if (planted)
  44.             {
  45.                 if (!player.capabilities.isCreativeMode){stack.stackSize--;}
  46.                
  47.                 if (!world.isRemote)
  48.                 {
  49.                     for (int posX = x - 2; posX <= x + 2; posX++)
  50.                     {
  51.                         for (int posZ = z - 2; posZ <= z + 2; posZ++)
  52.                         {
  53.                             world.playAuxSFX(2001, posX, y, posZ, Block.leaves.blockID);
  54.                         }
  55.                     }
  56.                    
  57.                 return planted;
  58.                
  59.                 }
  60.             }
  61.         }
  62.        
  63.         return false;
  64.     }
  65.  
  66.     public String getTextureFile()
  67.     {
  68.         return ClientProxy.itemTex;
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement