Added dungeon finder

This commit is contained in:
Unknown
2019-10-09 19:39:26 -04:00
parent d0458f80f9
commit 71500af23f
4 changed files with 86 additions and 1 deletions
@@ -2,6 +2,7 @@ package kaptainwutax.seedcracker;
import com.mojang.blaze3d.platform.GlStateManager;
import kaptainwutax.seedcracker.finder.BuriedTreasureFinder;
import kaptainwutax.seedcracker.finder.DungeonFinder;
import kaptainwutax.seedcracker.finder.Finder;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
@@ -26,7 +27,12 @@ public class FinderQueue {
public void onChunkData(World world, ChunkPos chunkPos) {
BuriedTreasureFinder buriedTreasure = new BuriedTreasureFinder(world, chunkPos);
buriedTreasure.findInChunk();
DungeonFinder dungeonFinder = new DungeonFinder(world, chunkPos);
dungeonFinder.findInChunk();
this.activeFinders.add(buriedTreasure);
this.activeFinders.add(dungeonFinder);
}
public void renderFinders() {
@@ -3,6 +3,7 @@ package kaptainwutax.seedcracker.finder;
import kaptainwutax.seedcracker.render.Cube;
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.world.World;
@@ -52,7 +53,7 @@ public class BuriedTreasureFinder extends BlockFinder {
return false;
});
result.forEach(pos -> this.renderers.add(new Cube(pos)));
result.forEach(pos -> this.renderers.add(new Cube(pos, new Vector4f(1.0f, 1.0f, 0.0f, 1.0f))));
return result;
}
@@ -0,0 +1,54 @@
package kaptainwutax.seedcracker.finder;
import kaptainwutax.seedcracker.render.Cube;
import kaptainwutax.seedcracker.util.PosIterator;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
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.world.World;
import java.util.List;
import java.util.Set;
public class DungeonFinder extends BlockFinder {
protected static Set<BlockPos> FLOOR_POSITION = PosIterator.create(
new BlockPos(-3, -1, -3),
new BlockPos(3, -1, 3)
);
public DungeonFinder(World world, ChunkPos chunkPos) {
super(world, chunkPos, Blocks.SPAWNER);
}
@Override
public List<BlockPos> findInChunk() {
//Gets all the positions with a mob spawner in the chunk.
List<BlockPos> result = super.findInChunk();
result.removeIf(pos -> {
BlockEntity blockEntity = this.world.getBlockEntity(pos);
if(!(blockEntity instanceof MobSpawnerBlockEntity))return true;
for(BlockPos blockPos: FLOOR_POSITION) {
BlockPos currentPos = pos.add(blockPos);
Block currentBlock = this.world.getBlockState(currentPos).getBlock();
if(currentBlock == Blocks.COBBLESTONE) {}
else if(currentBlock == Blocks.MOSSY_COBBLESTONE) {}
else return true;
}
return false;
});
result.forEach(pos -> this.renderers.add(new Cube(pos, new Vector4f(1.0f, 0.0f, 0.0f, 1.0f))));
return result;
}
}
@@ -0,0 +1,24 @@
package kaptainwutax.seedcracker.util;
import net.minecraft.util.math.BlockPos;
import java.util.HashSet;
import java.util.Set;
public class PosIterator {
public static Set<BlockPos> create(BlockPos start, BlockPos end) {
Set<BlockPos> result = new HashSet<>();
for(int x = start.getX(); x <= end.getX(); x++) {
for(int z = start.getZ(); z <= end.getZ(); z++) {
for(int y = start.getY(); y <= end.getY(); y++) {
result.add(new BlockPos(x, y, z));
}
}
}
return result;
}
}