Add tree blocks config option, fixes #165
This commit is contained in:
@@ -67,6 +67,10 @@ public final class Settings {
|
||||
/** The unlocalised name of the compatibility config category. */
|
||||
public static final String COMPATIBILITY_CATEGORY = "compatibility";
|
||||
|
||||
private static final String[] DEFAULT_TREE_BLOCKS = {"dynamictrees:oakbranch", "dynamictrees:sprucebranch",
|
||||
"dynamictrees:birchbranch", "dynamictrees:junglebranch", "dynamictrees:darkoakbranch",
|
||||
"dynamictrees:acaciabranch", "dynamictrees:cactusbranch", "dynamictrees:leaves0", "dynamictrees:leaves1"};
|
||||
|
||||
private static final String[] DEFAULT_LOOT_INJECTION_LOCATIONS = {"minecraft:chests/simple_dungeon",
|
||||
"minecraft:chests/abandoned_mineshaft", "minecraft:chests/desert_pyramid", "minecraft:chests/jungle_temple",
|
||||
"minecraft:chests/stronghold_corridor", "minecraft:chests/stronghold_crossing",
|
||||
@@ -119,6 +123,8 @@ public final class Settings {
|
||||
new ResourceLocation(Wizardry.MODID, "shrine_5"),
|
||||
new ResourceLocation(Wizardry.MODID, "shrine_6"),
|
||||
new ResourceLocation(Wizardry.MODID, "shrine_7")};
|
||||
/** <b>[Server-only]</b> List of solid blocks (usually trees) which are ignored by the structure generators. */
|
||||
public ResourceLocation[] treeBlocks = toResourceLocations(DEFAULT_TREE_BLOCKS);
|
||||
/** <b>[Server-only]</b> The chance for wizard towers to generate with an evil wizard and chest inside. */
|
||||
public double evilWizardChance = 0.2;
|
||||
/** <b>[Server-only]</b> List of dimension ids in which to generate crystal ore. */
|
||||
@@ -772,6 +778,12 @@ public final class Settings {
|
||||
shrineFiles = getResourceLocationList(property);
|
||||
propOrder.add(property.getName());
|
||||
|
||||
property = config.get(GAMEPLAY_CATEGORY, "treeBlocks", DEFAULT_TREE_BLOCKS, "List of registry names of blocks which can be overwritten by wizardry's structure generators, affecting both fast and fancy structure generation. Most tree blocks and other foliage should work automatically, but those that don't can be added manually here. Block names are not case sensitive. For mod blocks, prefix with the mod ID (e.g. dynamictrees:oakbranch).");
|
||||
property.setLanguageKey("config." + Wizardry.MODID + ".tree_blocks");
|
||||
property.setRequiresWorldRestart(true);
|
||||
treeBlocks = getResourceLocationList(property);
|
||||
propOrder.add(property.getName());
|
||||
|
||||
property = config.get(WORLDGEN_CATEGORY, "oreDimensions", new int[]{0}, "List of dimension ids in which crystal ore will generate. Note that removing the overworld (id 0) from this list will make the mod VERY difficult to play!");
|
||||
property.setLanguageKey("config." + Wizardry.MODID + ".ore_dimensions");
|
||||
property.setRequiresWorldRestart(true);
|
||||
|
||||
@@ -7,6 +7,7 @@ import electroblob.wizardry.entity.living.ISpellCaster;
|
||||
import electroblob.wizardry.item.ISpellCastingItem;
|
||||
import electroblob.wizardry.spell.Spell;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCactus;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -285,13 +286,25 @@ public final class WizardryUtilities {
|
||||
/** Surface criterion which defines a surface as the boundary between a block that cannot be moved through, and
|
||||
* a block that can be moved through or a tree block (log or leaves). Used for structure generation. */
|
||||
SurfaceCriteria COLLIDABLE_IGNORING_TREES = basedOn((world, pos) ->
|
||||
world.getBlockState(pos).getMaterial().blocksMovement()
|
||||
&& !(world.getBlockState(pos).getBlock() instanceof BlockLog)
|
||||
&& !(world.getBlockState(pos).getBlock().isLeaves(world.getBlockState(pos), world, pos)
|
||||
&& !(world.getBlockState(pos).getBlock().isFoliage(world, pos))));
|
||||
world.getBlockState(pos).getMaterial().blocksMovement() && !isTreeBlock(world, pos));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block at the given position is a tree block (or other 'solid' vegetation, such as cacti).
|
||||
* Used for structure generation.
|
||||
* @param world The world the block is in
|
||||
* @param pos The position of the block to be tested
|
||||
* @return True if the given block is a tree block, false if not.
|
||||
*/
|
||||
public static boolean isTreeBlock(World world, BlockPos pos){
|
||||
return world.getBlockState(pos).getBlock() instanceof BlockLog
|
||||
|| world.getBlockState(pos).getBlock() instanceof BlockCactus
|
||||
|| world.getBlockState(pos).getBlock().isLeaves(world.getBlockState(pos), world, pos)
|
||||
|| world.getBlockState(pos).getBlock().isFoliage(world, pos)
|
||||
|| Arrays.asList(Wizardry.settings.treeBlocks).contains(world.getBlockState(pos).getBlock().getRegistryName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the nearest floor level in the given direction from the given position,
|
||||
* within the range specified. This is a shorthand for
|
||||
|
||||
@@ -327,8 +327,7 @@ public abstract class WorldGenSurfaceStructure implements IWorldGenerator {
|
||||
Block below = world.getBlockState(pos.down()).getBlock();
|
||||
|
||||
if(block instanceof BlockLog){
|
||||
if(below != Blocks.GRASS && below != Blocks.DIRT && !(below instanceof BlockLog) &&
|
||||
!below.isLeaves(world.getBlockState(pos.down()), world, pos.down())){
|
||||
if(below != Blocks.GRASS && below != Blocks.DIRT && !WizardryUtilities.isTreeBlock(world, pos.down())){
|
||||
world.setBlockToAir(pos);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user