omegastar12311

biome code

Sep 4th, 2017
207
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import net.minecraftforge.fml.relauncher.SideOnly;
  2. import net.minecraftforge.fml.relauncher.Side;
  3. import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
  4. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  5. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  6. import net.minecraftforge.common.BiomeManager;
  7. import net.minecraftforge.common.BiomeDictionary;
  8.  
  9. import net.minecraft.world.gen.feature.WorldGenAbstractTree;
  10. import net.minecraft.world.biome.Biome;
  11. import net.minecraft.world.World;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraft.util.ResourceLocation;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.init.Blocks;
  16. import net.minecraft.block.state.IBlockState;
  17. import net.minecraft.block.Block;
  18.  
  19. import java.util.Random;
  20.  
  21. public class mcreator_cartoonbiome {
  22.  
  23. static Biome.BiomeProperties customProps = null;
  24. public static BiomeGencartoonbiome biome = null;
  25.  
  26. static {
  27. customProps = new Biome.BiomeProperties("cartoonbiome");
  28. customProps.setRainfall(0.2F);
  29. customProps.setBaseHeight(0.1F);
  30. customProps.setHeightVariation(0.3F);
  31. customProps.setWaterColor(0xc2fff9);
  32. biome = new BiomeGencartoonbiome(customProps);
  33. }
  34.  
  35. public static Object instance;
  36.  
  37. public mcreator_cartoonbiome() {
  38. }
  39.  
  40. public void load(FMLInitializationEvent event) {
  41. Biome.REGISTRY.register(46, new ResourceLocation("cartoonbiome"), biome);
  42. BiomeDictionary.addTypes(biome, BiomeDictionary.Type.FOREST);
  43. BiomeManager.addSpawnBiome(biome);
  44. BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(biome, 1024));
  45. }
  46.  
  47. public void generateNether(World world, Random random, int chunkX, int chunkZ) {
  48. }
  49.  
  50. public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
  51. }
  52.  
  53. public void registerRenderers() {
  54. }
  55.  
  56. public int addFuel(ItemStack fuel) {
  57. return 0;
  58. }
  59.  
  60. public void serverLoad(FMLServerStartingEvent event) {
  61. }
  62.  
  63. public void preInit(FMLPreInitializationEvent event) {
  64. }
  65.  
  66. static class BiomeGencartoonbiome extends Biome {
  67. @SuppressWarnings("unchecked")
  68. public BiomeGencartoonbiome(Biome.BiomeProperties mycustomProps) {
  69. super(mycustomProps);
  70. topBlock = mcreator_cartoongress.block.getDefaultState();
  71. fillerBlock = mcreator_cartoondirt.block.getDefaultState();
  72. theBiomeDecorator.generateLakes = true;
  73. theBiomeDecorator.treesPerChunk = 230;
  74. theBiomeDecorator.flowersPerChunk = 20;
  75. theBiomeDecorator.grassPerChunk = 300;
  76. theBiomeDecorator.deadBushPerChunk = 0;
  77. theBiomeDecorator.mushroomsPerChunk = 0;
  78. theBiomeDecorator.reedsPerChunk = 0;
  79. theBiomeDecorator.cactiPerChunk = 0;
  80. theBiomeDecorator.sandPerChunk = 0;
  81.  
  82. }
  83.  
  84. @Override
  85. public WorldGenAbstractTree genBigTreeChance(Random rand) {
  86. return new Tree();
  87. }
  88.  
  89. class Tree extends WorldGenAbstractTree {
  90. /** The minimum height of a generated tree. */
  91. private final int minTreeHeight;
  92.  
  93. /** True if this tree should grow Vines. */
  94. private final boolean vinesGrow;
  95.  
  96. /** The metadata value of the wood to use in tree generation. */
  97. private final int metaWood;
  98.  
  99. /** The metadata value of the leaves to use in tree generation. */
  100. private final int metaLeaves;
  101.  
  102. public Tree() {
  103. super(false);
  104. this.minTreeHeight = 3;
  105. this.metaWood = 0;
  106. this.metaLeaves = 0;
  107. this.vinesGrow = true;
  108. }
  109.  
  110. public boolean generate(World par1World, Random par2Random, BlockPos pos) {
  111. int par3 = pos.getX();
  112. int par4 = pos.getY();
  113. int par5 = pos.getZ();
  114. int var6 = par2Random.nextInt(3) + this.minTreeHeight;
  115. boolean var7 = true;
  116.  
  117. if (par4 >= 1 && par4 + var6 + 1 <= 256) {
  118. int var8;
  119. byte var9;
  120. int var11;
  121. int var12;
  122.  
  123. for (var8 = par4; var8 <= par4 + 1 + var6; ++var8) {
  124. var9 = 1;
  125.  
  126. if (var8 == par4) {
  127. var9 = 0;
  128. }
  129.  
  130. if (var8 >= par4 + 1 + var6 - 2) {
  131. var9 = 2;
  132. }
  133.  
  134. for (int var10 = par3 - var9; var10 <= par3 + var9 && var7; ++var10) {
  135. for (var11 = par5 - var9; var11 <= par5 + var9 && var7; ++var11) {
  136. if (var8 >= 0 && var8 < 256) {
  137. Block var12s = par1World.getBlockState(new BlockPos(var10, var8, var11)).getBlock();
  138. var12 = Block.getIdFromBlock(var12s);
  139.  
  140. if (var12 != 0 && var12s != mcreator_cartoonvine.block && var12s != mcreator_cartoongress.block
  141. && var12s != mcreator_cartoondirt.block && var12s != mcreator_cartoonwood.block) {
  142. var7 = false;
  143. }
  144. } else {
  145. var7 = false;
  146. }
  147. }
  148. }
  149. }
  150.  
  151. if (!var7) {
  152. return false;
  153. } else {
  154. Block var8s = par1World.getBlockState(new BlockPos(par3, par4 - 1, par5)).getBlock();
  155. var8 = Block.getIdFromBlock(var8s);
  156.  
  157. if ((var8s == mcreator_cartoongress.block || var8s == mcreator_cartoondirt.block) && par4 < 256 - var6 - 1) {
  158. par1World.setBlockState(new BlockPos(par3, par4 - 1, par5), mcreator_cartoondirt.block.getDefaultState(), 3);
  159. var9 = 3;
  160. byte var18 = 0;
  161. int var13;
  162. int var14;
  163. int var15;
  164.  
  165. for (var11 = par4 - var9 + var6; var11 <= par4 + var6; ++var11) {
  166. var12 = var11 - (par4 + var6);
  167. var13 = var18 + 1 - var12 / 2;
  168.  
  169. for (var14 = par3 - var13; var14 <= par3 + var13; ++var14) {
  170. var15 = var14 - par3;
  171.  
  172. for (int var16 = par5 - var13; var16 <= par5 + var13; ++var16) {
  173. int var17 = var16 - par5;
  174.  
  175. if ((Math.abs(var15) != var13 || Math.abs(var17) != var13 || par2Random.nextInt(2) != 0 && var12 != 0)) {
  176. par1World.setBlockState(new BlockPos(var14, var11, var16),
  177. mcreator_cartoonleaves.block.getDefaultState(), 3);
  178. }
  179. }
  180. }
  181. }
  182.  
  183. for (var11 = 0; var11 < var6; ++var11) {
  184. Block var12s = par1World.getBlockState(new BlockPos(par3, par4 + var11, par5)).getBlock();
  185. var12 = Block.getIdFromBlock(var12s);
  186.  
  187. if (var12 == 0 || var12s == mcreator_cartoonleaves.block) {
  188. par1World.setBlockState(new BlockPos(par3, par4 + var11, par5), mcreator_cartoonwood.block.getDefaultState(), 3);
  189.  
  190. if (this.vinesGrow && var11 > 0) {
  191. if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(new BlockPos(par3 - 1, par4 + var11, par5))) {
  192. par1World.setBlockState(new BlockPos(par3 - 1, par4 + var11, par5),
  193. mcreator_cartoonvine.block.getDefaultState(), 3);
  194. }
  195.  
  196. if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(new BlockPos(par3 + 1, par4 + var11, par5))) {
  197. par1World.setBlockState(new BlockPos(par3 + 1, par4 + var11, par5),
  198. mcreator_cartoonvine.block.getDefaultState(), 3);
  199. }
  200.  
  201. if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(new BlockPos(par3, par4 + var11, par5 - 1))) {
  202. par1World.setBlockState(new BlockPos(par3, par4 + var11, par5 - 1),
  203. mcreator_cartoonvine.block.getDefaultState(), 3);
  204. }
  205.  
  206. if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(new BlockPos(par3, par4 + var11, par5 + 1))) {
  207. par1World.setBlockState(new BlockPos(par3, par4 + var11, par5 + 1),
  208. mcreator_cartoonvine.block.getDefaultState(), 3);
  209. }
  210. }
  211. }
  212. }
  213.  
  214. if (this.vinesGrow) {
  215. for (var11 = par4 - 3 + var6; var11 <= par4 + var6; ++var11) {
  216. var12 = var11 - (par4 + var6);
  217. var13 = 2 - var12 / 2;
  218.  
  219. for (var14 = par3 - var13; var14 <= par3 + var13; ++var14) {
  220. for (var15 = par5 - var13; var15 <= par5 + var13; ++var15) {
  221. if (par1World.getBlockState(new BlockPos(var14, var11, var15)).getBlock() == mcreator_cartoonleaves.block) {
  222. if (par2Random.nextInt(4) == 0
  223. && Block.getIdFromBlock(par1World.getBlockState(new BlockPos(var14 - 1, var11, var15))
  224. .getBlock()) == 0) {
  225. this.growVines(par1World, var14 - 1, var11, var15, 8);
  226. }
  227.  
  228. if (par2Random.nextInt(4) == 0
  229. && Block.getIdFromBlock(par1World.getBlockState(new BlockPos(var14 + 1, var11, var15))
  230. .getBlock()) == 0) {
  231. this.growVines(par1World, var14 + 1, var11, var15, 2);
  232. }
  233.  
  234. if (par2Random.nextInt(4) == 0
  235. && Block.getIdFromBlock(par1World.getBlockState(new BlockPos(var14, var11, var15 - 1))
  236. .getBlock()) == 0) {
  237. this.growVines(par1World, var14, var11, var15 - 1, 1);
  238. }
  239.  
  240. if (par2Random.nextInt(4) == 0
  241. && Block.getIdFromBlock(par1World.getBlockState(new BlockPos(var14, var11, var15 + 1))
  242. .getBlock()) == 0) {
  243. this.growVines(par1World, var14, var11, var15 + 1, 4);
  244. }
  245. }
  246. }
  247. }
  248. }
  249.  
  250. if (par2Random.nextInt(5) == 0 && var6 > 5) {
  251. for (var11 = 0; var11 < 2; ++var11) {
  252. for (var12 = 0; var12 < 4; ++var12) {
  253. if (par2Random.nextInt(4 - var11) == 0) {
  254. var13 = par2Random.nextInt(3);
  255. par1World.setBlockState(new BlockPos(par3, par4 + var6 - 5 + var11, par5),
  256. Blocks.MELON_BLOCK.getDefaultState(), 3);
  257. }
  258. }
  259. }
  260. }
  261. }
  262.  
  263. return true;
  264. } else {
  265. return false;
  266. }
  267. }
  268. } else {
  269. return false;
  270. }
  271. }
  272.  
  273. /**
  274. * Grows vines downward from the given block for a given length.
  275. * Args: World, x, starty, z, vine-length
  276. */
  277. private void growVines(World par1World, int par2, int par3, int par4, int par5) {
  278. par1World.setBlockState(new BlockPos(par2, par3, par4), mcreator_cartoonvine.block.getDefaultState(), 3);
  279. int var6 = 4;
  280.  
  281. while (true) {
  282. --par3;
  283.  
  284. if (Block.getIdFromBlock(par1World.getBlockState(new BlockPos(par2, par3, par4)).getBlock()) != 0 || var6 <= 0) {
  285. return;
  286. }
  287.  
  288. par1World.setBlockState(new BlockPos(par2, par3, par4), mcreator_cartoonvine.block.getDefaultState(), 3);
  289. --var6;
  290. }
  291. }
  292.  
  293. protected boolean canGrowInto(Block blockType) {
  294. return true;
  295. }
  296.  
  297. public void generateSaplings(World worldIn, Random random, BlockPos pos) {
  298. }
  299.  
  300. /**
  301. * sets dirt at a specific location if it isn't already dirt
  302. */
  303. protected void setDirtAt(World worldIn, BlockPos pos) {
  304. if (worldIn.getBlockState(pos).getBlock() != Blocks.DIRT) {
  305. this.setBlockAndNotifyAdequately(worldIn, pos, Blocks.DIRT.getDefaultState());
  306. }
  307. }
  308.  
  309. public boolean isReplaceable(World world, BlockPos pos) {
  310. net.minecraft.block.state.IBlockState state = world.getBlockState(pos);
  311. return state.getBlock().isAir(state, world, pos) || state.getBlock().isLeaves(state, world, pos)
  312. || state.getBlock().isWood(world, pos) || canGrowInto(state.getBlock());
  313. }
  314.  
  315. }
  316.  
  317. @SideOnly(Side.CLIENT)
  318. @Override
  319. public int getGrassColorAtPos(BlockPos pos) {
  320. return 0x158400;
  321. }
  322.  
  323. @SideOnly(Side.CLIENT)
  324. @Override
  325. public int getFoliageColorAtPos(BlockPos pos) {
  326. return 0x158400;
  327. }
  328.  
  329. @SideOnly(Side.CLIENT)
  330. @Override
  331. public int getSkyColorByTemp(float currentTemperature) {
  332. return 0x00ffe0;
  333. }
  334.  
  335. }
  336.  
  337. }
RAW Paste Data