Initial work on rubber trees
This commit is contained in:
parent
c9fad62ed2
commit
6636fc648b
3 changed files with 57 additions and 0 deletions
|
@ -36,6 +36,7 @@ import techreborn.packets.PacketIdsu;
|
|||
import techreborn.proxies.CommonProxy;
|
||||
import techreborn.tiles.idsu.IDSUManager;
|
||||
import techreborn.world.TROreGen;
|
||||
import techreborn.world.TreeGenerator;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -106,6 +107,7 @@ public class Core {
|
|||
}
|
||||
// WorldGen
|
||||
GameRegistry.registerWorldGenerator(new TROreGen(), 0);
|
||||
GameRegistry.registerWorldGenerator(new TreeGenerator(), 1);
|
||||
// DungeonLoot.init();
|
||||
// Register Gui Handler
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
|
||||
|
|
15
src/main/java/techreborn/world/RubberTreeGenerator.java
Normal file
15
src/main/java/techreborn/world/RubberTreeGenerator.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package techreborn.world;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.world.gen.feature.WorldGenTrees;
|
||||
|
||||
/**
|
||||
* Created by Mark on 19/02/2016.
|
||||
*/
|
||||
public class RubberTreeGenerator extends WorldGenTrees {
|
||||
|
||||
|
||||
public RubberTreeGenerator(boolean doBlockNotify, int minTreeHeight, IBlockState woodState, IBlockState leaveState, boolean vinesGrow) {
|
||||
super(doBlockNotify, minTreeHeight, woodState, leaveState, vinesGrow);
|
||||
}
|
||||
}
|
40
src/main/java/techreborn/world/TreeGenerator.java
Normal file
40
src/main/java/techreborn/world/TreeGenerator.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package techreborn.world;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by Mark on 19/02/2016.
|
||||
*/
|
||||
public class TreeGenerator implements IWorldGenerator {
|
||||
|
||||
RubberTreeGenerator treeGenerator = new RubberTreeGenerator(false, 6, Blocks.log.getDefaultState(), Blocks.leaves.getDefaultState(), false);
|
||||
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||
int chance = 0;
|
||||
BiomeGenBase biomeGenBase = world.getBiomeGenForCoords( new BlockPos(chunkX * 16 + 16, 72, chunkZ * 16 + 16));
|
||||
if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)){
|
||||
chance += random.nextInt(10) + 5;
|
||||
}
|
||||
if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)){
|
||||
chance += random.nextInt(5) + 1;
|
||||
}
|
||||
if(world.provider.isSurfaceWorld()){
|
||||
if(random.nextInt(100) + 1 <= chance * 2){
|
||||
|
||||
|
||||
treeGenerator.generate(world, random, new BlockPos(chunkX * 16 + random.nextInt(16), 72, chunkZ * 16 + random.nextInt(16)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue