added search positions to dungeon finder
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package kaptainwutax.seedcracker.finder;
|
||||
|
||||
import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.DungeonData;
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
import kaptainwutax.seedcracker.util.PosIterator;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -9,15 +11,22 @@ import net.minecraft.block.entity.MobSpawnerBlockEntity;
|
||||
import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DungeonFinder extends BlockFinder {
|
||||
|
||||
protected static List<BlockPos> SEARCH_POSITIONS = buildSearchPositions(CHUNK_POSITIONS, pos -> {
|
||||
return false;
|
||||
});
|
||||
|
||||
protected static Set<BlockPos> FLOOR_POSITION = PosIterator.create(
|
||||
new BlockPos(-3, -1, -3),
|
||||
new BlockPos(3, -1, 3)
|
||||
@@ -25,6 +34,7 @@ public class DungeonFinder extends BlockFinder {
|
||||
|
||||
public DungeonFinder(World world, ChunkPos chunkPos) {
|
||||
super(world, chunkPos, Blocks.SPAWNER);
|
||||
this.searchPositions = SEARCH_POSITIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,11 +58,54 @@ public class DungeonFinder extends BlockFinder {
|
||||
return false;
|
||||
});
|
||||
|
||||
result.forEach(pos -> this.renderers.add(new Cube(pos, new Vector4f(1.0f, 0.0f, 0.0f, 1.0f))));
|
||||
Biome biome = this.world.getBiome(this.chunkPos.getCenterBlockPos().add(8, 8, 8));
|
||||
|
||||
List<BlockPos> starts = result.stream()
|
||||
.map(pos -> new BlockPos(pos.getX() & 15, pos.getY(), pos.getZ() & 15)).collect(Collectors.toList());
|
||||
|
||||
List<List<Integer>> floorCallsList = result.stream()
|
||||
.map(pos -> this.getFloorCalls(this.getDungeonSize(pos), pos)).collect(Collectors.toList());
|
||||
|
||||
result.forEach(pos -> {
|
||||
if(SeedCracker.get().onPopulationData(new DungeonData(this.chunkPos, biome, starts, floorCallsList))) {
|
||||
this.renderers.add(new Cube(pos, new Vector4f(1.0f, 0.0f, 0.0f, 1.0f)));
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Vec3i getDungeonSize(BlockPos spawnerPos) {
|
||||
for(int xo = 4; xo >= 3; xo--) {
|
||||
for(int zo = 4; zo >= 3; zo--) {
|
||||
Block block = this.world.getBlockState(spawnerPos.add(xo, -1, zo)).getBlock();
|
||||
if(block != Blocks.MOSSY_COBBLESTONE)continue;
|
||||
if(block != Blocks.COBBLESTONE)continue;
|
||||
return new Vec3i(xo, 0, zo);
|
||||
}
|
||||
}
|
||||
|
||||
return Vec3i.ZERO;
|
||||
}
|
||||
|
||||
public List<Integer> getFloorCalls(Vec3i dungeonSize, BlockPos spawnerPos) {
|
||||
List<Integer> floorCalls = new ArrayList<>();
|
||||
|
||||
for(int xo = -dungeonSize.getX(); xo <= dungeonSize.getX(); xo++) {
|
||||
for(int zo = -dungeonSize.getZ(); zo <= dungeonSize.getZ(); zo++) {
|
||||
Block block = this.world.getBlockState(spawnerPos.add(xo, -1, zo)).getBlock();
|
||||
|
||||
if(block == Blocks.MOSSY_COBBLESTONE) {
|
||||
floorCalls.add(DungeonData.MOSSY_COBBLESTONE_CALL);
|
||||
} else if(block == Blocks.COBBLESTONE) {
|
||||
floorCalls.add(DungeonData.COBBLESTONE_CALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return floorCalls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidDimension(DimensionType dimension) {
|
||||
return dimension == DimensionType.OVERWORLD;
|
||||
|
||||
Reference in New Issue
Block a user