-
-
Save anonymous/b24cbacf67c5ab883859b60a569e6f5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.chocolatemod.worldgen; | |
import com.chocolatemod.init.ChocolateBlocks; | |
import com.chocolatemod.main.MainRegistry; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.BlockFlower; | |
import net.minecraft.block.BlockSand; | |
import net.minecraft.block.material.Material; | |
import net.minecraft.block.state.IBlockState; | |
import net.minecraft.entity.monster.*; | |
import net.minecraft.entity.passive.EntityBat; | |
import net.minecraft.entity.passive.EntitySheep; | |
import net.minecraft.entity.passive.EntitySquid; | |
import net.minecraft.init.Blocks; | |
import net.minecraft.util.BlockPos; | |
import net.minecraft.util.WeightedRandom; | |
import net.minecraft.world.World; | |
import net.minecraft.world.biome.BiomeDecorator; | |
import net.minecraft.world.biome.BiomeGenBase; | |
import net.minecraft.world.biome.BiomeGenBase.FlowerEntry; | |
import net.minecraft.world.biome.BiomeGenForest; | |
import net.minecraft.world.biome.BiomeGenHills; | |
import net.minecraft.world.biome.BiomeGenJungle; | |
import net.minecraft.world.biome.BiomeGenMushroomIsland; | |
import net.minecraft.world.biome.BiomeGenPlains; | |
import net.minecraft.world.biome.BiomeGenSwamp; | |
import net.minecraft.world.chunk.ChunkPrimer; | |
import net.minecraft.world.chunk.IChunkProvider; | |
import net.minecraft.world.gen.feature.WorldGenAbstractTree; | |
import net.minecraft.world.gen.feature.WorldGenFlowers; | |
import net.minecraft.world.gen.feature.WorldGenTallGrass; | |
import net.minecraft.world.gen.feature.WorldGenerator; | |
import net.minecraftforge.common.BiomeDictionary; | |
import net.minecraftforge.common.BiomeDictionary.Type; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
public class BiomeGenChocolateBase extends BiomeGenBase { | |
public static BiomeGenBase chocolateForest; | |
public static BiomeGenBase chocolateMountians; | |
public static BiomeGenBase chocolateMushroom; | |
public static BiomeGenBase chocolatePlains; | |
public static BiomeGenBase chocolateSwamp; | |
public static BiomeGenBase chocolateJungle; | |
public static BiomeGenBase chocolateRiver; | |
public static BiomeGenBase chocolateOcean; | |
public static BiomeGenBase chocolateDesert; | |
public BiomeDecorator theChocolateBiomeDecorator; | |
/** | |
* The tree generator. | |
*/ | |
/** protected WorldGenCocoaTree worldGeneratorCocoaTrees; | |
protected WorldGenChocolateTree worldGeneratorChocolateTrees; | |
protected WorldGenDarkChocolateTree worldGeneratorDarkChocolateTrees; | |
protected WorldGenLightChocolateTree worldGeneratorLightChocolateTrees; | |
protected WorldGenWhiteChocolateTree worldGeneratorWhiteChocolateTrees; | |
/** | |
* The big tree generator. | |
*/ | |
// protected WorldGenMegaCocoa worldGeneratorBigChocolateTree; | |
/** | |
* The swamp tree generator. | |
*/ | |
// protected WorldGenChocolateSwamp worldGeneratorChocolateSwamp; | |
public BiomeGenChocolateBase(int biomeID) { | |
super(biomeID); | |
/** this.worldGeneratorCocoaTrees = new WorldGenCocoaTree(false); | |
this.worldGeneratorChocolateTrees = new WorldGenChocolateTree(false, false); | |
this.worldGeneratorDarkChocolateTrees = new WorldGenDarkChocolateTree(false); | |
this.worldGeneratorLightChocolateTrees = new WorldGenLightChocolateTree(false, false); | |
this.worldGeneratorWhiteChocolateTrees = new WorldGenWhiteChocolateTree(false); | |
this.worldGeneratorBigChocolateTree = new WorldGenMegaCocoa(false, 10, 20, 0, 0); | |
this.worldGeneratorChocolateSwamp = new WorldGenChocolateSwamp(); | |
**/ this.theChocolateBiomeDecorator = new BiomeDecorator(); | |
this.topBlock = ChocolateBlocks.chocoGrass.getDefaultState(); | |
this.fillerBlock = ChocolateBlocks.chocoDirt.getDefaultState(); | |
this.fillerBlockMetadata = 5169201; | |
this.minHeight = height_Default.rootHeight; | |
this.maxHeight = height_Default.variation; | |
this.spawnableCreatureList.clear(); | |
this.spawnableMonsterList = new ArrayList(); | |
this.spawnableCreatureList = new ArrayList(); | |
this.spawnableWaterCreatureList = new ArrayList(); | |
this.spawnableCaveCreatureList = new ArrayList(); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 12, 4, 4)); | |
/** this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitychocolatepig.class, 10, 4, 4)); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitydarkchocolatepig.class, 10, 4, 4)); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitylightchocolatepig.class, 10, 4, 4)); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitywhitechocolatepig.class, 10, 4, 4)); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitychocolatechicken.class, 10, 4, 4)); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitycocoacow.class, 8, 4, 4)); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitydarkcocoacow.class, 8, 4, 4)); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitylightcocoacow.class, 8, 4, 4)); | |
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(Entitywhitecocoacow.class, 8, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 100, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 100, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 100, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 100, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(Entitychocolateglob.class, 100, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(Entitydarkchocolateglob.class, 100, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(Entitylightchocolateglob.class, 100, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(Entitywhitechocolateglob.class, 100, 4, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityEnderman.class, 10, 1, 4)); | |
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 1)); | |
this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 10, 4, 4)); | |
this.spawnableCaveCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 10, 8, 8)); | |
**/ this.addDefaultChocolateFlowers(); | |
} | |
static { | |
chocolatePlains = new BiomeGenChocolatePlains(MainRegistry.ChocolatePlainsID).setBiomeName("Chocolate Plains").setColor(5470985); | |
chocolateForest = new BiomeGenForest(MainRegistry.ChocolateForestID, 0).setBiomeName("Chocolate Forest").setColor(5470985); | |
chocolateMountians = new BiomeGenHills(MainRegistry.ChocolateMountainsID, false).setBiomeName("Chocolate Mountians").setColor(5470985).setHeight(height_MidHills); | |
chocolateMushroom = new BiomeGenMushroomIsland(MainRegistry.ChocolateMushroomsID).setBiomeName("Chocolate Mushrooms").setColor(5470985); | |
// chocolateSwamp = new BiomeGenSwamp(MainRegistry.ChocolateSwampID).setBiomeName("Chocolate Swamp").setColor(5470985).setHeight(height_PartiallySubmerged); | |
chocolateJungle = new BiomeGenJungle(MainRegistry.ChocolateJungleID, false).setBiomeName("Chocolate Jungle").setColor(5470985); | |
chocolateRiver = new BiomeGenChocolateRiver(MainRegistry.ChocolateRiverID).setBiomeName("Chocolate River").setColor(5470985).setHeight(height_ShallowWaters); | |
chocolateOcean = new BiomeGenChocolateOcean(MainRegistry.ChocolateOceanID).setBiomeName("Chocolate Ocean").setColor(5470985).setHeight(height_Oceans); | |
chocolateDesert = (new BiomeGenChocolateDesert(MainRegistry.ChocolateDesertID)).setColor(16421912).setBiomeName("Chocolate Desert").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setHeight(height_LowPlains); | |
} | |
@Override | |
public BiomeDecorator createBiomeDecorator() { | |
return new BiomeDecorator(); | |
} | |
@Override | |
public void decorate(World worldIn, Random p_180624_2_, BlockPos p_180624_3_) | |
{ | |
this.theChocolateBiomeDecorator.decorate(worldIn, p_180624_2_, this, p_180624_3_); | |
} | |
// @Override | |
// public WorldGenAbstractTree genBigTreeChance(Random p_150567_1_) { | |
// return (WorldGenAbstractTree) (p_150567_1_.nextInt(10) == 0 ? this.worldGeneratorCocoaTrees : this.worldGeneratorChocolateTrees); | |
// } | |
//@Override | |
// public WorldGenerator getRandomWorldGenForGrass(Random random) { | |
// if (random.nextInt(1) == 0) | |
// return new WorldGenTallGrass(PlantRegistry.ChocolateGrass, 0); | |
// else | |
// return new WorldGenTallGrass(PlantRegistry.MintGrass, 0); | |
// } | |
public static void registerWithBiomeDictionary() { | |
BiomeDictionary.registerBiomeType(chocolateForest, Type.FOREST); | |
BiomeDictionary.registerBiomeType(chocolateMountians, Type.MOUNTAIN); | |
BiomeDictionary.registerBiomeType(chocolateMushroom, Type.MUSHROOM); | |
BiomeDictionary.registerBiomeType(chocolatePlains, Type.PLAINS); | |
BiomeDictionary.registerBiomeType(chocolateSwamp, Type.SWAMP); | |
BiomeDictionary.registerBiomeType(chocolateJungle, Type.JUNGLE); | |
BiomeDictionary.registerBiomeType(chocolateRiver, Type.RIVER); | |
BiomeDictionary.registerBiomeType(chocolateOcean, Type.OCEAN); | |
BiomeDictionary.registerAllBiomes(); | |
} | |
/** | |
* Replaces custom Stone to allow top/filler blocks to work in dimension. | |
* | |
* @param world | |
* @param random | |
* @param replacableBlock | |
* @param aByte | |
* @param par5 | |
* @param par6 | |
* @param par7 | |
*/ | |
public void genBiomeTerrain(World worldIn, Random p_180628_2_, ChunkPrimer p_180628_3_, int p_180628_4_, int p_180628_5_, double p_180628_6_) | |
{ | |
boolean flag = true; | |
IBlockState iblockstate = this.topBlock; | |
IBlockState iblockstate1 = this.fillerBlock; | |
int k = -1; | |
int l = (int)(p_180628_6_ / 3.0D + 3.0D + p_180628_2_.nextDouble() * 0.25D); | |
int i1 = p_180628_4_ & 15; | |
int j1 = p_180628_5_ & 15; | |
for (int k1 = 255; k1 >= 0; --k1) | |
{ | |
if (k1 <= p_180628_2_.nextInt(5)) | |
{ | |
p_180628_3_.setBlockState(j1, k1, i1, Blocks.bedrock.getDefaultState()); | |
} | |
else | |
{ | |
IBlockState iblockstate2 = p_180628_3_.getBlockState(j1, k1, i1); | |
if (iblockstate2.getBlock().getMaterial() == Material.air) | |
{ | |
k = -1; | |
} | |
else if (iblockstate2.getBlock() == ChocolateBlocks.chocoStone) | |
{ | |
if (k == -1) | |
{ | |
if (l <= 0) | |
{ | |
iblockstate = null; | |
iblockstate1 = ChocolateBlocks.chocoStone.getStateFromMeta(1); | |
} | |
else if (k1 >= 59 && k1 <= 64) | |
{ | |
iblockstate = this.topBlock; | |
iblockstate1 = this.fillerBlock; | |
} | |
if (k1 < 63 && (iblockstate == null || iblockstate.getBlock().getMaterial() == Material.air)) | |
{ | |
if (this.getFloatTemperature(new BlockPos(p_180628_4_, k1, p_180628_5_)) < 0.15F) | |
{ | |
iblockstate = Blocks.ice.getDefaultState(); | |
} | |
else | |
{ | |
iblockstate = Blocks.water.getDefaultState(); | |
} | |
} | |
k = l; | |
if (k1 >= 62) | |
{ | |
p_180628_3_.setBlockState(j1, k1, i1, iblockstate); | |
} | |
else if (k1 < 56 - l) | |
{ | |
iblockstate = null; | |
iblockstate1 = ChocolateBlocks.chocoStone.getStateFromMeta(1); | |
p_180628_3_.setBlockState(j1, k1, i1, Blocks.gravel.getDefaultState()); | |
} | |
else | |
{ | |
p_180628_3_.setBlockState(j1, k1, i1, iblockstate1); | |
} | |
} | |
else if (k > 0) | |
{ | |
--k; | |
p_180628_3_.setBlockState(j1, k1, i1, iblockstate1); | |
if (k == 0 && iblockstate1.getBlock() == ChocolateBlocks.chocoSand.getStateFromMeta(3)) | |
{ | |
k = p_180628_2_.nextInt(4) + Math.max(0, k1 - 63); | |
Blocks.sandstone.getDefaultState(); | |
} | |
} | |
} | |
} | |
} | |
} | |
protected List<FlowerEntry> flowers = new ArrayList<FlowerEntry>(); | |
public static class FlowerEntry extends WeightedRandom.Item | |
{ | |
public final net.minecraft.block.state.IBlockState state; | |
public FlowerEntry(net.minecraft.block.state.IBlockState state, int weight) | |
{ | |
super(weight); | |
this.state = state; | |
} | |
} | |
public void addDefaultChocolateFlowers() | |
{ | |
/** this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower1, 0, 10)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 0, 20)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 1, 30)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 2, 40)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 3, 50)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 4, 60)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 5, 70)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 6, 80)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 7, 90)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 8, 100)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 9, 110)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 10, 120)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 11, 130)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 12, 140)); | |
this.flowers.add(new FlowerEntry(PlantRegistry.chocolateflower2, 13, 150)); | |
**/ | |
} | |
public void addFlower(IBlockState state, int weight) | |
{ | |
// this.flowers.add(new FlowerEntry(state, weight)); | |
} | |
public void plantFlower(World world, Random rand, BlockPos pos) | |
{ | |
FlowerEntry flower = (FlowerEntry)WeightedRandom.getRandomItem(rand, flowers); | |
if (flower == null || flower.state == null || | |
(flower.state.getBlock() instanceof net.minecraft.block.BlockBush && | |
!((net.minecraft.block.BlockBush)flower.state.getBlock()).canBlockStay(world, pos, flower.state))) | |
{ | |
return; | |
} | |
world.setBlockState(pos, flower.state, 3); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment