various optimizations, color changes and renderer additions
This commit is contained in:
@@ -31,6 +31,10 @@ public abstract class DecoratorData extends SeedData {
|
||||
|
||||
public abstract boolean testDecorator(Rand rand);
|
||||
|
||||
public ChunkPos getChunkPos() {
|
||||
return this.chunkPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj == this)return true;
|
||||
|
||||
@@ -22,28 +22,23 @@ public class DungeonData extends DecoratorData {
|
||||
public static final Integer COBBLESTONE_CALL = 0;
|
||||
public static final Integer MOSSY_COBBLESTONE_CALL = 1;
|
||||
|
||||
private List<BlockPos> starts;
|
||||
private BlockPos start;
|
||||
private final List<List<Integer>> floorCallsList;
|
||||
|
||||
public DungeonData(ChunkPos chunkPos, Biome biome, List<BlockPos> starts, List<List<Integer>> floorCallsList) {
|
||||
public DungeonData(ChunkPos chunkPos, Biome biome, BlockPos start, List<List<Integer>> floorCallsList) {
|
||||
super(chunkPos, SALT, biome);
|
||||
this.starts = starts;
|
||||
this.start = start;
|
||||
this.floorCallsList = floorCallsList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testDecorator(Rand rand) {
|
||||
if(this.starts.isEmpty())return true;
|
||||
|
||||
//TODO: This currently only supports 1 dungeon per chunk.
|
||||
BlockPos start = this.starts.get(0);
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
int x = rand.nextInt(16);
|
||||
int z = rand.nextInt(16);
|
||||
int y = rand.nextInt(256);
|
||||
|
||||
if(y == start.getY() && x == start.getX() && z == start.getZ()) {
|
||||
if(y == this.start.getY() && x == this.start.getX() && z == this.start.getZ()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -54,6 +49,10 @@ public class DungeonData extends DecoratorData {
|
||||
return false;
|
||||
}
|
||||
|
||||
public BlockPos getStart() {
|
||||
return this.start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBits() {
|
||||
return BITS;
|
||||
|
||||
@@ -48,9 +48,10 @@ public class DesertWellFinder extends PieceFinder {
|
||||
List<BlockPos> result = super.findInChunk();
|
||||
|
||||
result.forEach(pos -> {
|
||||
if(SeedCracker.get().getDataStorage().addBaseData(new DesertWellData(this.chunkPos, biome, pos.add(2, 1, 2)))) {
|
||||
this.renderers.add(new Cuboid(pos, SIZE, new Vector4f(0.5f, 0.5f, 1.0f, 1.0f)));
|
||||
this.renderers.add(new Cube(pos.add(2, 1, 2), new Vector4f(0.5f, 0.5f, 1.0f, 1.0f)));
|
||||
pos = pos.add(2, 1, 2);
|
||||
if(SeedCracker.get().getDataStorage().addBaseData(new DesertWellData(new ChunkPos(pos), biome, pos))) {
|
||||
this.renderers.add(new Cuboid(pos.add(-2, -1, -2), SIZE, new Vector4f(0.5f, 0.5f, 1.0f, 1.0f)));
|
||||
this.renderers.add(new Cube(pos, new Vector4f(0.5f, 0.5f, 1.0f, 1.0f)));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class DungeonFinder extends BlockFinder {
|
||||
.map(pos -> this.getFloorCalls(this.getDungeonSize(pos), pos)).collect(Collectors.toList());
|
||||
|
||||
result.forEach(pos -> {
|
||||
if(SeedCracker.get().getDataStorage().addBaseData(new DungeonData(this.chunkPos, biome, starts, floorCallsList))) {
|
||||
if(SeedCracker.get().getDataStorage().addBaseData(new DungeonData(this.chunkPos, biome, starts.get(0), floorCallsList))) {
|
||||
this.renderers.add(new Cube(pos, new Vector4f(1.0f, 0.0f, 0.0f, 1.0f)));
|
||||
Vec3i size = this.getDungeonSize(pos);
|
||||
this.renderers.add(new Cuboid(pos.subtract(size), pos.add(size).add(1, -1, 1), new Vector4f(1.0f, 0.0f, 0.0f, 1.0f)));
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package kaptainwutax.seedcracker.finder.structure;
|
||||
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
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;
|
||||
@@ -54,6 +57,12 @@ public abstract class AbstractTempleFinder extends Finder {
|
||||
|
||||
protected abstract StructureFeature<?> getStructureFeature();
|
||||
|
||||
public void addRenderers(PieceFinder pieceFinder, BlockPos origin, Vector4f color) {
|
||||
this.renderers.add(new Cuboid(origin, pieceFinder.getLayout(), color));
|
||||
BlockPos chunkStart = new BlockPos(origin.getX() & -16, origin.getY(), origin.getZ() & -16);
|
||||
this.renderers.add(new Cube(chunkStart, color));
|
||||
}
|
||||
|
||||
public Map<PieceFinder, List<BlockPos>> findInChunkPieces() {
|
||||
Map<PieceFinder, List<BlockPos>> result = new HashMap<>();
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
@@ -36,8 +35,8 @@ public class DesertTempleFinder extends AbstractTempleFinder {
|
||||
combinedResult.addAll(positions);
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if( SeedCracker.get().getDataStorage().addBaseData(new StructureData(this.chunkPos, StructureFeatures.DESERT_PYRAMID))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
if(SeedCracker.get().getDataStorage().addBaseData(new StructureData(this.chunkPos, StructureFeatures.DESERT_PYRAMID))) {
|
||||
this.addRenderers(pieceFinder, pos, new Vector4f(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,9 @@ 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.feature.Feature;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -24,6 +26,7 @@ import java.util.Map;
|
||||
public class EndCityFinder extends Finder {
|
||||
|
||||
protected static List<BlockPos> SEARCH_POSITIONS = buildSearchPositions(CHUNK_POSITIONS, pos -> {
|
||||
if(pos.getY() > 90)return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -74,6 +77,12 @@ public class EndCityFinder extends Finder {
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findInChunk() {
|
||||
Biome biome = this.world.getBiome(this.chunkPos.getCenterBlockPos().add(9, 0, 9));
|
||||
|
||||
if(!biome.hasStructureFeature(Feature.END_CITY)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Map<PieceFinder, List<BlockPos>> result = this.findInChunkPieces();
|
||||
List<BlockPos> combinedResult = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.enums.WallMountLocation;
|
||||
import net.minecraft.block.enums.WireConnection;
|
||||
@@ -37,7 +36,7 @@ public class JungleTempleFinder extends AbstractTempleFinder {
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if(SeedCracker.get().getDataStorage().addBaseData(new StructureData(this.chunkPos, StructureFeatures.JUNGLE_TEMPLE))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
this.addRenderers(pieceFinder, pos, new Vector4f(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -176,8 +176,8 @@ public class ShipwreckFinder extends BlockFinder {
|
||||
|
||||
if((mutablePos.getX() & 0xf) == 0 && (mutablePos.getZ() & 0xf) == 0) {
|
||||
if(SeedCracker.get().getDataStorage().addBaseData(new StructureData(new ChunkPos(mutablePos), StructureFeatures.SHIPWRECK))) {
|
||||
this.renderers.add(new Cuboid(box, new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
this.renderers.add(new Cube(new ChunkPos(mutablePos).getCenterBlockPos().offset(Direction.UP, mutablePos.getY()), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
this.renderers.add(new Cuboid(box, new Vector4f(0.0f, 1.0f, 1.0f, 1.0f)));
|
||||
this.renderers.add(new Cube(new ChunkPos(mutablePos).getCenterBlockPos().offset(Direction.UP, mutablePos.getY()), new Vector4f(0.0f, 1.0f, 1.0f, 1.0f)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import kaptainwutax.seedcracker.SeedCracker;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureData;
|
||||
import kaptainwutax.seedcracker.cracker.structure.StructureFeatures;
|
||||
import kaptainwutax.seedcracker.finder.Finder;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
@@ -38,7 +37,7 @@ public class SwampHutFinder extends AbstractTempleFinder {
|
||||
|
||||
positions.forEach(pos -> {
|
||||
if(SeedCracker.get().getDataStorage().addBaseData(new StructureData(this.chunkPos, StructureFeatures.SWAMP_HUT))) {
|
||||
this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f)));
|
||||
this.addRenderers(pieceFinder, pos, new Vector4f(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user