Lakugrove structure
This commit is contained in:
parent
0f9edccc4e
commit
91b40a3ae6
17 changed files with 301 additions and 64 deletions
16
src/main/java/ru/betterend/blocks/BlockLacugroveSapling.java
Normal file
16
src/main/java/ru/betterend/blocks/BlockLacugroveSapling.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
|
import ru.betterend.blocks.basis.BlockFeatureSapling;
|
||||||
|
import ru.betterend.registry.EndFeatures;
|
||||||
|
|
||||||
|
public class BlockLacugroveSapling extends BlockFeatureSapling {
|
||||||
|
public BlockLacugroveSapling() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Feature<?> getFeature() {
|
||||||
|
return EndFeatures.LACUGROVE.getFeature();
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,8 +4,8 @@ import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.blocks.basis.BlockFeatureSapling;
|
import ru.betterend.blocks.basis.BlockFeatureSapling;
|
||||||
import ru.betterend.registry.EndFeatures;
|
import ru.betterend.registry.EndFeatures;
|
||||||
|
|
||||||
public class BlockMossyPythadendronSapling extends BlockFeatureSapling {
|
public class BlockPythadendronSapling extends BlockFeatureSapling {
|
||||||
public BlockMossyPythadendronSapling() {
|
public BlockPythadendronSapling() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.explosion.Explosion;
|
import net.minecraft.world.explosion.Explosion;
|
||||||
|
|
||||||
import ru.betterend.blocks.basis.BlockSlab;
|
import ru.betterend.blocks.basis.BlockSlab;
|
||||||
import ru.betterend.blocks.entities.EternalPedestalBlockEntity;
|
import ru.betterend.blocks.entities.EternalPedestalBlockEntity;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
|
@ -8,9 +8,11 @@ import net.minecraft.block.LeavesBlock;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.block.MaterialColor;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.interfaces.Patterned;
|
import ru.betterend.interfaces.Patterned;
|
||||||
|
|
||||||
public class BlockLeaves extends LeavesBlock implements Patterned {
|
public class BlockLeaves extends LeavesBlock implements Patterned, IRenderTypeable {
|
||||||
public BlockLeaves(MaterialColor color) {
|
public BlockLeaves(MaterialColor color) {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).materialColor(color));
|
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).materialColor(color));
|
||||||
}
|
}
|
||||||
|
@ -35,4 +37,9 @@ public class BlockLeaves extends LeavesBlock implements Patterned {
|
||||||
public Identifier statePatternId() {
|
public Identifier statePatternId() {
|
||||||
return Patterned.BLOCK_STATES_PATTERN;
|
return Patterned.BLOCK_STATES_PATTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ERenderLayer getRenderLayer() {
|
||||||
|
return ERenderLayer.CUTOUT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package ru.betterend.blocks.entities.render;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.enums.SlabType;
|
import net.minecraft.block.enums.SlabType;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
@ -18,7 +17,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.DyeColor;
|
import net.minecraft.util.DyeColor;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
import ru.betterend.blocks.EternalPedestal;
|
import ru.betterend.blocks.EternalPedestal;
|
||||||
import ru.betterend.blocks.entities.EternalPedestalBlockEntity;
|
import ru.betterend.blocks.entities.EternalPedestalBlockEntity;
|
||||||
import ru.betterend.client.render.BeamRenderer;
|
import ru.betterend.client.render.BeamRenderer;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import ru.betterend.blocks.RunedFlavolite;
|
import ru.betterend.blocks.RunedFlavolite;
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
import ru.betterend.util.PortalFrameHelper;
|
import ru.betterend.util.PortalFrameHelper;
|
||||||
|
|
|
@ -21,12 +21,13 @@ import ru.betterend.blocks.BlockEndLotusSeed;
|
||||||
import ru.betterend.blocks.BlockEndLotusStem;
|
import ru.betterend.blocks.BlockEndLotusStem;
|
||||||
import ru.betterend.blocks.BlockEndstoneDust;
|
import ru.betterend.blocks.BlockEndstoneDust;
|
||||||
import ru.betterend.blocks.BlockGlowingMoss;
|
import ru.betterend.blocks.BlockGlowingMoss;
|
||||||
|
import ru.betterend.blocks.BlockLacugroveSapling;
|
||||||
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
||||||
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
|
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
|
||||||
import ru.betterend.blocks.BlockMossyGlowshroomSapling;
|
import ru.betterend.blocks.BlockMossyGlowshroomSapling;
|
||||||
import ru.betterend.blocks.BlockMossyPythadendronSapling;
|
|
||||||
import ru.betterend.blocks.BlockOre;
|
import ru.betterend.blocks.BlockOre;
|
||||||
import ru.betterend.blocks.BlockPath;
|
import ru.betterend.blocks.BlockPath;
|
||||||
|
import ru.betterend.blocks.BlockPythadendronSapling;
|
||||||
import ru.betterend.blocks.BlockTerrain;
|
import ru.betterend.blocks.BlockTerrain;
|
||||||
import ru.betterend.blocks.BlockTerrainPlant;
|
import ru.betterend.blocks.BlockTerrainPlant;
|
||||||
import ru.betterend.blocks.BlockUmbrellaMoss;
|
import ru.betterend.blocks.BlockUmbrellaMoss;
|
||||||
|
@ -75,7 +76,7 @@ public class EndBlocks {
|
||||||
public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", new BlockGlowingFur(MOSSY_GLOWSHROOM_SAPLING, 16));
|
public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", new BlockGlowingFur(MOSSY_GLOWSHROOM_SAPLING, 16));
|
||||||
public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD);
|
public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD);
|
||||||
|
|
||||||
public static final Block PYTHADENDRON_SAPLING = registerBlock("pythadendron_sapling", new BlockMossyPythadendronSapling());
|
public static final Block PYTHADENDRON_SAPLING = registerBlock("pythadendron_sapling", new BlockPythadendronSapling());
|
||||||
public static final Block PYTHADENDRON_LEAVES = registerBlock("pythadendron_leaves", new BlockLeaves(MaterialColor.MAGENTA));
|
public static final Block PYTHADENDRON_LEAVES = registerBlock("pythadendron_leaves", new BlockLeaves(MaterialColor.MAGENTA));
|
||||||
public static final WoodenMaterial PYTHADENDRON = new WoodenMaterial("pythadendron", MaterialColor.MAGENTA, MaterialColor.PURPLE);
|
public static final WoodenMaterial PYTHADENDRON = new WoodenMaterial("pythadendron", MaterialColor.MAGENTA, MaterialColor.PURPLE);
|
||||||
|
|
||||||
|
@ -85,6 +86,8 @@ public class EndBlocks {
|
||||||
public static final Block END_LOTUS_FLOWER = registerBlockNI("end_lotus_flower", new BlockEndLotusFlower());
|
public static final Block END_LOTUS_FLOWER = registerBlockNI("end_lotus_flower", new BlockEndLotusFlower());
|
||||||
public static final WoodenMaterial END_LOTUS = new WoodenMaterial("end_lotus", MaterialColor.LIGHT_BLUE, MaterialColor.CYAN);
|
public static final WoodenMaterial END_LOTUS = new WoodenMaterial("end_lotus", MaterialColor.LIGHT_BLUE, MaterialColor.CYAN);
|
||||||
|
|
||||||
|
public static final Block LACUGROVE_SAPLING = registerBlock("lacugrove_sapling", new BlockLacugroveSapling());
|
||||||
|
public static final Block LACUGROVE_LEAVES = registerBlock("lacugrove_leaves", new BlockLeaves(MaterialColor.CYAN));
|
||||||
public static final WoodenMaterial LACUGROVE = new WoodenMaterial("lacugrove", MaterialColor.BROWN, MaterialColor.YELLOW);
|
public static final WoodenMaterial LACUGROVE = new WoodenMaterial("lacugrove", MaterialColor.BROWN, MaterialColor.YELLOW);
|
||||||
|
|
||||||
// Small Plants //
|
// Small Plants //
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class EndFeatures {
|
||||||
// Trees //
|
// Trees //
|
||||||
public static final EndFeature MOSSY_GLOWSHROOM = new EndFeature("mossy_glowshroom", new MossyGlowshroomFeature(), 3);
|
public static final EndFeature MOSSY_GLOWSHROOM = new EndFeature("mossy_glowshroom", new MossyGlowshroomFeature(), 3);
|
||||||
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(), 3);
|
public static final EndFeature LACUGROVE = new EndFeature("lacugrove", new LacugroveFeature(), 4);
|
||||||
|
|
||||||
// Bushes //
|
// Bushes //
|
||||||
public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new PythadendronBushFeature(), 4);
|
public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new PythadendronBushFeature(), 4);
|
||||||
|
|
|
@ -135,4 +135,66 @@ public class SplineHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canGenerate(List<Vector3f> spline, float scale, BlockPos start, StructureWorldAccess world, Function<BlockState, Boolean> canReplace) {
|
||||||
|
int count = spline.size();
|
||||||
|
Vector3f vec = spline.get(0);
|
||||||
|
Mutable mut = new Mutable();
|
||||||
|
float x1 = start.getX() + vec.getX() * scale;
|
||||||
|
float y1 = start.getY() + vec.getY() * scale;
|
||||||
|
float z1 = start.getZ() + vec.getZ() * scale;
|
||||||
|
for (int i = 1; i < count; i++) {
|
||||||
|
vec = spline.get(i);
|
||||||
|
float x2 = start.getX() + vec.getX() * scale;
|
||||||
|
float y2 = start.getY() + vec.getY() * scale;
|
||||||
|
float z2 = start.getZ() + vec.getZ() * scale;
|
||||||
|
|
||||||
|
for (float py = y1; py < y2; py += 3) {
|
||||||
|
if (py - start.getY() < 10) continue;
|
||||||
|
float lerp = (py - y1) / (y2 - y1);
|
||||||
|
float x = MathHelper.lerp(lerp, x1, x2);
|
||||||
|
float z = MathHelper.lerp(lerp, z1, z2);
|
||||||
|
mut.set(x, py, z);
|
||||||
|
if (!canReplace.apply(world.getBlockState(mut))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x1 = x2;
|
||||||
|
y1 = y2;
|
||||||
|
z1 = z2;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canGenerate(List<Vector3f> spline, BlockPos start, StructureWorldAccess world, Function<BlockState, Boolean> canReplace) {
|
||||||
|
int count = spline.size();
|
||||||
|
Vector3f vec = spline.get(0);
|
||||||
|
Mutable mut = new Mutable();
|
||||||
|
float x1 = start.getX() + vec.getX();
|
||||||
|
float y1 = start.getY() + vec.getY();
|
||||||
|
float z1 = start.getZ() + vec.getZ();
|
||||||
|
for (int i = 1; i < count; i++) {
|
||||||
|
vec = spline.get(i);
|
||||||
|
float x2 = start.getX() + vec.getX();
|
||||||
|
float y2 = start.getY() + vec.getY();
|
||||||
|
float z2 = start.getZ() + vec.getZ();
|
||||||
|
|
||||||
|
for (float py = y1; py < y2; py += 3) {
|
||||||
|
if (py - start.getY() < 10) continue;
|
||||||
|
float lerp = (py - y1) / (y2 - y1);
|
||||||
|
float x = MathHelper.lerp(lerp, x1, x2);
|
||||||
|
float z = MathHelper.lerp(lerp, z1, z2);
|
||||||
|
mut.set(x, py, z);
|
||||||
|
if (!canReplace.apply(world.getBlockState(mut))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x1 = x2;
|
||||||
|
y1 = y2;
|
||||||
|
z1 = z2;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.google.common.collect.Sets;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.util.math.BlockPos.Mutable;
|
||||||
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.ServerWorldAccess;
|
import net.minecraft.world.ServerWorldAccess;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
@ -155,6 +156,102 @@ public abstract class SDF {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fillArea(ServerWorldAccess world, BlockPos center, Box box) {
|
||||||
|
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||||
|
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
||||||
|
|
||||||
|
Mutable mut = new Mutable();
|
||||||
|
for (int y = (int) box.minY; y <= box.maxY; y++) {
|
||||||
|
mut.setY(y);
|
||||||
|
for (int x = (int) box.minX; x <= box.maxX; x++) {
|
||||||
|
mut.setX(x);
|
||||||
|
for (int z = (int) box.minZ; z <= box.maxZ; z++) {
|
||||||
|
mut.setZ(z);
|
||||||
|
if (canReplace.apply(world.getBlockState(mut))) {
|
||||||
|
BlockPos fpos = mut.subtract(center);
|
||||||
|
if (this.getDistance(fpos.getX(), fpos.getY(), fpos.getZ()) < 0) {
|
||||||
|
PosInfo.create(mapWorld, addInfo, mut.toImmutable()).setState(getBlockState(mut));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
|
||||||
|
if (infos.size() > 0) {
|
||||||
|
Collections.sort(infos);
|
||||||
|
infos.forEach((info) -> {
|
||||||
|
BlockState state = postProcess.apply(info);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||||
|
});
|
||||||
|
|
||||||
|
infos.clear();
|
||||||
|
infos.addAll(addInfo.values());
|
||||||
|
Collections.sort(infos);
|
||||||
|
infos.forEach((info) -> {
|
||||||
|
if (canReplace.apply(world.getBlockState(info.getPos()))) {
|
||||||
|
BlockState state = postProcess.apply(info);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillRecursiveIgnore(ServerWorldAccess world, BlockPos start, Function<BlockState, Boolean> ignore) {
|
||||||
|
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||||
|
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
||||||
|
Set<BlockPos> blocks = Sets.newHashSet();
|
||||||
|
Set<BlockPos> ends = Sets.newHashSet();
|
||||||
|
Set<BlockPos> add = Sets.newHashSet();
|
||||||
|
ends.add(new BlockPos(0, 0, 0));
|
||||||
|
boolean run = true;
|
||||||
|
|
||||||
|
Mutable bPos = new Mutable();
|
||||||
|
|
||||||
|
while (run) {
|
||||||
|
for (BlockPos center: ends) {
|
||||||
|
for (Direction dir: Direction.values()) {
|
||||||
|
bPos.set(center).move(dir);
|
||||||
|
BlockPos wpos = bPos.add(start);
|
||||||
|
BlockState state = world.getBlockState(wpos);
|
||||||
|
boolean ign = ignore.apply(state);
|
||||||
|
if (!blocks.contains(bPos) && (ign || canReplace.apply(state))) {
|
||||||
|
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
|
||||||
|
PosInfo.create(mapWorld, addInfo, wpos).setState(ign ? state : getBlockState(bPos));
|
||||||
|
add.add(bPos.toImmutable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blocks.addAll(ends);
|
||||||
|
ends.clear();
|
||||||
|
ends.addAll(add);
|
||||||
|
add.clear();
|
||||||
|
|
||||||
|
run &= !ends.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PosInfo> infos = new ArrayList<PosInfo>(mapWorld.values());
|
||||||
|
if (infos.size() > 0) {
|
||||||
|
Collections.sort(infos);
|
||||||
|
infos.forEach((info) -> {
|
||||||
|
BlockState state = postProcess.apply(info);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||||
|
});
|
||||||
|
|
||||||
|
infos.clear();
|
||||||
|
infos.addAll(addInfo.values());
|
||||||
|
Collections.sort(infos);
|
||||||
|
infos.forEach((info) -> {
|
||||||
|
if (canReplace.apply(world.getBlockState(info.getPos()))) {
|
||||||
|
BlockState state = postProcess.apply(info);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, info.getPos(), state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void fillRecursive(StructureWorld world, BlockPos start) {
|
public void fillRecursive(StructureWorld world, BlockPos start) {
|
||||||
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
|
||||||
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
|
||||||
|
|
|
@ -18,7 +18,8 @@ public class BiomeMegalake extends EndBiome {
|
||||||
.setFogDensity(1.75F)
|
.setFogDensity(1.75F)
|
||||||
.setMusic(EndSounds.MUSIC_MEGALAKE)
|
.setMusic(EndSounds.MUSIC_MEGALAKE)
|
||||||
.setLoop(EndSounds.AMBIENT_MEGALAKE)
|
.setLoop(EndSounds.AMBIENT_MEGALAKE)
|
||||||
.setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS)
|
//.setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS)
|
||||||
|
.setSurface(EndBlocks.END_MOSS)
|
||||||
.addStructureFeature(EndStructures.MEGALAKE)
|
.addStructureFeature(EndStructures.MEGALAKE)
|
||||||
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
|
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
|
||||||
.addFeature(EndFeatures.LACUGROVE)
|
.addFeature(EndFeatures.LACUGROVE)
|
||||||
|
|
|
@ -5,13 +5,18 @@ import java.util.Random;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.LeavesBlock;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.util.math.BlockPos.Mutable;
|
||||||
|
import net.minecraft.util.math.Box;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||||
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndTags;
|
import ru.betterend.registry.EndTags;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
@ -19,9 +24,14 @@ import ru.betterend.util.MHelper;
|
||||||
import ru.betterend.util.SplineHelper;
|
import ru.betterend.util.SplineHelper;
|
||||||
import ru.betterend.util.sdf.PosInfo;
|
import ru.betterend.util.sdf.PosInfo;
|
||||||
import ru.betterend.util.sdf.SDF;
|
import ru.betterend.util.sdf.SDF;
|
||||||
|
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||||
|
import ru.betterend.util.sdf.operator.SDFSubtraction;
|
||||||
|
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||||
|
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||||
|
|
||||||
public class LacugroveFeature extends DefaultFeature {
|
public class LacugroveFeature extends DefaultFeature {
|
||||||
private static final Function<BlockState, Boolean> REPLACE;
|
private static final Function<BlockState, Boolean> REPLACE;
|
||||||
|
private static final Function<BlockState, Boolean> IGNORE;
|
||||||
private static final Function<PosInfo, BlockState> POST;
|
private static final Function<PosInfo, BlockState> POST;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,14 +41,36 @@ public class LacugroveFeature extends DefaultFeature {
|
||||||
float size = MHelper.randRange(15, 25, random);
|
float size = MHelper.randRange(15, 25, random);
|
||||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 6);
|
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 6);
|
||||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||||
float radius = MHelper.randRange(1.2F, 1.8F, random);
|
|
||||||
|
if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||||
|
/*Vector3f center = null;
|
||||||
|
for (int i = 3; i < 6; i++) {
|
||||||
|
center = spline.get(i);
|
||||||
|
float radius = MathHelper.lerp((i - 3F) / 2F, 6.5F, 3.7F) + MHelper.randRange(-0.5F, 0.5F, random);
|
||||||
|
radius *= (size - 15F) / 20F + 1F;
|
||||||
|
leavesBall(world, pos.add(center.getX(), center.getY(), center.getZ()), radius, random, noise);
|
||||||
|
}*/
|
||||||
|
float radius = MHelper.randRange(6F, 8F, random);
|
||||||
|
radius *= (size - 15F) / 20F + 1F;
|
||||||
|
Vector3f center = spline.get(4);
|
||||||
|
leavesBall(world, pos.add(center.getX(), center.getY(), center.getZ()), radius, random, noise);
|
||||||
|
|
||||||
|
radius = MHelper.randRange(1.2F, 1.8F, random);
|
||||||
SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> {
|
SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> {
|
||||||
return EndBlocks.LACUGROVE.bark.getDefaultState();
|
return EndBlocks.LACUGROVE.bark.getDefaultState();
|
||||||
});
|
});
|
||||||
|
|
||||||
function.setReplaceFunction(REPLACE);
|
function.setReplaceFunction(REPLACE);
|
||||||
function.setPostProcess(POST);
|
function.setPostProcess(POST);
|
||||||
function.fillRecursive(world, pos);
|
function.fillRecursive(world, pos);
|
||||||
|
|
||||||
|
spline = spline.subList(4, 6);
|
||||||
|
SplineHelper.fillSpline(spline, world, EndBlocks.LACUGROVE.bark.getDefaultState(), pos, REPLACE);
|
||||||
|
|
||||||
Mutable mut = new Mutable();
|
Mutable mut = new Mutable();
|
||||||
int offset = random.nextInt(2);
|
int offset = random.nextInt(2);
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
|
@ -79,12 +111,44 @@ public class LacugroveFeature extends DefaultFeature {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
|
||||||
|
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.LACUGROVE_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
||||||
|
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||||
|
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||||
|
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius - 2, 0).setSource(sphere));
|
||||||
|
sphere.fillRecursiveIgnore(world, pos, IGNORE);
|
||||||
|
//sphere.fillArea(world, pos, new Box(pos).expand(radius));
|
||||||
|
|
||||||
|
if (radius > 5) {
|
||||||
|
int count = (int) (radius * 2.5F);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
BlockPos p = pos.add(random.nextGaussian() * 1, random.nextGaussian() * 1, random.nextGaussian() * 1);
|
||||||
|
boolean place = true;
|
||||||
|
for (Direction d: Direction.values()) {
|
||||||
|
BlockState state = world.getBlockState(p.offset(d));
|
||||||
|
if (!EndBlocks.LACUGROVE.isTreeLog(state) && !state.isOf(EndBlocks.LACUGROVE_LEAVES)) {
|
||||||
|
place = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (place) {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LACUGROVE.bark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.LACUGROVE.bark);
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
REPLACE = (state) -> {
|
REPLACE = (state) -> {
|
||||||
if (state.isIn(EndTags.END_GROUND)) {
|
if (state.isIn(EndTags.END_GROUND)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (state.getBlock() == EndBlocks.PYTHADENDRON_LEAVES) {
|
if (EndBlocks.LACUGROVE.isTreeLog(state)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (state.getBlock() == EndBlocks.LACUGROVE_LEAVES) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (state.getMaterial().equals(Material.PLANT)) {
|
if (state.getMaterial().equals(Material.PLANT)) {
|
||||||
|
@ -93,6 +157,10 @@ public class LacugroveFeature extends DefaultFeature {
|
||||||
return state.getMaterial().isReplaceable();
|
return state.getMaterial().isReplaceable();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IGNORE = (state) -> {
|
||||||
|
return EndBlocks.LACUGROVE.isTreeLog(state);
|
||||||
|
};
|
||||||
|
|
||||||
POST = (info) -> {
|
POST = (info) -> {
|
||||||
if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp()) && EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) {
|
if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp()) && EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) {
|
||||||
return EndBlocks.LACUGROVE.log.getDefaultState();
|
return EndBlocks.LACUGROVE.log.getDefaultState();
|
||||||
|
|
|
@ -8,9 +8,7 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||||
|
@ -48,8 +46,6 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
||||||
private static final SDFPrimitive CONE_GLOW;
|
private static final SDFPrimitive CONE_GLOW;
|
||||||
private static final SDFPrimitive ROOTS;
|
private static final SDFPrimitive ROOTS;
|
||||||
|
|
||||||
private static final Mutable POS = new Mutable();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
|
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
|
||||||
blockPos = getPosOnSurface(world, blockPos);
|
blockPos = getPosOnSurface(world, blockPos);
|
||||||
|
@ -75,33 +71,10 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
||||||
Vector3f pos = spline.get(spline.size() - 1);
|
Vector3f pos = spline.get(spline.size() - 1);
|
||||||
float scale = MHelper.randRange(0.75F, 1.1F, random);
|
float scale = MHelper.randRange(0.75F, 1.1F, random);
|
||||||
|
|
||||||
Vector3f vec = spline.get(0);
|
if (!SplineHelper.canGenerate(spline, scale, blockPos, world, REPLACE)) {
|
||||||
float x1 = blockPos.getX() + vec.getX() * scale;
|
|
||||||
float y1 = blockPos.getY() + vec.getY() * scale;
|
|
||||||
float z1 = blockPos.getZ() + vec.getZ() * scale;
|
|
||||||
for (int i = 1; i < count; i++) {
|
|
||||||
vec = spline.get(i);
|
|
||||||
float x2 = blockPos.getX() + vec.getX() * scale;
|
|
||||||
float y2 = blockPos.getY() + vec.getY() * scale;
|
|
||||||
float z2 = blockPos.getZ() + vec.getZ() * scale;
|
|
||||||
|
|
||||||
for (float py = y1; py < y2; py += 3) {
|
|
||||||
if (py - blockPos.getY() < 10) continue;
|
|
||||||
float lerp = (py - y1) / (y2 - y1);
|
|
||||||
float x = MathHelper.lerp(lerp, x1, x2);
|
|
||||||
float z = MathHelper.lerp(lerp, z1, z2);
|
|
||||||
POS.set(x, py, z);
|
|
||||||
BlockState state = world.getBlockState(POS);
|
|
||||||
boolean generate = state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT);
|
|
||||||
if (!generate) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
x1 = x2;
|
|
||||||
y1 = y2;
|
|
||||||
z1 = z2;
|
|
||||||
}
|
|
||||||
BlocksHelper.setWithoutUpdate(world, blockPos, AIR);
|
BlocksHelper.setWithoutUpdate(world, blockPos, AIR);
|
||||||
|
|
||||||
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
|
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class LakePiece extends BasePiece {
|
||||||
}
|
}
|
||||||
minY = MathHelper.lerp(lerp, maxY - minY, 56 - minY);
|
minY = MathHelper.lerp(lerp, maxY - minY, 56 - minY);
|
||||||
pos.setY(maxY);
|
pos.setY(maxY);
|
||||||
while (chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
|
while (!chunk.getBlockState(pos).getMaterial().isReplaceable()) {
|
||||||
pos.setY(maxY ++);
|
pos.setY(maxY ++);
|
||||||
}
|
}
|
||||||
for (int y = maxY; y >= minY; y--) {
|
for (int y = maxY; y >= minY; y--) {
|
||||||
|
@ -115,10 +115,19 @@ public class LakePiece extends BasePiece {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pos.setY(MHelper.floor(minY - 1));
|
||||||
|
if (pos.getY() == 57 && chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
|
||||||
|
BlockState state = world.getBiome(pos.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||||
|
chunk.setBlockState(pos, state, false);
|
||||||
|
}
|
||||||
if (pos.getY() < 57) {
|
if (pos.getY() < 57) {
|
||||||
BlockState state = chunk.getBlockState(pos);
|
BlockState state = chunk.getBlockState(pos);
|
||||||
if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) {
|
if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) {
|
||||||
chunk.setBlockState(pos, EndBlocks.ENDSTONE_DUST.getDefaultState(), false);
|
state = EndBlocks.ENDSTONE_DUST.getDefaultState();
|
||||||
|
if (pos.getY() == 56 && random.nextBoolean()) {
|
||||||
|
state = world.getBiome(pos.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||||
|
}
|
||||||
|
chunk.setBlockState(pos, state, false);
|
||||||
pos.setY(pos.getY() - 1);
|
pos.setY(pos.getY() - 1);
|
||||||
state = chunk.getBlockState(pos);
|
state = chunk.getBlockState(pos);
|
||||||
if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) {
|
if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) {
|
||||||
|
@ -126,7 +135,6 @@ public class LakePiece extends BasePiece {
|
||||||
pos.setY(pos.getY() - 1);
|
pos.setY(pos.getY() - 1);
|
||||||
}
|
}
|
||||||
if (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
|
if (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
|
||||||
|
|
||||||
chunk.setBlockState(pos, Blocks.END_STONE.getDefaultState(), false);
|
chunk.setBlockState(pos, Blocks.END_STONE.getDefaultState(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,5 +219,8 @@
|
||||||
"block.betterend.lacugrove_stairs": "Lacugrove Stairs",
|
"block.betterend.lacugrove_stairs": "Lacugrove Stairs",
|
||||||
"block.betterend.lacugrove_stripped_bark": "Lacugrove Stripped Bark",
|
"block.betterend.lacugrove_stripped_bark": "Lacugrove Stripped Bark",
|
||||||
"block.betterend.lacugrove_stripped_log": "Lacugrove Stripped Log",
|
"block.betterend.lacugrove_stripped_log": "Lacugrove Stripped Log",
|
||||||
"block.betterend.lacugrove_trapdoor": "Lacugrove Trapdoor"
|
"block.betterend.lacugrove_trapdoor": "Lacugrove Trapdoor",
|
||||||
|
|
||||||
|
"block.betterend.lacugrove_leaves": "Lacugrove Leaves",
|
||||||
|
"block.betterend.lacugrove_sapling": "Lacugrove Sapling"
|
||||||
}
|
}
|
|
@ -205,21 +205,24 @@
|
||||||
"block.betterend.eternal_pedestal": "Вечный пьедестал",
|
"block.betterend.eternal_pedestal": "Вечный пьедестал",
|
||||||
|
|
||||||
"block.betterend.lacugrove_bark": "Кора оземангра",
|
"block.betterend.lacugrove_bark": "Кора оземангра",
|
||||||
"block.betterend.lacugrove_barrel": "Бочка",
|
"block.betterend.lacugrove_barrel": "Бочка из оземангра",
|
||||||
"block.betterend.lacugrove_button": "Кнопка",
|
"block.betterend.lacugrove_button": "Кнопка из оземангра",
|
||||||
"block.betterend.lacugrove_chest": "Сундук",
|
"block.betterend.lacugrove_chest": "Сундук из оземангра",
|
||||||
"block.betterend.lacugrove_crafting_table": "Верстак",
|
"block.betterend.lacugrove_crafting_table": "Верстак из оземангра",
|
||||||
"block.betterend.lacugrove_door": "Дверь",
|
"block.betterend.lacugrove_door": "Дверь из оземангра",
|
||||||
"block.betterend.lacugrove_fence": "Забор",
|
"block.betterend.lacugrove_fence": "Забор из оземангра",
|
||||||
"block.betterend.lacugrove_gate": "Калитка",
|
"block.betterend.lacugrove_gate": "Калитка из оземангра",
|
||||||
"block.betterend.lacugrove_ladder": "Лестница",
|
"block.betterend.lacugrove_ladder": "Лестница из оземангра",
|
||||||
"block.betterend.lacugrove_log": "Бревно",
|
"block.betterend.lacugrove_log": "Бревно оземангра",
|
||||||
"block.betterend.lacugrove_planks": "Доски",
|
"block.betterend.lacugrove_planks": "Доски из оземангра",
|
||||||
"block.betterend.lacugrove_plate": "Плита",
|
"block.betterend.lacugrove_plate": "Плита из оземангра",
|
||||||
"block.betterend.lacugrove_sign": "Табличка",
|
"block.betterend.lacugrove_sign": "Табличка из оземангра",
|
||||||
"block.betterend.lacugrove_slab": "Плита",
|
"block.betterend.lacugrove_slab": "Плита из оземангра",
|
||||||
"block.betterend.lacugrove_stairs": "Ступени",
|
"block.betterend.lacugrove_stairs": "Ступени из оземангра",
|
||||||
"block.betterend.lacugrove_stripped_bark": "Обтёсанная кора",
|
"block.betterend.lacugrove_stripped_bark": "Обтёсанная кора оземангра",
|
||||||
"block.betterend.lacugrove_stripped_log": "Обтёсанное бревно",
|
"block.betterend.lacugrove_stripped_log": "Обтёсанное бревно оземангра",
|
||||||
"block.betterend.lacugrove_trapdoor": "Люк"
|
"block.betterend.lacugrove_trapdoor": "Люк из оземангра",
|
||||||
|
|
||||||
|
"block.betterend.lacugrove_leaves": "Листья оземангра",
|
||||||
|
"block.betterend.lacugrove_sapling": "Саженец оземангра"
|
||||||
}
|
}
|
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Loading…
Add table
Add a link
Reference in a new issue