Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.45 KB | None | 0 0
  1. package me.geometrically.prehistoric.common.world.gen;
  2.  
  3. import com.google.common.collect.HashMultimap;
  4. import com.google.common.collect.ImmutableList;
  5. import com.google.common.collect.Lists;
  6. import com.google.common.collect.Multimap;
  7. import net.minecraft.block.BlockFalling;
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.client.Minecraft;
  10. import net.minecraft.entity.EnumCreatureType;
  11. import net.minecraft.util.math.BlockPos;
  12. import net.minecraft.util.math.MathHelper;
  13. import net.minecraft.world.World;
  14. import net.minecraft.world.WorldEntitySpawner;
  15. import net.minecraft.world.WorldServer;
  16. import net.minecraft.world.biome.Biome;
  17. import net.minecraft.world.chunk.Chunk;
  18. import net.minecraft.world.chunk.ChunkPrimer;
  19. import net.minecraft.world.gen.*;
  20. import net.minecraftforge.event.ForgeEventFactory;
  21. import net.minecraftforge.event.terraingen.InitMapGenEvent;
  22. import net.minecraftforge.event.terraingen.TerrainGen;
  23.  
  24. import javax.annotation.Nullable;
  25. import javax.imageio.ImageIO;
  26. import java.awt.*;
  27. import java.awt.image.BufferedImage;
  28. import java.io.IOException;
  29. import java.util.*;
  30. import java.util.List;
  31.  
  32. public class ChunkGeneratorPrehistoric implements IChunkGenerator {
  33.  
  34.     private final World worldObj;
  35.     private Random random;
  36.     private Biome[] biomesForGeneration;
  37.  
  38.     //private List<Biome.SpawnListEntry> mobs = Lists.newArrayList(new Biome.SpawnListEntry(EntityWeirdZombie.class, 100, 2, 2));
  39.  
  40.     private MapGenBase caveGenerator = new MapGenCaves();
  41.     private PrehistoricTerrainGenerator terraingen = new PrehistoricTerrainGenerator();
  42.  
  43.     public ChunkGeneratorPrehistoric(World worldObj) {
  44.         this.worldObj = worldObj;
  45.         long seed = worldObj.getSeed();
  46.         this.random = new Random((seed + 516) * 314);
  47.         terraingen.setup(worldObj, random);
  48.         caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, InitMapGenEvent.EventType.CAVE);
  49.     }
  50.  
  51.     @Override
  52.     public Chunk generateChunk(int x, int z) {
  53.         ChunkPrimer chunkprimer = new ChunkPrimer();
  54.  
  55.         // Setup biomes for terraingen
  56.         this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10);
  57.         terraingen.setBiomesForGeneration(biomesForGeneration);
  58.         terraingen.generate(x, z, chunkprimer);
  59.  
  60.         // Setup biomes again for actual biome decoration
  61.         this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16);
  62.         // This will replace stone with the biome specific stones
  63.         terraingen.replaceBiomeBlocks(x, z, chunkprimer, this, biomesForGeneration);
  64.  
  65.         // Generate caves
  66.         this.caveGenerator.generate(this.worldObj, x, z, chunkprimer);
  67.  
  68.         Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z);
  69.  
  70.         byte[] biomeArray = chunk.getBiomeArray();
  71.         for (int i = 0; i < biomeArray.length; ++i) {
  72.             biomeArray[i] = (byte) Biome.getIdForBiome(this.biomesForGeneration[i]);
  73.         }
  74.  
  75.         chunk.generateSkylightMap();
  76.         return chunk;
  77.     }
  78.  
  79.     @Override
  80.     public void populate(int x, int z) {
  81.         int i = x * 16;
  82.         int j = z * 16;
  83.         BlockPos blockpos = new BlockPos(i, 0, j);
  84.         Biome biome = this.worldObj.getBiome(blockpos.add(16, 0, 16));
  85.  
  86.         // Add biome decorations (like flowers, grass, trees, ...)
  87.         biome.decorate(this.worldObj, this.random, blockpos);
  88.  
  89.         // Make sure animals appropriate to the biome spawn here when the chunk is generated
  90.         WorldEntitySpawner.performWorldGenSpawning(this.worldObj, biome, i + 8, j + 8, 16, 16, this.random);
  91.     }
  92.  
  93.     @Override
  94.     public boolean generateStructures(Chunk chunkIn, int x, int z) {
  95.         return false;
  96.     }
  97.  
  98.     @Override
  99.     public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
  100.  
  101.        /* if (creatureType == EnumCreatureType.MONSTER){
  102.             return mobs;
  103.         }*/
  104.         return ImmutableList.of();
  105.  
  106.     }
  107.  
  108.     @Nullable
  109.     @Override
  110.     public BlockPos getNearestStructurePos(World worldIn, String structureName, BlockPos position, boolean findUnexplored) {
  111.         return null;
  112.     }
  113.  
  114.     @Override
  115.     public boolean isInsideStructure(World worldIn, String structureName, BlockPos pos) {
  116.         return false;
  117.     }
  118.  
  119.     @Override
  120.     public void recreateStructures(Chunk chunkIn, int x, int z) {
  121.  
  122.     }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement