mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
"Added lush caves that spawn randomly" or something like that.
I guess I'll leave these in, as they're kind of awesome.
This commit is contained in:
parent
9b9f7b8ff3
commit
b826c83c50
5 changed files with 112 additions and 2 deletions
|
@ -57,7 +57,7 @@ public class ConfigValues{
|
|||
mashedFoodCraftingExceptions = config.get(ConfigCategories.ITEMS_CRAFTING.name, "Mashed Food Crafting Exceptions", new String[]{"ActuallyAdditions:itemCoffee"}, "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList();
|
||||
paxelExtraMiningWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "AIOT Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the AIOT can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList();
|
||||
drillExtraMiningWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "Drill Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the Drill can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList();
|
||||
oreGenDimensionBlacklist = config.get(ConfigCategories.WORLD_GEN.name, "OreGen Dimension Blacklist", new int[0], "The IDs of the dimensions that Actually Additions OreGen (Black Quartz for example) is banned in").getIntList();
|
||||
oreGenDimensionBlacklist = config.get(ConfigCategories.WORLD_GEN.name, "OreGen Dimension Blacklist", new int[0], "The IDs of the dimensions that Actually Additions OreGen (Black Quartz for example) is banned in. This also applies for other world gen like lush caves.").getIntList();
|
||||
plantDimensionBlacklist = config.get(ConfigCategories.WORLD_GEN.name, "Plant Blacklist", new int[0], "The IDs of the dimensions that Actually Additions Plants (Rice for example) are banned in").getIntList();
|
||||
minerExtraWhitelist = config.get(ConfigCategories.MACHINE_VALUES.name, "Vertical Digger Extra Whitelist", new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option only applies if the miner is in Ores Only Mode.").getStringList();
|
||||
minerBlacklist = config.get(ConfigCategories.MACHINE_VALUES.name, "Vertical Digger Blacklist", new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can mine, but shouldn't be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option will apply in both modes.").getStringList();
|
||||
|
|
|
@ -46,7 +46,8 @@ public enum ConfigBoolValues{
|
|||
|
||||
ENABLE_SEASONAL("Seasonal Mode", ConfigCategories.OTHER, true, "If Seasonal Mode is enabled"),
|
||||
|
||||
DUNGEON_LOOT("Dungeon Loot", ConfigCategories.OTHER, true, "Should Actually Additions Loot spawn in Dungeons");
|
||||
DUNGEON_LOOT("Dungeon Loot", ConfigCategories.OTHER, true, "Should Actually Additions Loot spawn in Dungeons"),
|
||||
GEN_LUSH_CAVES("Generate Lush Caves", ConfigCategories.WORLD_GEN, true, "Should caves with trees and grass randomly generate underground");
|
||||
|
||||
public final String name;
|
||||
public final String category;
|
||||
|
|
|
@ -21,6 +21,7 @@ public enum ConfigIntValues{
|
|||
FLAX_AMOUNT("Flax: Amount", ConfigCategories.WORLD_GEN, 8, 1, 50, "The Amount of Flax generating"),
|
||||
COFFEE_AMOUNT("Coffee: Amount", ConfigCategories.WORLD_GEN, 6, 1, 50, "The Amount of Coffee generating"),
|
||||
BLACK_LOTUS_AMOUNT("Black Lotus: Amount", ConfigCategories.WORLD_GEN, 14, 1, 50, "The Amount of Black Lotus generating"),
|
||||
LUSH_CAVE_CHANCE("Lush Caves: Chance", ConfigCategories.WORLD_GEN, 20, 1, 100, "The chance for lush caves to generate. The lower the number, the likelier."),
|
||||
|
||||
LASER_RELAY_LOSS("Laser Relay: Loss", ConfigCategories.MACHINE_VALUES, 5, 0, 80, "The Energy Loss of the Laser Relay per Transfer in Percent"),
|
||||
LASER_RELAY_MAX_TRANSFER("Laser Relay: Max Transfer", ConfigCategories.MACHINE_VALUES, 10000, 100, 1000000, "The max amount of RF a Laser Relay can receive and try to transfer (if it's given 100 RF and can only transfer 50, it will only accept 50, it won't waste any power!)"),
|
||||
|
|
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
|||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -36,6 +37,8 @@ public class OreGen implements IWorldGenerator{
|
|||
public static final int QUARTZ_MIN = 0;
|
||||
public static final int QUARTZ_MAX = 45;
|
||||
|
||||
private final WorldGenLushCaves caveGen = new WorldGenLushCaves();
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Registering World Generator...");
|
||||
GameRegistry.registerWorldGenerator(new OreGen(), 10);
|
||||
|
@ -55,6 +58,11 @@ public class OreGen implements IWorldGenerator{
|
|||
if(ConfigBoolValues.GENERATE_QUARTZ.isEnabled()){
|
||||
this.addOreSpawn(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), Blocks.STONE, world, random, x, z, MathHelper.getRandomIntegerInRange(random, 5, 8), 10, QUARTZ_MIN, QUARTZ_MAX);
|
||||
}
|
||||
|
||||
if(ConfigBoolValues.GEN_LUSH_CAVES.isEnabled() && random.nextInt(ConfigIntValues.LUSH_CAVE_CHANCE.getValue()) <= 0){
|
||||
BlockPos posAtHeight = world.getTopSolidOrLiquidBlock(new BlockPos(x+random.nextInt(16)+8, 0, z+random.nextInt(16)+8));
|
||||
this.caveGen.generate(world, random, posAtHeight.down(MathHelper.getRandomIntegerInRange(random, 10, posAtHeight.getY()-10)));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* This file ("WorldGenLushCaves.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.*;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class WorldGenLushCaves extends WorldGenerator{
|
||||
|
||||
@Override
|
||||
public boolean generate(@Nonnull World world, @Nonnull Random rand, @Nonnull BlockPos position){
|
||||
this.generateCave(world, position, rand);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void generateCave(World world, BlockPos center, Random rand){
|
||||
int spheres = rand.nextInt(5)+3;
|
||||
for(int i = 0; i <= spheres; i++){
|
||||
this.makeSphereWithGrassFloor(world, center.add(rand.nextInt(11)-5, rand.nextInt(7)-3, rand.nextInt(11)-5), rand.nextInt(3)+5);
|
||||
}
|
||||
|
||||
this.genTreesAndTallGrass(world, center, 10, spheres*3, rand);
|
||||
}
|
||||
|
||||
private void genTreesAndTallGrass(World world, BlockPos center, int radius, int amount, Random rand){
|
||||
List<BlockPos> possiblePoses = new ArrayList<BlockPos>();
|
||||
for(double x = -radius; x < radius; x++){
|
||||
for(double y = -radius; y < radius; y++){
|
||||
for(double z = -radius; z < radius; z++){
|
||||
if(rand.nextDouble() >= 0.5D){
|
||||
BlockPos pos = center.add(x, y, z);
|
||||
if(world.getBlockState(pos).getBlock() == Blocks.GRASS){
|
||||
possiblePoses.add(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!possiblePoses.isEmpty()){
|
||||
for(int i = 0; i <= amount; i++){
|
||||
Collections.shuffle(possiblePoses);
|
||||
if(rand.nextBoolean()){
|
||||
WorldGenAbstractTree trees = rand.nextBoolean() ? (rand.nextBoolean() ? new WorldGenBigTree(false) : new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState())) : new WorldGenTrees(false);
|
||||
trees.generate(world, rand, possiblePoses.get(0).up());
|
||||
}
|
||||
else{
|
||||
ItemDye.applyBonemeal(new ItemStack(Items.DYE, 1, EnumDyeColor.WHITE.getDyeDamage()), world, possiblePoses.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makeSphereWithGrassFloor(World world, BlockPos center, int radius){
|
||||
for(double x = -radius; x < radius; x++){
|
||||
for(double y = -radius; y < radius; y++){
|
||||
for(double z = -radius; z < radius; z++){
|
||||
if(Math.sqrt((x*x)+(y*y)+(z*z)) < radius){
|
||||
world.setBlockToAir(center.add(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(double x = -radius; x < radius; x++){
|
||||
for(double z = -radius; z < radius; z++){
|
||||
for(double y = -radius; y <= -3; y++){
|
||||
BlockPos pos = center.add(x, y, z);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
BlockPos posUp = pos.up();
|
||||
IBlockState stateUp = world.getBlockState(posUp);
|
||||
if(!state.getBlock().isAir(state, world, pos) && stateUp.getBlock().isAir(stateUp, world, posUp)){
|
||||
world.setBlockState(pos, Blocks.GRASS.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue