Skip to content
Permalink
Browse files

Loose sticks now generate based on tree density. Also tweaked loose r…

…ock generation to be more consistent with other decorations.
  • Loading branch information...
alcatrazEscapee committed Aug 14, 2018
1 parent 247ff48 commit dced34288dfcd29f342411d9a31886182f5747ee
@@ -9,7 +9,6 @@
import java.util.Random;
import javax.annotation.Nullable;

import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
@@ -58,7 +57,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG
int xoff = chunkX * 16 + 8;
int zoff = chunkZ * 16 + 8;

for (int i = 0; i < 8; i++)
for (int i = 0; i < 12; i++)
{
BlockPos pos = new BlockPos(
xoff + random.nextInt(16),
@@ -73,8 +72,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG
private void generateRock(World world, BlockPos pos, @Nullable VeinType vein, Rock rock)
{

IBlockState stateAt = world.getBlockState(pos.down());
if (world.isAirBlock(pos) && stateAt.isFullCube())
if (world.getBlockState(pos).getMaterial().isReplaceable() && !world.getBlockState(pos).getMaterial().isLiquid() && world.getBlockState(pos.down()).isFullCube())
{
//noinspection ConstantConditions
world.setBlockState(pos, BlocksTFC.WORLD_ITEM.getDefaultState(), 2);
@@ -13,6 +13,8 @@
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
@@ -25,7 +27,9 @@

import net.dries007.tfc.api.ITreeGenerator;
import net.dries007.tfc.api.types.Tree;
import net.dries007.tfc.objects.blocks.BlocksTFC;
import net.dries007.tfc.objects.blocks.wood.BlockLeavesTFC;
import net.dries007.tfc.objects.te.TEWorldItem;
import net.dries007.tfc.world.classic.ChunkGenTFC;
import net.dries007.tfc.world.classic.biomes.BiomeTFC;
import net.dries007.tfc.world.classic.biomes.BiomesTFC;
@@ -113,6 +117,11 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG
List<Tree> trees = chunkData.getValidTrees();
Collections.rotate(trees, -(int) (diversity * (trees.size() - 1f)));

int stickDensity = 3 + (int) (4f * density + 1.5f * trees.size());
if (trees.isEmpty())
stickDensity = 1 + (int) (1.5f * density);
generateLooseSticks(random, chunkX, chunkZ, world, stickDensity);

// This is to avoid giant regions of no trees whatsoever.
// It will create sparse trees ( < 1 per chunk) by averaging the climate data to make it more temperate
// The thought is in very harsh conditions, a few trees might survive outside their typical temperature zone
@@ -163,4 +172,23 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG
}
}

private void generateLooseSticks(Random rand, int chunkX, int chunkZ, World world, int amount)
{
for (int i = 0; i < amount; i++)
{
final int x = chunkX * 16 + rand.nextInt(16) + 8;
final int z = chunkZ * 16 + rand.nextInt(16) + 8;
final BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z));

if (world.getBlockState(pos).getMaterial().isReplaceable() && !world.getBlockState(pos).getMaterial().isLiquid() && world.getBlockState(pos.down()).isOpaqueCube())
{
//noinspection ConstantConditions
world.setBlockState(pos, BlocksTFC.WORLD_ITEM.getDefaultState());
TEWorldItem tile = (TEWorldItem) world.getTileEntity(pos);
if (tile != null)
tile.inventory.setStackInSlot(0, new ItemStack(Items.STICK));
}
}
}

}

0 comments on commit dced342

Please sign in to comment.
You can’t perform that action at this time.