Guest User

Mon block

a guest
Aug 6th, 2017
29
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.lavapower.harmonia.common.blocks;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import fr.lavapower.harmonia.common.ModHarmonia;
  6. import net.minecraft.block.BlockBush;
  7. import net.minecraft.block.material.Material;
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.entity.item.EntityItem;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.item.ItemStack;
  12. import net.minecraft.util.DamageSource;
  13. import net.minecraft.world.ColorizerGrass;
  14. import net.minecraft.world.World;
  15.  
  16. public class OrtieBlock extends BlockBush
  17. {
  18.  
  19. public OrtieBlock(Material leaves)
  20. {
  21. super(leaves);
  22. setCreativeTab(ModHarmonia.HarmoniaCreativeTabs);
  23. }
  24.  
  25. public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
  26. {
  27. int lower = 1;
  28. int higher = 11;
  29.  
  30. int random = (int)(Math.random() * (higher - lower)) + lower;
  31. if(random == 2)
  32. {
  33. if(!world.isRemote)
  34. {
  35. EntityItem item = new EntityItem(world, x, y, z, new ItemStack(ModHarmonia.ortie, 1));
  36. world.spawnEntityInWorld(item);
  37. return true;
  38. }
  39. return false;
  40. }
  41. return false;
  42. }
  43.  
  44. public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
  45. {
  46. entity.attackEntityFrom(DamageSource.cactus, 2.0F);
  47. }
  48. }
RAW Paste Data