Guest User

Untitled

a guest
May 28th, 2014
307
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package net.CaveBiomes.main;
  2.  
  3. import java.lang.reflect.Field;
  4.  
  5. import com.google.common.base.Throwables;
  6. import com.google.common.collect.ObjectArrays;
  7.  
  8. import net.CaveBiomes.biomes.DesertCave;
  9. import net.CaveBiomes.items.GlowShroom;
  10. import net.minecraft.item.Item;
  11. import net.minecraft.world.biome.BiomeGenBase;
  12. import net.minecraft.world.gen.layer.CaveBiomesGenLayerAccessor;
  13. import net.minecraft.world.gen.layer.GenLayer;
  14. import net.minecraft.world.gen.layer.GenLayerBiome;
  15. import net.minecraft.world.gen.layer.GenLayerRiverMix;
  16. import net.minecraftforge.common.MinecraftForge;
  17. import net.minecraftforge.event.terraingen.WorldTypeEvent;
  18. import cpw.mods.fml.common.Mod;
  19. import cpw.mods.fml.common.Mod.EventHandler;
  20. import cpw.mods.fml.common.event.FMLInitializationEvent;
  21. import cpw.mods.fml.common.event.FMLPostInitializationEvent;
  22. import cpw.mods.fml.common.event.FMLPreInitializationEvent;
  23. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  24. import cpw.mods.fml.common.registry.GameRegistry;
  25. import cpw.mods.fml.common.registry.LanguageRegistry;
  26. import net.minecraftforge.event.terraingen.WorldTypeEvent;
  27.  
  28. @Mod(modid = CaveBiomes.modid, version = CaveBiomes.version)
  29.  
  30. public class CaveBiomes<itemGlowShroom> {
  31.  
  32. public static final String modid = "CaveBiomes";
  33. public static final String version = "1.7.2";
  34.  
  35. //Items
  36. public static Item itemGlowShroom;
  37. //biomes
  38. public static BiomeGenBase DesertCave = new DesertCave(34).setBiomeName("DesertCave");
  39.  
  40.  
  41. @EventHandler
  42. public void Init(FMLInitializationEvent preEvent){
  43.  
  44. //Item Registry
  45. itemGlowShroom = new GlowShroom().setUnlocalizedName("GlowShroom");
  46. GameRegistry.registerItem(itemGlowShroom, "Glow Shroom");
  47. LanguageRegistry.addName(itemGlowShroom, "Glow Shroom");
  48.  
  49.  
  50. //Biome Registry
  51.  
  52. ;
  53.  
  54.  
  55. }
  56.  
  57. @EventHandler
  58. public void PreInit(FMLPreInitializationEvent event){
  59. MinecraftForge.TERRAIN_GEN_BUS.register(this);
  60.  
  61. DesertCave = new BiomeGenBase(233) {
  62.  
  63. };
  64.  
  65. }
  66.  
  67. public static Field biomePatternGeneratorChainfield;
  68. public static Field biomeArrayField;
  69.  
  70. static{
  71.  
  72. try {
  73. biomePatternGeneratorChainfield = GenLayerRiverMix.class.getDeclaredField("field_151622_e");
  74. biomePatternGeneratorChainfield.setAccessible(true);
  75.  
  76.  
  77. biomeArrayField = GenLayerBiome.class.getDeclaredField("field_151622_e");
  78. biomeArrayField.setAccessible(true);
  79. } catch (NoSuchFieldException e) {
  80. Throwables.propagate(e);
  81. }
  82. }
  83.  
  84. @SubscribeEvent
  85. public void onGenLayerInit(WorldTypeEvent.InitBiomeGens event) throws IllegalAccessException {
  86. GenLayer biomeLayer = event.originalBiomeGens[1];
  87.  
  88. do{
  89.  
  90. if (biomeLayer instanceof GenLayerRiverMix) {
  91. biomeLayer = (GenLayer) biomePatternGeneratorChainfield.get(biomeLayer);
  92. } else {
  93. biomeLayer = CaveBiomesGenLayerAccessor.getParent(biomeLayer);
  94.  
  95. }
  96.  
  97.  
  98. } while (biomeLayer != null && !(biomeLayer instanceof GenLayerBiome));
  99. if (biomeLayer == null) {
  100. throw new IllegalStateException("couldn't locate GenLayerbiome!");
  101. }
  102.  
  103. BiomeGenBase[] biomes = (BiomeGenBase[]) biomeArrayField.get(biomeLayer);
  104. biomes = ObjectArrays.concat(biomes, DesertCave);
  105. biomeArrayField.set(biomeLayer, biomes);
  106. }
  107.  
  108. @EventHandler
  109. public void postInit(FMLPostInitializationEvent postEvent){
  110.  
  111. }
  112.  
  113. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×