api changes
This commit is contained in:
@@ -2,6 +2,7 @@ package kaptainwutax.seedcracker;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import kaptainwutax.seedcracker.finder.*;
|
||||
import kaptainwutax.seedcracker.util.FinderBuilder;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -11,11 +12,17 @@ import java.util.List;
|
||||
public class FinderQueue {
|
||||
|
||||
private final static FinderQueue INSTANCE = new FinderQueue();
|
||||
|
||||
private List<FinderBuilder> finderBuilders = new ArrayList<>();
|
||||
private List<Finder> activeFinders = new ArrayList<>();
|
||||
|
||||
|
||||
public FinderQueue() {
|
||||
|
||||
private FinderQueue() {
|
||||
this.finderBuilders.add(DungeonFinder::create);
|
||||
this.finderBuilders.add(BuriedTreasureFinder::create);
|
||||
this.finderBuilders.add(SwampHutFinder::create);
|
||||
this.finderBuilders.add(DesertTempleFinder::create);
|
||||
this.finderBuilders.add(JungleTempleFinder::create);
|
||||
this.finderBuilders.add(EndPillarsFinder::create);
|
||||
}
|
||||
|
||||
public static FinderQueue get() {
|
||||
@@ -23,26 +30,18 @@ public class FinderQueue {
|
||||
}
|
||||
|
||||
public void onChunkData(World world, ChunkPos chunkPos) {
|
||||
BuriedTreasureFinder buriedTreasure = new BuriedTreasureFinder(world, chunkPos);
|
||||
buriedTreasure.findInChunk();
|
||||
this.finderBuilders.forEach(finderBuilder -> {
|
||||
List<Finder> finders = finderBuilder.build(world, chunkPos);
|
||||
|
||||
DungeonFinder dungeonFinder = new DungeonFinder(world, chunkPos);
|
||||
dungeonFinder.findInChunk();
|
||||
finders.forEach(finder -> {
|
||||
if(finder.isValidDimension(finder.getWorld().dimension.getType())) {
|
||||
finder.findInChunk();
|
||||
this.activeFinders.add(finder);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
SwampHutFinder swampHutFinder = new SwampHutFinder(world, chunkPos);
|
||||
swampHutFinder.findInChunk();
|
||||
|
||||
DesertTempleFinder desertTempleFinder = new DesertTempleFinder(world, chunkPos);
|
||||
desertTempleFinder.findInChunk();
|
||||
|
||||
JungleTempleFinder jungleTempleFinder = new JungleTempleFinder(world, chunkPos);
|
||||
jungleTempleFinder.findInChunk();
|
||||
|
||||
this.activeFinders.add(buriedTreasure);
|
||||
this.activeFinders.add(dungeonFinder);
|
||||
this.activeFinders.add(swampHutFinder);
|
||||
this.activeFinders.add(desertTempleFinder);
|
||||
this.activeFinders.add(jungleTempleFinder);
|
||||
this.activeFinders.removeIf(Finder::isUseless);
|
||||
}
|
||||
|
||||
public void renderFinders() {
|
||||
@@ -51,8 +50,6 @@ public class FinderQueue {
|
||||
//Makes it render through blocks.
|
||||
GlStateManager.disableDepthTest();
|
||||
|
||||
this.activeFinders.removeIf(Finder::isUseless);
|
||||
|
||||
this.activeFinders.forEach(finder -> {
|
||||
if(finder.shouldRender()) {
|
||||
finder.render();
|
||||
|
||||
@@ -2,9 +2,13 @@ package kaptainwutax.seedcracker;
|
||||
|
||||
import kaptainwutax.seedcracker.render.RenderQueue;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class SeedCracker implements ModInitializer {
|
||||
|
||||
public static final Logger LOG = LogManager.getLogger("Seed Cracker");
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
RenderQueue.get().add("hand", FinderQueue.get()::renderFinders);
|
||||
|
||||
@@ -5,6 +5,7 @@ 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.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -16,17 +17,17 @@ public abstract class AbstractTempleFinder extends Finder {
|
||||
protected List<PieceFinder> finders = new ArrayList<>();
|
||||
protected final Vec3i size;
|
||||
|
||||
protected Map<BlockPos, Vec3i> posToLayout = new HashMap<>();
|
||||
|
||||
public AbstractTempleFinder(World world, ChunkPos chunkPos, Vec3i size) {
|
||||
super(world, chunkPos);
|
||||
|
||||
Direction.Type.HORIZONTAL.forEach(direction -> {
|
||||
PieceFinder finder = new PieceFinder(world, chunkPos, direction, size, pos -> {
|
||||
if(pos.getX() != 0)return false;
|
||||
if(pos.getY() < 63)return false;
|
||||
if(pos.getZ() != 0)return false;
|
||||
return true;
|
||||
PieceFinder finder = new PieceFinder(world, chunkPos, direction, size);
|
||||
|
||||
finder.searchPositions.removeIf(pos -> {
|
||||
if(pos.getX() != 0)return true;
|
||||
if(pos.getY() < 63)return true;
|
||||
if(pos.getZ() != 0)return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
buildStructure(finder);
|
||||
@@ -36,14 +37,15 @@ public abstract class AbstractTempleFinder extends Finder {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findInChunk() {
|
||||
List<BlockPos> result = new ArrayList<>();
|
||||
public List<BlockPos> findInChunkPiece(PieceFinder pieceFinder) {
|
||||
return pieceFinder.findInChunk();
|
||||
}
|
||||
|
||||
this.finders.forEach(finder -> {
|
||||
List<BlockPos> rawResult = finder.findInChunk();
|
||||
rawResult.forEach(raw -> posToLayout.put(raw, finder.getLayout()));
|
||||
result.addAll(rawResult);
|
||||
public Map<PieceFinder, List<BlockPos>> findInChunkPieces() {
|
||||
Map<PieceFinder, List<BlockPos>> result = new HashMap<>();
|
||||
|
||||
this.finders.forEach(pieceFinder -> {
|
||||
result.put(pieceFinder, this.findInChunkPiece(pieceFinder));
|
||||
});
|
||||
|
||||
return result;
|
||||
@@ -51,4 +53,8 @@ public abstract class AbstractTempleFinder extends Finder {
|
||||
|
||||
public abstract void buildStructure(PieceFinder finder);
|
||||
|
||||
@Override
|
||||
public boolean isValidDimension(DimensionType dimension) {
|
||||
return dimension == DimensionType.OVERWORLD;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,24 @@ import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class BlockFinder extends Finder {
|
||||
|
||||
private Set<BlockState> targetBlockStates = new HashSet<>();
|
||||
protected List<BlockPos> searchPositions = new ArrayList<>();
|
||||
|
||||
public BlockFinder(World world, ChunkPos chunkPos, Block block) {
|
||||
super(world, chunkPos);
|
||||
this.searchPositions.addAll(CHUNK_POSITIONS);
|
||||
this.targetBlockStates.addAll(block.getStateFactory().getStates());
|
||||
}
|
||||
|
||||
public BlockFinder(World world, ChunkPos chunkPos, BlockState blockState) {
|
||||
public BlockFinder(World world, ChunkPos chunkPos, BlockState... blockStates) {
|
||||
super(world, chunkPos);
|
||||
this.targetBlockStates.add(blockState);
|
||||
this.searchPositions.addAll(CHUNK_POSITIONS);
|
||||
this.targetBlockStates.addAll(Arrays.stream(blockStates).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,7 +34,7 @@ public abstract class BlockFinder extends Finder {
|
||||
ChunkWrapper chunkWrapper = new ChunkWrapper(this.world, this.chunkPos);
|
||||
Chunk chunk = chunkWrapper.getChunk();
|
||||
|
||||
for(BlockPos blockPos: CHUNK_POSITIONS) {
|
||||
for(BlockPos blockPos: this.searchPositions) {
|
||||
BlockState currentState = chunk.getBlockState(blockPos);
|
||||
|
||||
if(this.targetBlockStates.contains(currentState)) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
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;
|
||||
@@ -26,8 +27,16 @@ public class BuriedTreasureFinder extends BlockFinder {
|
||||
}
|
||||
|
||||
public BuriedTreasureFinder(World world, ChunkPos chunkPos) {
|
||||
|
||||
super(world, chunkPos, Blocks.CHEST);
|
||||
|
||||
this.searchPositions.removeIf(pos -> {
|
||||
//Buried treasure chests always generate at (9, 9) within a chunk.
|
||||
int localX = pos.getX() & 15;
|
||||
int localZ = pos.getZ() & 15;
|
||||
//if(localX != 9 || localZ != 9)return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,11 +45,6 @@ public class BuriedTreasureFinder extends BlockFinder {
|
||||
List<BlockPos> result = super.findInChunk();
|
||||
|
||||
result.removeIf(pos -> {
|
||||
//Buried treasure chests always generate at (9, 9) within a chunk.
|
||||
int localX = pos.getX() & 15;
|
||||
int localZ = pos.getZ() & 15;
|
||||
if(localX != 9 || localZ != 9)return true;
|
||||
|
||||
//Only so many blocks can hold a treasure chest.
|
||||
BlockState chestHolder = world.getBlockState(pos.down());
|
||||
if(!CHEST_HOLDERS.contains(chestHolder))return true;
|
||||
@@ -58,4 +62,15 @@ public class BuriedTreasureFinder extends BlockFinder {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidDimension(DimensionType dimension) {
|
||||
return dimension == DimensionType.OVERWORLD;
|
||||
}
|
||||
|
||||
public static List<Finder> create(World world, ChunkPos chunkPos) {
|
||||
List<Finder> finders = new ArrayList<>();
|
||||
finders.add(new BuriedTreasureFinder(world, chunkPos));
|
||||
return finders;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package kaptainwutax.seedcracker.finder;
|
||||
|
||||
import kaptainwutax.seedcracker.render.Cube;
|
||||
import kaptainwutax.seedcracker.render.Cuboid;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -14,7 +13,9 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DesertTempleFinder extends AbstractTempleFinder {
|
||||
|
||||
@@ -24,17 +25,22 @@ public class DesertTempleFinder extends AbstractTempleFinder {
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findInChunk() {
|
||||
List<BlockPos> result = super.findInChunk();
|
||||
Map<PieceFinder, List<BlockPos>> result = super.findInChunkPieces();
|
||||
List<BlockPos> combinedResult = new ArrayList<>();
|
||||
|
||||
result.removeIf(pos -> {
|
||||
Biome biome = world.getBiome(pos);
|
||||
if(!biome.hasStructureFeature(Feature.DESERT_PYRAMID))return true;
|
||||
result.forEach((pieceFinder, positions) -> {
|
||||
positions.removeIf(pos -> {
|
||||
Biome biome = world.getBiome(pos);
|
||||
if(!biome.hasStructureFeature(Feature.DESERT_PYRAMID))return true;
|
||||
|
||||
return false;
|
||||
return false;
|
||||
});
|
||||
|
||||
combinedResult.addAll(positions);
|
||||
positions.forEach(pos -> this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f))));
|
||||
});
|
||||
|
||||
result.forEach(pos -> this.renderers.add(new Cuboid(pos, this.posToLayout.get(pos), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f))));
|
||||
return result;
|
||||
return combinedResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,5 +211,14 @@ public class DesertTempleFinder extends AbstractTempleFinder {
|
||||
finder.addBlock(Blocks.CHISELED_SANDSTONE.getDefaultState(), 10, -10, 13);
|
||||
finder.addBlock(Blocks.CUT_SANDSTONE.getDefaultState(), 10, -11, 13);
|
||||
}
|
||||
|
||||
public static List<Finder> create(World world, ChunkPos chunkPos) {
|
||||
List<Finder> finders = new ArrayList<>();
|
||||
finders.add(new DesertTempleFinder(world, chunkPos));
|
||||
finders.add(new DesertTempleFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z)));
|
||||
finders.add(new DesertTempleFinder(world, new ChunkPos(chunkPos.x, chunkPos.z - 1)));
|
||||
finders.add(new DesertTempleFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z - 1)));
|
||||
return finders;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -51,4 +53,26 @@ public class DungeonFinder extends BlockFinder {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidDimension(DimensionType dimension) {
|
||||
return dimension == DimensionType.OVERWORLD;
|
||||
}
|
||||
|
||||
public static List<Finder> create(World world, ChunkPos chunkPos) {
|
||||
List<Finder> finders = new ArrayList<>();
|
||||
finders.add(new DungeonFinder(world, chunkPos));
|
||||
|
||||
finders.add(new DungeonFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z)));
|
||||
finders.add(new DungeonFinder(world, new ChunkPos(chunkPos.x, chunkPos.z - 1)));
|
||||
finders.add(new DungeonFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z - 1)));
|
||||
|
||||
finders.add(new DungeonFinder(world, new ChunkPos(chunkPos.x + 1, chunkPos.z)));
|
||||
finders.add(new DungeonFinder(world, new ChunkPos(chunkPos.x, chunkPos.z + 1)));
|
||||
finders.add(new DungeonFinder(world, new ChunkPos(chunkPos.x + 1, chunkPos.z + 1)));
|
||||
|
||||
finders.add(new DungeonFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z - 1)));
|
||||
finders.add(new DungeonFinder(world, new ChunkPos(chunkPos.x - 1, chunkPos.z + 1)));
|
||||
return finders;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -37,9 +38,21 @@ public abstract class Finder {
|
||||
this.chunkPos = chunkPos;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
public ChunkPos getChunkPos() {
|
||||
return this.chunkPos;
|
||||
}
|
||||
|
||||
public abstract List<BlockPos> findInChunk();
|
||||
|
||||
public boolean shouldRender() {
|
||||
DimensionType finderDim = this.world.dimension.getType();
|
||||
DimensionType playerDim = mc.player.world.dimension.getType();
|
||||
|
||||
if(finderDim != playerDim)return false;
|
||||
Vec3d playerPos = mc.player.getPos();
|
||||
|
||||
double distance = playerPos.squaredDistanceTo(
|
||||
@@ -60,4 +73,6 @@ public abstract class Finder {
|
||||
return this.renderers.isEmpty();
|
||||
}
|
||||
|
||||
public abstract boolean isValidDimension(DimensionType dimension);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JungleTempleFinder extends AbstractTempleFinder {
|
||||
|
||||
@@ -23,41 +25,46 @@ public class JungleTempleFinder extends AbstractTempleFinder {
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findInChunk() {
|
||||
List<BlockPos> result = super.findInChunk();
|
||||
Map<PieceFinder, List<BlockPos>> result = super.findInChunkPieces();
|
||||
List<BlockPos> combinedResult = new ArrayList<>();
|
||||
|
||||
result.removeIf(pos -> {
|
||||
Biome biome = world.getBiome(pos);
|
||||
if(!biome.hasStructureFeature(Feature.JUNGLE_TEMPLE))return true;
|
||||
result.forEach((pieceFinder, positions) -> {
|
||||
positions.removeIf(pos -> {
|
||||
Biome biome = world.getBiome(pos);
|
||||
if(!biome.hasStructureFeature(Feature.JUNGLE_TEMPLE))return true;
|
||||
|
||||
return false;
|
||||
return false;
|
||||
});
|
||||
|
||||
combinedResult.addAll(positions);
|
||||
positions.forEach(pos -> this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f))));
|
||||
});
|
||||
|
||||
result.forEach(pos -> this.renderers.add(new Cuboid(pos, this.posToLayout.get(pos), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f))));
|
||||
return result;
|
||||
return combinedResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildStructure(PieceFinder finder) {
|
||||
BlockState blockState_1 = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.EAST);
|
||||
BlockState blockState_2 = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.WEST);
|
||||
BlockState blockState_3 = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.SOUTH);
|
||||
BlockState blockState_4 = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.NORTH);
|
||||
finder.addBlock(blockState_4, 5, 9, 6);
|
||||
finder.addBlock(blockState_4, 6, 9, 6);
|
||||
finder.addBlock(blockState_3, 5, 9, 8);
|
||||
finder.addBlock(blockState_3, 6, 9, 8);
|
||||
finder.addBlock(blockState_4, 4, 0, 0);
|
||||
finder.addBlock(blockState_4, 5, 0, 0);
|
||||
finder.addBlock(blockState_4, 6, 0, 0);
|
||||
finder.addBlock(blockState_4, 7, 0, 0);
|
||||
finder.addBlock(blockState_4, 4, 1, 8);
|
||||
finder.addBlock(blockState_4, 4, 2, 9);
|
||||
finder.addBlock(blockState_4, 4, 3, 10);
|
||||
finder.addBlock(blockState_4, 7, 1, 8);
|
||||
finder.addBlock(blockState_4, 7, 2, 9);
|
||||
finder.addBlock(blockState_4, 7, 3, 10);
|
||||
finder.addBlock(blockState_1, 4, 4, 5);
|
||||
finder.addBlock(blockState_2, 7, 4, 5);
|
||||
BlockState eastStairs = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.EAST);
|
||||
BlockState westStairs = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.WEST);
|
||||
BlockState southStairs = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.SOUTH);
|
||||
BlockState northStairs = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.NORTH);
|
||||
finder.addBlock(northStairs, 5, 9, 6);
|
||||
finder.addBlock(northStairs, 6, 9, 6);
|
||||
finder.addBlock(southStairs, 5, 9, 8);
|
||||
finder.addBlock(southStairs, 6, 9, 8);
|
||||
finder.addBlock(northStairs, 4, 0, 0);
|
||||
finder.addBlock(northStairs, 5, 0, 0);
|
||||
finder.addBlock(northStairs, 6, 0, 0);
|
||||
finder.addBlock(northStairs, 7, 0, 0);
|
||||
finder.addBlock(northStairs, 4, 1, 8);
|
||||
finder.addBlock(northStairs, 4, 2, 9);
|
||||
finder.addBlock(northStairs, 4, 3, 10);
|
||||
finder.addBlock(northStairs, 7, 1, 8);
|
||||
finder.addBlock(northStairs, 7, 2, 9);
|
||||
finder.addBlock(northStairs, 7, 3, 10);
|
||||
finder.addBlock(eastStairs, 4, 4, 5);
|
||||
finder.addBlock(westStairs, 7, 4, 5);
|
||||
finder.addBlock((Blocks.TRIPWIRE_HOOK.getDefaultState().with(TripwireHookBlock.FACING, Direction.EAST)).with(TripwireHookBlock.ATTACHED, true), 1, -3, 8);
|
||||
finder.addBlock((Blocks.TRIPWIRE_HOOK.getDefaultState().with(TripwireHookBlock.FACING, Direction.WEST)).with(TripwireHookBlock.ATTACHED, true), 4, -3, 8);
|
||||
finder.addBlock(((Blocks.TRIPWIRE.getDefaultState().with(TripwireBlock.EAST, true)).with(TripwireBlock.WEST, true)).with(TripwireBlock.ATTACHED, true), 2, -3, 8);
|
||||
@@ -113,5 +120,11 @@ public class JungleTempleFinder extends AbstractTempleFinder {
|
||||
finder.addBlock(Blocks.STICKY_PISTON.getDefaultState().with(PistonBlock.FACING, Direction.WEST), 10, -1, 8);
|
||||
finder.addBlock(Blocks.REPEATER.getDefaultState().with(RepeaterBlock.FACING, Direction.NORTH), 10, -2, 10);
|
||||
}
|
||||
|
||||
public static List<Finder> create(World world, ChunkPos chunkPos) {
|
||||
List<Finder> finders = new ArrayList<>();
|
||||
finders.add(new JungleTempleFinder(world, chunkPos));
|
||||
return finders;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,36 +8,32 @@ import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class PieceFinder extends Finder {
|
||||
|
||||
protected Map<BlockPos, BlockState> structure = new HashMap<>();
|
||||
private MutableIntBoundingBox boundingBox;
|
||||
private final Predicate<BlockPos> searchPredicate;
|
||||
protected List<BlockPos> searchPositions = new ArrayList<>();
|
||||
|
||||
protected Direction facing;
|
||||
private BlockMirror mirror;
|
||||
private BlockRotation rotation;
|
||||
|
||||
//SizeX, width here for clarity when comparing with original code.
|
||||
protected int width;
|
||||
|
||||
//SizeY, width here for clarity when comparing with original code.
|
||||
protected int height;
|
||||
|
||||
//SizeZ, width here for clarity when comparing with original code.
|
||||
protected int depth;
|
||||
|
||||
public PieceFinder(World world, ChunkPos chunkPos, Direction facing, Vec3i size, Predicate<BlockPos> searchPredicate) {
|
||||
public PieceFinder(World world, ChunkPos chunkPos, Direction facing, Vec3i size) {
|
||||
super(world, chunkPos);
|
||||
this.setOrientation(facing);
|
||||
this.searchPositions.addAll(CHUNK_POSITIONS);
|
||||
|
||||
this.setOrientation(facing);
|
||||
this.width = size.getX();
|
||||
this.height = size.getY();
|
||||
this.depth = size.getZ();
|
||||
@@ -53,8 +49,6 @@ public class PieceFinder extends Finder {
|
||||
size.getZ() - 1, size.getY() - 1, size.getX() - 1
|
||||
);
|
||||
}
|
||||
|
||||
this.searchPredicate = searchPredicate;
|
||||
}
|
||||
|
||||
public Vec3i getLayout() {
|
||||
@@ -72,9 +66,7 @@ public class PieceFinder extends Finder {
|
||||
ChunkWrapper chunkWrapper = new ChunkWrapper(this.world, this.chunkPos);
|
||||
Chunk chunk = chunkWrapper.getChunk();
|
||||
|
||||
for(BlockPos center: CHUNK_POSITIONS) {
|
||||
if(!this.searchPredicate.test(center))continue;
|
||||
|
||||
for(BlockPos center: this.searchPositions) {
|
||||
boolean found = true;
|
||||
|
||||
for(Map.Entry<BlockPos, BlockState> entry: this.structure.entrySet()) {
|
||||
@@ -212,4 +204,8 @@ public class PieceFinder extends Finder {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidDimension(DimensionType dimension) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SwampHutFinder extends AbstractTempleFinder {
|
||||
|
||||
@@ -24,17 +26,22 @@ public class SwampHutFinder extends AbstractTempleFinder {
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findInChunk() {
|
||||
List<BlockPos> result = super.findInChunk();
|
||||
Map<PieceFinder, List<BlockPos>> result = super.findInChunkPieces();
|
||||
List<BlockPos> combinedResult = new ArrayList<>();
|
||||
|
||||
result.removeIf(pos -> {
|
||||
Biome biome = world.getBiome(pos);
|
||||
if(!biome.hasStructureFeature(Feature.SWAMP_HUT))return true;
|
||||
result.forEach((pieceFinder, positions) -> {
|
||||
positions.removeIf(pos -> {
|
||||
Biome biome = world.getBiome(pos);
|
||||
if(!biome.hasStructureFeature(Feature.SWAMP_HUT))return true;
|
||||
|
||||
return false;
|
||||
return false;
|
||||
});
|
||||
|
||||
combinedResult.addAll(positions);
|
||||
positions.forEach(pos -> this.renderers.add(new Cuboid(pos, pieceFinder.getLayout(), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f))));
|
||||
});
|
||||
|
||||
result.forEach(pos -> this.renderers.add(new Cuboid(pos, this.posToLayout.get(pos), new Vector4f(1.0f, 0.0f, 1.0f, 1.0f))));
|
||||
return result;
|
||||
return combinedResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,4 +81,10 @@ public class SwampHutFinder extends AbstractTempleFinder {
|
||||
finder.addBlock(southStairs.with(StairsBlock.SHAPE, StairShape.OUTER_RIGHT), 6, 4, 8);
|
||||
}
|
||||
|
||||
public static List<Finder> create(World world, ChunkPos chunkPos) {
|
||||
List<Finder> finders = new ArrayList<>();
|
||||
finders.add(new SwampHutFinder(world, chunkPos));
|
||||
return finders;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user