diff --git a/src/main/java/kaptainwutax/seedcracker/finder/FinderConfig.java b/src/main/java/kaptainwutax/seedcracker/finder/FinderConfig.java index d69a16a..c6a7ecd 100644 --- a/src/main/java/kaptainwutax/seedcracker/finder/FinderConfig.java +++ b/src/main/java/kaptainwutax/seedcracker/finder/FinderConfig.java @@ -1,5 +1,6 @@ package kaptainwutax.seedcracker.finder; +import kaptainwutax.seedcracker.finder.population.DesertWellFinder; import kaptainwutax.seedcracker.finder.population.DungeonFinder; import kaptainwutax.seedcracker.finder.population.EndGatewayFinder; import kaptainwutax.seedcracker.finder.population.EndPillarsFinder; @@ -83,6 +84,7 @@ public class FinderConfig { DIAMOND_ORE(DiamondOreFinder::create, Category.ORES), INFESTED_STONE_ORE(InfestedStoneOreFinder::create, Category.ORES), EMERALD_ORE(EmeraldOreFinder::create, Category.ORES), + DESERT_WELL(DesertWellFinder::create, Category.OTHERS), BIOME(BiomeFinder::create, Category.BIOMES); diff --git a/src/main/java/kaptainwutax/seedcracker/finder/population/DesertWellFinder.java b/src/main/java/kaptainwutax/seedcracker/finder/population/DesertWellFinder.java new file mode 100644 index 0000000..7151bdc --- /dev/null +++ b/src/main/java/kaptainwutax/seedcracker/finder/population/DesertWellFinder.java @@ -0,0 +1,92 @@ +package kaptainwutax.seedcracker.finder.population; + +import kaptainwutax.seedcracker.cracker.DecoratorCache; +import kaptainwutax.seedcracker.finder.Finder; +import kaptainwutax.seedcracker.finder.structure.PieceFinder; +import kaptainwutax.seedcracker.render.Cuboid; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.util.math.Vector4f; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.gen.decorator.Decorator; + +import java.util.ArrayList; +import java.util.List; + +public class DesertWellFinder extends PieceFinder { + + protected static List SEARCH_POSITIONS = buildSearchPositions(CHUNK_POSITIONS, pos -> { + return false; + }); + + public DesertWellFinder(World world, ChunkPos chunkPos) { + super(world, chunkPos, Direction.NORTH, new Vec3i(5, 6, 5)); + this.searchPositions = SEARCH_POSITIONS; + this.buildStructure(); + } + + @Override + public List findInChunk() { + Biome biome = this.world.getBiome(this.chunkPos.getCenterBlockPos().add(8, 0, 8)); + + if(DecoratorCache.get().getSalt(biome, Decorator.CHANCE_HEIGHTMAP, false) == DecoratorCache.INVALID) { + return new ArrayList<>(); + } + + List result = super.findInChunk(); + + result.forEach(pos -> { + this.renderers.add(new Cuboid(pos, new Vec3i(5, 6, 5), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f))); + }); + + return result; + } + + @Override + public boolean isValidDimension(DimensionType dimension) { + return dimension == DimensionType.OVERWORLD; + } + + protected void buildStructure() { + this.setDebug(); + BlockState sandstone = Blocks.SANDSTONE.getDefaultState(); + BlockState sandstoneSlab = Blocks.SANDSTONE_SLAB.getDefaultState(); + BlockState water = Blocks.WATER.getDefaultState(); + + this.fillWithOutline(0, 0, 0, 4, 1, 4, sandstone, sandstone, false); + this.fillWithOutline(1, 5, 1, 3, 5, 3, sandstoneSlab, sandstoneSlab, false); + this.addBlock(sandstone, 2, 5, 2); + + BlockPos p1 = new BlockPos(2, 1, 2); + this.addBlock(water, p1.getX(), p1.getY(), p1.getZ()); + + Direction.Type.HORIZONTAL.forEach(facing -> { + BlockPos p2 = p1.offset(facing); + this.addBlock(water, p2.getX(), p2.getY(), p2.getZ()); + }); + } + + public static List create(World world, ChunkPos chunkPos) { + List finders = new ArrayList<>(); + finders.add(new DesertWellFinder(world, chunkPos)); + + finders.add(new DesertWellFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z))); + finders.add(new DesertWellFinder(world, new ChunkPos(chunkPos.x, chunkPos.z - 1))); + finders.add(new DesertWellFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z - 1))); + + finders.add(new DesertWellFinder(world, new ChunkPos(chunkPos.x + 1, chunkPos.z))); + finders.add(new DesertWellFinder(world, new ChunkPos(chunkPos.x, chunkPos.z + 1))); + finders.add(new DesertWellFinder(world, new ChunkPos(chunkPos.x + 1, chunkPos.z + 1))); + + finders.add(new DesertWellFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z - 1))); + finders.add(new DesertWellFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z + 1))); + return finders; + } + +}