- add comments to Region
- lookup surface y for searches
This commit is contained in:
parent
9c3a05c8d7
commit
0140a8bcd8
@ -194,7 +194,8 @@ public class TerraCommand {
|
|||||||
UUID playerID = context.getSource().asPlayer().getUniqueID();
|
UUID playerID = context.getSource().asPlayer().getUniqueID();
|
||||||
MinecraftServer server = context.getSource().getServer();
|
MinecraftServer server = context.getSource().getServer();
|
||||||
WorldGenerator worldGenerator = terraContext.factory.get();
|
WorldGenerator worldGenerator = terraContext.factory.get();
|
||||||
Search search = new TerrainSearchTask(pos, worldGenerator, target);
|
IWorldReader reader = context.getSource().asPlayer().getServerWorld();
|
||||||
|
Search search = new TerrainSearchTask(pos, reader, worldGenerator, target);
|
||||||
doSearch(server, playerID, search);
|
doSearch(server, playerID, search);
|
||||||
context.getSource().sendFeedback(new StringTextComponent("Searching..."), false);
|
context.getSource().sendFeedback(new StringTextComponent("Searching..."), false);
|
||||||
|
|
||||||
@ -235,8 +236,9 @@ public class TerraCommand {
|
|||||||
UUID playerID = context.getSource().asPlayer().getUniqueID();
|
UUID playerID = context.getSource().asPlayer().getUniqueID();
|
||||||
MinecraftServer server = context.getSource().getServer();
|
MinecraftServer server = context.getSource().getServer();
|
||||||
WorldGenerator worldGenerator = terraContext.factory.get();
|
WorldGenerator worldGenerator = terraContext.factory.get();
|
||||||
|
IWorldReader reader = context.getSource().asPlayer().getServerWorld();
|
||||||
Search biomeSearch = new BiomeSearchTask(pos, world, biome);
|
Search biomeSearch = new BiomeSearchTask(pos, world, biome);
|
||||||
Search terrainSearch = new TerrainSearchTask(pos, worldGenerator, target);
|
Search terrainSearch = new TerrainSearchTask(pos, reader, worldGenerator, target);
|
||||||
Search search = new BothSearchTask(pos, biomeSearch, terrainSearch);
|
Search search = new BothSearchTask(pos, biomeSearch, terrainSearch);
|
||||||
doSearch(server, playerID, search);
|
doSearch(server, playerID, search);
|
||||||
context.getSource().sendFeedback(new StringTextComponent("Searching..."), false);
|
context.getSource().sendFeedback(new StringTextComponent("Searching..."), false);
|
||||||
|
@ -3,6 +3,7 @@ package com.terraforged.command.search;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IWorldReader;
|
import net.minecraft.world.IWorldReader;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.gen.Heightmap;
|
||||||
|
|
||||||
public class BiomeSearchTask extends Search {
|
public class BiomeSearchTask extends Search {
|
||||||
|
|
||||||
@ -24,4 +25,10 @@ public class BiomeSearchTask extends Search {
|
|||||||
public boolean test(BlockPos pos) {
|
public boolean test(BlockPos pos) {
|
||||||
return reader.getNoiseBiomeRaw(pos.getX() >> 2, pos.getY(), pos.getZ() >> 2) == biome;
|
return reader.getNoiseBiomeRaw(pos.getX() >> 2, pos.getY(), pos.getZ() >> 2) == biome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos success(BlockPos.Mutable pos) {
|
||||||
|
pos.setY(reader.getHeight(Heightmap.Type.MOTION_BLOCKING, pos.getX(), pos.getZ()));
|
||||||
|
return super.success(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,9 @@ public class BothSearchTask extends Search {
|
|||||||
public boolean test(BlockPos pos) {
|
public boolean test(BlockPos pos) {
|
||||||
return a.test(pos) && b.test(pos);
|
return a.test(pos) && b.test(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos success(BlockPos.Mutable pos) {
|
||||||
|
return a.success(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,21 @@ import com.terraforged.core.cell.Cell;
|
|||||||
import com.terraforged.world.WorldGenerator;
|
import com.terraforged.world.WorldGenerator;
|
||||||
import com.terraforged.world.terrain.Terrain;
|
import com.terraforged.world.terrain.Terrain;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IWorldReader;
|
||||||
|
import net.minecraft.world.gen.Heightmap;
|
||||||
|
|
||||||
public class TerrainSearchTask extends Search {
|
public class TerrainSearchTask extends Search {
|
||||||
|
|
||||||
private final Terrain type;
|
private final Terrain type;
|
||||||
|
private final IWorldReader reader;
|
||||||
private final WorldGenerator generator;
|
private final WorldGenerator generator;
|
||||||
private final Cell cell = new Cell();
|
private final Cell cell = new Cell();
|
||||||
|
|
||||||
public TerrainSearchTask(BlockPos center, WorldGenerator generator, Terrain type) {
|
public TerrainSearchTask(BlockPos center, IWorldReader reader, WorldGenerator generator, Terrain type) {
|
||||||
super(center, 256);
|
super(center, 256);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
|
this.reader = reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,4 +31,10 @@ public class TerrainSearchTask extends Search {
|
|||||||
generator.getHeightmap().apply(cell, pos.getX(), pos.getZ());
|
generator.getHeightmap().apply(cell, pos.getX(), pos.getZ());
|
||||||
return cell.terrain == type;
|
return cell.terrain == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos success(BlockPos.Mutable pos) {
|
||||||
|
pos.setY(reader.getHeight(Heightmap.Type.MOTION_BLOCKING, pos.getX(), pos.getZ()));
|
||||||
|
return super.success(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user