Guest User

PapCrop

a guest
Dec 22nd, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. package com.morefood.mod.crops;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Random;
  5.  
  6. import com.morefood.mod.Morefood;
  7.  
  8. import cpw.mods.fml.relauncher.Side;
  9. import cpw.mods.fml.relauncher.SideOnly;
  10. import net.minecraft.block.BlockCrops;
  11. import net.minecraft.client.renderer.texture.IIconRegister;
  12. import net.minecraft.init.Items;
  13. import net.minecraft.item.Item;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.util.IIcon;
  16. import net.minecraft.world.IBlockAccess;
  17. import net.minecraft.world.World;
  18. import net.minecraftforge.common.EnumPlantType;
  19.  
  20. public class PapCrop extends BlockCrops
  21. {
  22. @SideOnly(Side.CLIENT)
  23. private IIcon[] iconArray;
  24.  
  25. @Override
  26. public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)
  27. {
  28. return EnumPlantType.Crop;
  29. }
  30.  
  31. @Override
  32. public Item getItemDropped(int stage, Random random, int j)
  33. {
  34. return customGetDropFunction(stage);
  35. }
  36.  
  37. public Item customGetDropFunction(int stage) {
  38. if (stage == 4) {
  39. return Morefood.cropGreenPaprika;
  40. }else if (stage == 5){
  41. return Morefood.cropYellowPaprika;
  42. }else if (stage == 7){
  43. return Morefood.cropRedPaprika;
  44. }else{
  45. return (Morefood.cropPaprikaSeeds);
  46. }
  47. }
  48.  
  49. public int quantityDropped(Random p_149745_1_)
  50. {
  51. return 0;
  52. }
  53.  
  54. @Override
  55. public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
  56. {
  57. ArrayList<ItemStack> ret = super.getDrops(world, x, y, z, metadata, fortune);
  58.  
  59. if (metadata >= 7)
  60. {
  61. for (int i = 0; i < 3 + fortune; ++i)
  62. {
  63. if (world.rand.nextInt(15) <= metadata)
  64. {
  65. ret.add(new ItemStack(this.customGetDropFunction(4), 3, 0));
  66. ret.add(new ItemStack(this.customGetDropFunction(5), 3, 0));
  67. ret.add(new ItemStack(this.customGetDropFunction(7), 3, 0));
  68. }
  69. }
  70. }
  71.  
  72. return ret;
  73. }
  74.  
  75. protected Item func_149866_i()
  76. {
  77. return null;
  78. }
  79.  
  80. protected Item func_149865_P()
  81. {
  82. return null;
  83. }
  84.  
  85. /**
  86. * Gets the block's texture. Args: side, meta
  87. */
  88. @SideOnly(Side.CLIENT)
  89. public IIcon getIcon(int side, int metadata)
  90. {
  91. if (metadata < 7)
  92. {
  93. return this.iconArray[metadata];
  94. }
  95. else
  96. {
  97. return this.iconArray[6];
  98. }
  99. }
  100.  
  101. @SideOnly(Side.CLIENT)
  102. public Item getItem(World world, int i, int j, int k)
  103. {
  104. return Morefood.cropPaprikaSeeds;
  105. }
  106.  
  107. @SideOnly(Side.CLIENT)
  108. public void registerBlockIcons(IIconRegister iconRegister)
  109. {
  110. this.iconArray = new IIcon[7];
  111.  
  112. for (int i = 0; i < this.iconArray.length; ++i)
  113. {
  114. this.iconArray[i] = iconRegister.registerIcon(Morefood.modid + ":" + this.getUnlocalizedName().substring(5) + (i + 1));
  115. }
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment