Advertisement
drackiseries

A New Flower

Jul 27th, 2012
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.28 KB | None | 0 0
  1. MOD_FILE CONTENTS:
  2.  
  3. package net.minecraft.src;
  4.  
  5. import java.util.Random;
  6.  
  7. public class mod_tutorial extends BaseMod
  8. {
  9.  
  10.  
  11.  
  12. //Textures
  13.  
  14. //Blocks
  15.  
  16. public static final Block SoulFlower = (BlockSoulFlowers)(new BlockSoulFlowers(211, ModLoader.addOverride("/terrain.png","/Blocks/soulflower.png"))).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setBlockName("SoulFlower");
  17.  
  18. //Tree Blocks
  19.  
  20. //Very Complex Blocks
  21.  
  22. //Items
  23.  
  24. public void load()
  25. {
  26.  
  27. //Registering
  28.  
  29. ModLoader.registerBlock(SoulFlower);
  30.  
  31. //Adding names
  32.  
  33. ModLoader.addName(SoulFlower, "Soul Flower");
  34.  
  35. //Tile Entity
  36.  
  37. //Biomes
  38.  
  39. ModLoader.addBiome(BiomeGenBase.souldesert);
  40.  
  41. //Crafting Recipes
  42.  
  43. //Smelting Recipes
  44.  
  45. //Shapeless Recipes
  46.  
  47.  
  48. }
  49.  
  50. public String getVersion()
  51. {
  52. return "1.2.5";
  53. }
  54. }
  55.  
  56. BLOCKSOULFLOWERS FILE:
  57.  
  58.  
  59. package net.minecraft.src;
  60.  
  61. import java.util.Random;
  62.  
  63. public class BlockSoulFlowers extends Block
  64. {
  65. protected BlockSoulFlowers(int par1, int par2, Material par3Material)
  66. {
  67. super(par1, par3Material);
  68. blockIndexInTexture = par2;
  69. setTickRandomly(true);
  70. float f = 0.2F;
  71. setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3F, 0.5F + f);
  72. }
  73.  
  74. protected BlockSoulFlowers(int par1, int par2)
  75. {
  76. this(par1, par2, Material.plants);
  77. }
  78.  
  79. /**
  80. * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
  81. */
  82. public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
  83. {
  84. return super.canPlaceBlockAt(par1World, par2, par3, par4) && canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
  85. }
  86.  
  87. /**
  88. * Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
  89. * blockID passed in. Args: blockID
  90. */
  91. protected boolean canThisPlantGrowOnThisBlockID(int par1)
  92. {
  93. return par1 == Block.slowSand.blockID;
  94. }
  95.  
  96. /**
  97. * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
  98. * their own) Args: x, y, z, neighbor blockID
  99. */
  100.  
  101. /**
  102. * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
  103. */
  104. public boolean canBlockStay(World par1World, int par2, int par3, int par4)
  105. {
  106. return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
  107. }
  108.  
  109. /**
  110. * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
  111. * cleared to be reused)
  112. */
  113. public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int i)
  114. {
  115. return null;
  116. }
  117.  
  118. /**
  119. * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
  120. * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
  121. */
  122. public boolean isOpaqueCube()
  123. {
  124. return false;
  125. }
  126.  
  127. /**
  128. * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
  129. */
  130. public boolean renderAsNormalBlock()
  131. {
  132. return false;
  133. }
  134.  
  135. /**
  136. * The type of render function that is called for this block
  137. */
  138. public int getRenderType()
  139. {
  140. return 1;
  141. }
  142. }
  143.  
  144. WORLDGENSOULFLOWERS FILE:
  145.  
  146.  
  147. package net.minecraft.src;
  148.  
  149. import java.util.Random;
  150.  
  151. public class WorldGenSoulFlowers extends WorldGenerator
  152. {
  153. /** The ID of the plant block used in this plant generator. */
  154. private int plantBlockId;
  155.  
  156. public WorldGenSoulFlowers(int par1)
  157. {
  158. plantBlockId = par1;
  159. }
  160.  
  161. public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
  162. {
  163. for (int i = 0; i < 64; i++)
  164. {
  165. int j = (par3 + par2Random.nextInt(8)) - par2Random.nextInt(8);
  166. int k = (par4 + par2Random.nextInt(4)) - par2Random.nextInt(4);
  167. int l = (par5 + par2Random.nextInt(8)) - par2Random.nextInt(8);
  168.  
  169. if (par1World.isAirBlock(j, k, l) && mod_tutorial.SoulFlower.canBlockStay(par1World, j, k, l))
  170. {
  171. par1World.setBlock(j, k, l, plantBlockId);
  172. }
  173. }
  174.  
  175. return true;
  176. }
  177. }
  178.  
  179. BIOMEDECORATOR STUFF:
  180.  
  181. // ADD THIS OUTSIDE OF PUBLIC BIOMEDECORATOR(BiomeGenBasepar1BiomeGenBase)
  182. protected int soulflowersperchunk;
  183. protected WorldGenerator soulflowerGen
  184.  
  185. // ADD THIS INSIDE OF PUBLIC BIOMEDECORATOR(BiomeGenBasepar1BiomeGenBase)
  186. soulflowerGen = new WorldGenSoulFlowers(mod_tutorial.SoulFlower.blockID);
  187. soulflowersperchunk = 0;
  188.  
  189.  
  190.  
  191. ADD THIS TO THE DECORATE METHOD:
  192. for(int q = 0; q < soulflowersperchunk; q++)
  193. {
  194. int q1 = chunk_X + randomGenerator.nextInt(16) + 8;
  195. int q2 = randomGenerator.nextInt(128);
  196. int q3 = chunk_Z + randomGenerator.nextInt(16) + 8;
  197. soulflowerGen.generate(currentWorld, randomGenerator, q1, q2, q3);
  198.  
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement