Generation

This commit is contained in:
paulevsGitch 2020-11-18 16:26:45 +03:00
parent 1a4eaa7c6e
commit dc823fb7d1
3 changed files with 35 additions and 7 deletions

View file

@ -39,7 +39,7 @@ public class EndFeatures {
public static final EndFeature PYTHADENDRON_TREE = new EndFeature("pythadendron_tree", new PythadendronTreeFeature(), 2); public static final EndFeature PYTHADENDRON_TREE = new EndFeature("pythadendron_tree", new PythadendronTreeFeature(), 2);
public static final EndFeature LACUGROVE = new EndFeature("lacugrove", new LacugroveFeature(), 4); public static final EndFeature LACUGROVE = new EndFeature("lacugrove", new LacugroveFeature(), 4);
public static final EndFeature DRAGON_TREE = new EndFeature("dragon_tree", new DragonTreeFeature(), 3); public static final EndFeature DRAGON_TREE = new EndFeature("dragon_tree", new DragonTreeFeature(), 3);
public static final EndFeature TENANEA = new EndFeature("tenanea", new TenaneaFeature(), 3); public static final EndFeature TENANEA = new EndFeature("tenanea", new TenaneaFeature(), 7);
// Bushes // // Bushes //
public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new BushFeature(EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.bark), 4); public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new BushFeature(EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.bark), 4);

View file

@ -13,6 +13,7 @@ public class BlossomingSpires extends EndBiome {
.setSurface(EndBlocks.END_MOSS) .setSurface(EndBlocks.END_MOSS)
.addFeature(EndFeatures.SPIRE) .addFeature(EndFeatures.SPIRE)
.addFeature(EndFeatures.FLOATING_SPIRE) .addFeature(EndFeatures.FLOATING_SPIRE)
.addFeature(EndFeatures.TENANEA)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4)); .addMobSpawn(EntityType.ENDERMAN, 50, 1, 4));
} }
} }

View file

@ -1,6 +1,9 @@
package ru.betterend.world.features.trees; package ru.betterend.world.features.trees;
import java.util.Random; import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -21,21 +24,24 @@ public class TenaneaFeature extends DefaultFeature {
@Override @Override
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
branch(world, pos, UP, 100, random); Set<BlockPos> set = branch(Sets.newHashSet(), world, pos, UP, 100, random);
set.forEach((bpos) -> {
BlocksHelper.setWithoutUpdate(world, bpos, Blocks.DIAMOND_BLOCK);
});
return true; return true;
} }
private void branch(StructureWorldAccess world, BlockPos pos, Vec3i dir, int length, Random random) { private Set<BlockPos> branch(Set<BlockPos> set, StructureWorldAccess world, BlockPos pos, Vec3i dir, int length, Random random) {
Mutable mut = new Mutable().set(pos); Mutable mut = new Mutable().set(pos);
int upCount = 0; int upCount = 0;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
MHelper.shuffle(DIRECTIONS, random); MHelper.shuffle(DIRECTIONS, random);
boolean up = false; boolean up = false;
BlocksHelper.setWithoutUpdate(world, mut, Blocks.DIAMOND_BLOCK); set.add(mut.toImmutable());
for (Direction hor: BlocksHelper.HORIZONTAL) { for (Direction hor: BlocksHelper.HORIZONTAL) {
if (!isReplaceable(world.getBlockState(mut.offset(hor)))) { if (!isReplaceable(world.getBlockState(mut.offset(hor))) || !isReplaceable(world.getBlockState(mut.offset(hor).down()))) {
upCount = -1; upCount = -1;
up = true; up = true;
break; break;
@ -47,18 +53,37 @@ public class TenaneaFeature extends DefaultFeature {
if (upCount > 8) { if (upCount > 8) {
break; break;
} }
if (random.nextInt(4) == 0) {
Direction d = BlocksHelper.randomHorizontal(random);
mut.move(d);
}
/*if (random.nextInt(16) == 0) {
int l = length - i;
if (l > 5) {
l = MHelper.randRange(l / 2, l, random);
Vec3i d = DIRECTIONS[random.nextInt(DIRECTIONS.length)];
if (d != dir) {
branch(set, world, mut.add(d), d, l, random);
}
}
}*/
continue; continue;
} }
else { else {
up = true; up = true;
for (Vec3i d: DIRECTIONS) { for (Vec3i d: DIRECTIONS) {
BlockPos offseted = mut.add(d.getX(), d.getY(), d.getZ()); BlockPos offseted = mut.add(d.getX(), d.getY(), d.getZ());
if (isReplaceable(world.getBlockState(offseted))) { boolean canOffset = Math.abs(offseted.getX() - pos.getX()) < 16 && Math.abs(offseted.getZ() - pos.getZ()) < 16;
int dist = BlocksHelper.raycastSqr(world, offseted, d.getX(), d.getY(), d.getZ(), 18); if (canOffset && isReplaceable(world.getBlockState(offseted))) {
int dist = BlocksHelper.raycastSqr(world, offseted, d.getX(), d.getY(), d.getZ(), 10);
if (dist < 64) { if (dist < 64) {
mut.move(d.getX(), d.getY(), d.getZ()); mut.move(d.getX(), d.getY(), d.getZ());
upCount = 0; upCount = 0;
up = false; up = false;
dir = d;
break; break;
} }
} }
@ -85,6 +110,8 @@ public class TenaneaFeature extends DefaultFeature {
} }
} }
} }
return set;
} }
private boolean isReplaceable(BlockState state) { private boolean isReplaceable(BlockState state) {