mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Fix the studio's 3D terrain: blank views, grey blocks, pale colours
The 3D views looked for tiles across the world's whole build height. In a pack with a tall sky most of a tile's box is air, so once the camera came close to the ground the planner drew sixteen far tiles and none under the camera. Tiles are now looked for between the lowest and highest ground drawn so far, and ranked by how far they lie from the ground in the middle of the view instead of by their centre point. Saved tiles named blocks without their properties, which matched no model variant, so grass and every plugin block drew as flat grey. Saved and generated tiles now carry the state players see, which for a plugin block is the vanilla state it borrows. Colours went through three.js colour management as if they were linear light and came out pale with flat shading. They are drawn as given now, as v3e does. Gaps in cut-out textures such as leaves take the texture's own colour instead of black. Also in the studio: - Right click or Ctrl+click on 3D terrain teleports there, as on the map. - The land, sea and cave biome layer views are gone. - New icons for the views and the map tools that shared one or said something else. - A saved world with nothing finished says so instead of reading forever.
This commit is contained in:
1 parent
6a86ad4b3f
commit
67063b02d7
72 files changed
+466
-275
No files matched your search
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.core.studio.bridge;
|
||||
|
||||
import art.arcane.iris.core.link.CustomBlockLook;
|
||||
import art.arcane.iris.core.studio.map.MapLabel;
|
||||
import art.arcane.iris.core.studio.map.MapTile;
|
||||
import com.google.gson.Gson;
|
||||
@@ -26,6 +27,8 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A {@link MapTile} as the studio reads it, little endian:
|
||||
@@ -36,7 +39,7 @@ import java.util.List;
|
||||
* i16 ground[grid²] | padding to 4 | i16 cover[grid²], when the header names blocks
|
||||
* </pre>
|
||||
* The header holds the size, the scale, the subject kind, the labels the grids index, and the blocks the ground and
|
||||
* cover grids index when the tile carries the tops of its columns. Every array starts on a
|
||||
* cover grids index when the tile carries the tops of its columns, each as the state players see. Every array starts on a
|
||||
* multiple of 4 bytes, so the studio views them in place.
|
||||
*/
|
||||
final class MapTileEncoding {
|
||||
@@ -45,12 +48,16 @@ final class MapTileEncoding {
|
||||
private MapTileEncoding() {
|
||||
}
|
||||
|
||||
static byte[] encode(MapTile tile, Gson gson) {
|
||||
/**
|
||||
* @param pluginLooks the plugin block a server state is with the vanilla state players see in its place; empty for
|
||||
* every state that is no plugin's block
|
||||
*/
|
||||
static byte[] encode(MapTile tile, Gson gson, Function<String, Optional<CustomBlockLook>> pluginLooks) {
|
||||
boolean hasHeights = tile.heights() != null;
|
||||
boolean hasPickNoise = tile.pickNoise() != null;
|
||||
MapTile.Blocks blocks = tile.blocks();
|
||||
byte[] header = gson.toJson(new Header(tile.size(), tile.blocksPerPixel(), tile.subjectKind(), tile.labels(),
|
||||
hasHeights, hasPickNoise, blocks == null ? null : blocks.names()))
|
||||
hasHeights, hasPickNoise, blocks == null ? null : statesPlayersSee(blocks.names(), pluginLooks)))
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
int cells = tile.gridSize() * tile.gridSize();
|
||||
int length = aligned(Integer.BYTES + header.length)
|
||||
@@ -91,6 +98,12 @@ final class MapTileEncoding {
|
||||
buffer.position(aligned(buffer.position()));
|
||||
}
|
||||
|
||||
private static List<String> statesPlayersSee(List<String> serverStates, Function<String, Optional<CustomBlockLook>> pluginLooks) {
|
||||
return serverStates.stream()
|
||||
.map(state -> pluginLooks.apply(state).map(CustomBlockLook::shownAs).orElse(state))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private record Header(int size, double blocksPerPixel, MapLabel.Kind subjectKind, List<MapLabel> labels,
|
||||
boolean heights, boolean pickNoise, List<String> blocks) {
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.core.studio.bridge;
|
||||
|
||||
import art.arcane.iris.core.studio.map.MapLabel;
|
||||
import art.arcane.iris.core.studio.saved.SavedBlock;
|
||||
import art.arcane.iris.core.studio.saved.SavedTile;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@@ -34,7 +35,7 @@ import java.util.List;
|
||||
* i16 groundY[size²] | padding to 4 | i16 waterSurfaceY[size²] | padding to 4
|
||||
* i16 blocks[size²] | padding to 4 | i16 biomes[size²]
|
||||
* </pre>
|
||||
* The header holds the size, the scale, the block names and the biome labels the grids index, and the values that mean
|
||||
* The header holds the size, the scale, the blocks and the biome labels the grids index, and the values that mean
|
||||
* no ground and no water.
|
||||
*/
|
||||
final class SavedTileEncoding {
|
||||
@@ -44,7 +45,7 @@ final class SavedTileEncoding {
|
||||
}
|
||||
|
||||
static byte[] encode(SavedTile tile, List<MapLabel> biomes, Gson gson) {
|
||||
byte[] header = gson.toJson(new Header(tile.size(), tile.blocksPerPixel(), tile.blockNames(), biomes,
|
||||
byte[] header = gson.toJson(new Header(tile.size(), tile.blocksPerPixel(), tile.savedBlocks(), biomes,
|
||||
SavedTile.NO_GROUND, SavedTile.NO_WATER)).getBytes(StandardCharsets.UTF_8);
|
||||
List<short[]> grids = List.of(tile.groundY(), tile.waterSurfaceY(), tile.blocks(), tile.biomes());
|
||||
int gridBytes = aligned(tile.size() * tile.size() * Short.BYTES);
|
||||
@@ -63,6 +64,6 @@ final class SavedTileEncoding {
|
||||
return (bytes + ALIGNMENT_BYTES - 1) / ALIGNMENT_BYTES * ALIGNMENT_BYTES;
|
||||
}
|
||||
|
||||
private record Header(int size, int blocksPerPixel, List<String> blocks, List<MapLabel> biomes, int noGround, int noWater) {
|
||||
private record Header(int size, int blocksPerPixel, List<SavedBlock> blocks, List<MapLabel> biomes, int noGround, int noWater) {
|
||||
}
|
||||
}
|
||||
@@ -335,9 +335,6 @@ public final class StudioBridge implements AutoCloseable {
|
||||
|
||||
private static MapPickInspection.Inspection picks(Engine engine, Query query) {
|
||||
MapLayer layer = layer(engine, query);
|
||||
if (!layer.hasPickNoise()) {
|
||||
throw new RequestError(STATUS_BAD_REQUEST, "The " + layer.view().label() + " view has no picks to inspect");
|
||||
}
|
||||
try {
|
||||
MapPickInspection.Area area = new MapPickInspection.Area(
|
||||
query.number("minX"), query.number("minZ"), query.number("maxX"), query.number("maxZ"));
|
||||
@@ -609,7 +606,7 @@ public final class StudioBridge implements AutoCloseable {
|
||||
if (query.has("blocks")) {
|
||||
tile = withBlocks(session, tile, startX, startZ, blockSource(query), cancelled);
|
||||
}
|
||||
return MapTileEncoding.encode(tile, gson);
|
||||
return MapTileEncoding.encode(tile, gson, StudioBridge::pluginLookOf);
|
||||
}
|
||||
|
||||
private static MapTile withBlocks(StudioWorld.Session session, MapTile tile, double startX, double startZ, BlockSource source,
|
||||
|
||||
@@ -49,11 +49,6 @@ public record MapLayer(MapView view, IrisRegion previewRegion) {
|
||||
return previewRegion != null;
|
||||
}
|
||||
|
||||
/** Whether the layer can show the noise that picked each spot: the region view, its previews and the biome view. */
|
||||
public boolean hasPickNoise() {
|
||||
return view == MapView.BIOMES || view == MapView.REGIONS;
|
||||
}
|
||||
|
||||
/** Whether each spot is labelled with its region rather than a biome; a preview labels the biomes. */
|
||||
boolean labelsRegions() {
|
||||
return view.labelsRegions() && !previews();
|
||||
|
||||
@@ -46,7 +46,6 @@ public final class MapPickInspection {
|
||||
private MapPickInspection() {
|
||||
}
|
||||
|
||||
/** @throws IllegalArgumentException for a view whose spots no noise picks, such as a biome layer's */
|
||||
public static Inspection measure(Engine engine, MapLayer layer, Area area) {
|
||||
if (layer.previews()) {
|
||||
return measurePreview(engine, layer.previewRegion(), area);
|
||||
@@ -54,7 +53,6 @@ public final class MapPickInspection {
|
||||
return switch (layer.view()) {
|
||||
case REGIONS -> measureRegions(engine, area);
|
||||
case BIOMES -> measureBiomes(engine, area);
|
||||
default -> throw new IllegalArgumentException("The " + layer.view().label() + " view has no picks to inspect");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -51,13 +51,7 @@ public final class MapPickPath {
|
||||
return path;
|
||||
}
|
||||
path.add(regionStep(engine, region, x, z));
|
||||
MapView view = layer.view();
|
||||
switch (view) {
|
||||
case LAND_BIOMES -> addListStep(path, engine, view, region, InferredType.LAND, x, z);
|
||||
case SEA_BIOMES -> addListStep(path, engine, view, region, InferredType.SEA, x, z);
|
||||
case CAVE_BIOMES -> addListStep(path, engine, view, region, InferredType.CAVE, x, z);
|
||||
case BIOMES, REGIONS -> addBaseBiomeSteps(path, engine, view, region, x, z);
|
||||
}
|
||||
addBaseBiomeSteps(path, engine, layer.view(), region, x, z);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ public final class MapTileRenderer {
|
||||
/**
|
||||
* The square of {@code size} pixels whose top left pixel samples ({@code startX}, {@code startZ}).
|
||||
*
|
||||
* @param extras what to sample besides the labels; the height view always has heights, and only a layer that
|
||||
* {@linkplain MapLayer#hasPickNoise() has pick noise} gets it
|
||||
* @param extras what to sample besides the labels; the height view always has heights
|
||||
* @throws CancellationException as soon as {@code cancelled} answers true
|
||||
*/
|
||||
public MapTile render(MapLayer layer, double startX, double startZ, double blocksPerPixel, int size,
|
||||
@@ -120,12 +119,10 @@ public final class MapTileRenderer {
|
||||
IrisComplex complex = engine.getComplex();
|
||||
ProceduralStream<IrisRegion> regionStream = complex.getRegionStream();
|
||||
short[] regions = everyCell(grid, (x, z) -> labels.indexOf(regionStream.get(x, z)));
|
||||
ProceduralStream<IrisBiome> biomeStream = layer.view().biomeStream(complex);
|
||||
short[] subjects = layer.labelsRegions() ? regions : everyCell(grid, (x, z) -> labels.indexOf(biomeStream.get(x, z)));
|
||||
ProceduralStream<IrisBiome> baseBiomes = complex.getBaseBiomeStream();
|
||||
short[] subjects = layer.labelsRegions() ? regions : everyCell(grid, (x, z) -> labels.indexOf(baseBiomes.get(x, z)));
|
||||
float[] heights = extras.contains(MapTile.Extra.HEIGHTS) ? latticeHeights(grid) : null;
|
||||
float[] pickNoise = extras.contains(MapTile.Extra.PICK_NOISE) && layer.hasPickNoise()
|
||||
? MapPickNoise.sample(engine, layer, grid)
|
||||
: null;
|
||||
float[] pickNoise = extras.contains(MapTile.Extra.PICK_NOISE) ? MapPickNoise.sample(engine, layer, grid) : null;
|
||||
MapLabel.Kind subjectKind = layer.labelsRegions() ? MapLabel.Kind.REGION : MapLabel.Kind.BIOME;
|
||||
return new MapTile(grid.size() - 2, blocksPerPixel, subjectKind, labels.labels(), subjects, regions, heights, pickNoise, null);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@
|
||||
|
||||
package art.arcane.iris.core.studio.map;
|
||||
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.framework.render.RenderType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.util.project.stream.ProceduralStream;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
@@ -29,12 +26,7 @@ import java.util.Optional;
|
||||
/** The studio map's views of a world drawn from its engine streams, one tile at a time. */
|
||||
public enum MapView {
|
||||
BIOMES("biomes", "Biomes", "The biome at each spot, in the biome's colour", Group.WORLD, RenderType.BIOME),
|
||||
REGIONS("regions", "Regions", "The region each spot belongs to", Group.WORLD, RenderType.REGION),
|
||||
LAND_BIOMES("landBiomes", "Land biomes", "The land biome each spot would get, also where the sea is",
|
||||
Group.BIOME_LAYERS, RenderType.BIOME_LAND),
|
||||
SEA_BIOMES("seaBiomes", "Sea biomes", "The sea biome each spot would get, also where the land is",
|
||||
Group.BIOME_LAYERS, RenderType.BIOME_SEA),
|
||||
CAVE_BIOMES("caveBiomes", "Cave biomes", "The cave biome under each spot", Group.BIOME_LAYERS, RenderType.CAVE_LAND);
|
||||
REGIONS("regions", "Regions", "The region each spot belongs to", Group.WORLD, RenderType.REGION);
|
||||
|
||||
private final String id;
|
||||
private final String label;
|
||||
@@ -80,19 +72,8 @@ public enum MapView {
|
||||
return colorType;
|
||||
}
|
||||
|
||||
/** The biome each spot is labelled with: the base biome, before the height corrects it near coasts. */
|
||||
ProceduralStream<IrisBiome> biomeStream(IrisComplex complex) {
|
||||
return switch (this) {
|
||||
case LAND_BIOMES -> complex.getLandBiomeStream();
|
||||
case SEA_BIOMES -> complex.getSeaBiomeStream();
|
||||
case CAVE_BIOMES -> complex.getCaveBiomeStream();
|
||||
case BIOMES, REGIONS -> complex.getBaseBiomeStream();
|
||||
};
|
||||
}
|
||||
|
||||
public enum Group {
|
||||
WORLD("World"),
|
||||
BIOME_LAYERS("Biome layers");
|
||||
WORLD("World");
|
||||
|
||||
private final String label;
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.studio.saved;
|
||||
|
||||
/**
|
||||
* A block as a region file holds it.
|
||||
*
|
||||
* @param name such as {@code minecraft:stone}, without its properties; a plugin's block is named as its plugin does
|
||||
* @param drawnAs the state it was saved as, such as {@code minecraft:grass_block[snowy=false]}, which is what players see
|
||||
*/
|
||||
public record SavedBlock(String name, String drawnAs) {
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -91,14 +92,24 @@ final class SavedChunk {
|
||||
|
||||
/** The block's name, such as {@code minecraft:stone}, without its properties; a plugin's block is named as its plugin does. */
|
||||
String blockAt(int x, int y, int z) {
|
||||
return nameOf(paletteBlockAt(x, y, z));
|
||||
}
|
||||
|
||||
/** The block with the state it was saved as, which is what players see of it. */
|
||||
SavedBlock savedBlockAt(int x, int y, int z) {
|
||||
Tag<?> block = paletteBlockAt(x, y, z);
|
||||
return new SavedBlock(nameOf(block), savedStateOf(block));
|
||||
}
|
||||
|
||||
private Tag<?> paletteBlockAt(int x, int y, int z) {
|
||||
CompoundTag section = sectionsByY.get(Math.floorDiv(y, BLOCKS_ACROSS));
|
||||
if (section == null || !section.containsKey("block_states")) {
|
||||
return AIR;
|
||||
return new StringTag(AIR);
|
||||
}
|
||||
CompoundTag states = section.getCompoundTag("block_states");
|
||||
ListTag<?> palette = states.getListTag("palette");
|
||||
int index = (Math.floorMod(y, BLOCKS_ACROSS) * BLOCKS_ACROSS + z) * BLOCKS_ACROSS + x;
|
||||
return nameOf(paletteEntry(palette, states.getLongArray("data"), Math.max(SMALLEST_BLOCK_INDEX_BITS, bitsFor(palette.size())), index));
|
||||
return paletteEntry(palette, states.getLongArray("data"), Math.max(SMALLEST_BLOCK_INDEX_BITS, bitsFor(palette.size())), index);
|
||||
}
|
||||
|
||||
/** The biome's key, such as {@code minecraft:plains}; biomes are stored once per 4 blocks across. */
|
||||
@@ -126,15 +137,28 @@ final class SavedChunk {
|
||||
return entry < palette.size() ? palette.get(entry) : null;
|
||||
}
|
||||
|
||||
// A block with properties is a compound naming it under Name; since 26.1 a block without them may be its bare name.
|
||||
private String nameOf(Tag<?> block) {
|
||||
String name = switch (block) {
|
||||
return customBlocks.nameSavedAs(vanillaNameOf(block), () -> propertiesOf(block));
|
||||
}
|
||||
|
||||
private static String savedStateOf(Tag<?> block) {
|
||||
Map<String, String> properties = new TreeMap<>(propertiesOf(block));
|
||||
if (properties.isEmpty()) {
|
||||
return vanillaNameOf(block);
|
||||
}
|
||||
return vanillaNameOf(block) + properties.entrySet().stream()
|
||||
.map(property -> property.getKey() + "=" + property.getValue())
|
||||
.collect(Collectors.joining(",", "[", "]"));
|
||||
}
|
||||
|
||||
// A block with properties is a compound naming it under Name; since 26.1 a block without them may be its bare name.
|
||||
private static String vanillaNameOf(Tag<?> block) {
|
||||
return switch (block) {
|
||||
case StringTag text -> text.getValue();
|
||||
case CompoundTag compound when !compound.getString("Name").isEmpty() -> compound.getString("Name");
|
||||
case CompoundTag compound when !compound.getString("").isEmpty() -> compound.getString("");
|
||||
case null, default -> UNKNOWN;
|
||||
};
|
||||
return customBlocks.nameSavedAs(name, () -> propertiesOf(block));
|
||||
}
|
||||
|
||||
private static Map<String, String> propertiesOf(Tag<?> block) {
|
||||
|
||||
@@ -54,9 +54,9 @@ final class SavedRegion {
|
||||
private final short[] waterSurfaceY = new short[BLOCKS_ACROSS * BLOCKS_ACROSS];
|
||||
private final short[] blockIds = new short[BLOCKS_ACROSS * BLOCKS_ACROSS];
|
||||
private final short[] biomeIds = new short[BLOCKS_ACROSS * BLOCKS_ACROSS];
|
||||
private final List<String> blocks = new CopyOnWriteArrayList<>();
|
||||
private final List<SavedBlock> blocks = new CopyOnWriteArrayList<>();
|
||||
private final List<String> biomes = new CopyOnWriteArrayList<>();
|
||||
private final Map<String, Short> blockIndex = new HashMap<>();
|
||||
private final Map<SavedBlock, Short> blockIndex = new HashMap<>();
|
||||
private final Map<String, Short> biomeIndex = new HashMap<>();
|
||||
private final Map<Integer, Integer> waterColumnsBySurface = new HashMap<>();
|
||||
private int minY = Integer.MAX_VALUE;
|
||||
@@ -135,7 +135,7 @@ final class SavedRegion {
|
||||
}
|
||||
}
|
||||
|
||||
private static short idOf(String name, Map<String, Short> index, List<String> names) {
|
||||
private static <Named> short idOf(Named name, Map<Named, Short> index, List<Named> names) {
|
||||
return index.computeIfAbsent(name, added -> {
|
||||
names.add(added);
|
||||
return (short) (names.size() - 1);
|
||||
@@ -173,14 +173,14 @@ final class SavedRegion {
|
||||
* @param groundY the top block of the ground, under any water
|
||||
* @param waterSurfaceY the top water block over it, or {@link #NO_WATER}
|
||||
*/
|
||||
record SavedColumn(int groundY, int waterSurfaceY, String block, String biome) {
|
||||
record SavedColumn(int groundY, int waterSurfaceY, SavedBlock block, String biome) {
|
||||
}
|
||||
|
||||
/** One chunk's columns, read without holding the region so other chunks can be read meanwhile. */
|
||||
private record ChunkColumns(int minY, short[] groundY, short[] waterSurfaceY, String[] blocks, String[] biomes) {
|
||||
private record ChunkColumns(int minY, short[] groundY, short[] waterSurfaceY, SavedBlock[] blocks, String[] biomes) {
|
||||
static ChunkColumns of(SavedChunk chunk, SavedGround ground) {
|
||||
ChunkColumns columns = new ChunkColumns(chunk.minY(), new short[CHUNK_COLUMNS], new short[CHUNK_COLUMNS],
|
||||
new String[CHUNK_COLUMNS], new String[CHUNK_COLUMNS]);
|
||||
new SavedBlock[CHUNK_COLUMNS], new String[CHUNK_COLUMNS]);
|
||||
for (int z = 0; z < SavedChunk.BLOCKS_ACROSS; z++) {
|
||||
for (int x = 0; x < SavedChunk.BLOCKS_ACROSS; x++) {
|
||||
columns.read(chunk, ground, x, z);
|
||||
@@ -204,7 +204,7 @@ final class SavedRegion {
|
||||
}
|
||||
groundY[column] = (short) y;
|
||||
waterSurfaceY[column] = (short) waterTop;
|
||||
blocks[column] = block;
|
||||
blocks[column] = chunk.savedBlockAt(x, y, z);
|
||||
biomes[column] = chunk.biomeAt(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Map;
|
||||
* @param waterSurfaceY per pixel, the top water block over the ground, or {@link #NO_WATER}
|
||||
*/
|
||||
public record SavedTile(int size, int blocksPerPixel, short[] groundY, short[] waterSurfaceY, short[] blocks, short[] biomes,
|
||||
List<String> blockNames, List<String> biomeNames) {
|
||||
List<SavedBlock> savedBlocks, List<String> biomeNames) {
|
||||
public static final short NO_GROUND = Short.MIN_VALUE;
|
||||
public static final short NO_WATER = (short) SavedRegion.NO_WATER;
|
||||
|
||||
@@ -43,7 +43,7 @@ public record SavedTile(int size, int blocksPerPixel, short[] groundY, short[] w
|
||||
int pixels = size * size;
|
||||
SavedTile tile = new SavedTile(size, blocksPerPixel, new short[pixels], new short[pixels], new short[pixels], new short[pixels],
|
||||
new ArrayList<>(), new ArrayList<>());
|
||||
Map<String, Short> blockIds = new HashMap<>();
|
||||
Map<SavedBlock, Short> blockIds = new HashMap<>();
|
||||
Map<String, Short> biomeIds = new HashMap<>();
|
||||
long originX = (long) tileX * size * blocksPerPixel;
|
||||
long originZ = (long) tileZ * size * blocksPerPixel;
|
||||
@@ -59,14 +59,14 @@ public record SavedTile(int size, int blocksPerPixel, short[] groundY, short[] w
|
||||
}
|
||||
tile.groundY[pixel] = (short) saved.groundY();
|
||||
tile.waterSurfaceY[pixel] = (short) saved.waterSurfaceY();
|
||||
tile.blocks[pixel] = idOf(saved.block(), blockIds, tile.blockNames);
|
||||
tile.blocks[pixel] = idOf(saved.block(), blockIds, tile.savedBlocks);
|
||||
tile.biomes[pixel] = idOf(saved.biome(), biomeIds, tile.biomeNames);
|
||||
}
|
||||
}
|
||||
return tile;
|
||||
}
|
||||
|
||||
private static short idOf(String name, Map<String, Short> ids, List<String> names) {
|
||||
private static <Named> short idOf(Named name, Map<Named, Short> ids, List<Named> names) {
|
||||
return ids.computeIfAbsent(name, added -> {
|
||||
names.add(added);
|
||||
return (short) (names.size() - 1);
|
||||
|
||||
@@ -183,11 +183,6 @@ public class StudioBridgeTest {
|
||||
assertEquals(400, get("hover?view=regions&preview=nowhere&x=0&z=0").statusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aBiomeLayerViewHasNoPicksToInspect() throws Exception {
|
||||
assertEquals(400, get("picks?view=landBiomes&minX=0&minZ=0&maxX=10&maxZ=10").statusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aWorldWithoutAnEngineIsUnavailableUntilItHasOneAgain() throws Exception {
|
||||
Engine engine = running.getAndSet(null);
|
||||
|
||||
@@ -67,11 +67,6 @@ public class MapPickInspectionTest {
|
||||
assertEquals(SPOTS, section.spreads().getFirst().samples());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aBiomeLayerViewHasNoPicks() {
|
||||
assertThrows(IllegalArgumentException.class, () -> measure(MapLayer.of(MapView.LAND_BIOMES)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anAreaNeedsItsSecondCornerBeyondItsFirst() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new MapPickInspection.Area(0D, 0D, 0D, 10D));
|
||||
|
||||
@@ -45,11 +45,6 @@ public class MapPickPathTest {
|
||||
assertBand(bands.get(1), "plains", 0.25D, 1D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theLandViewStopsAtTheListPickBecauseItsStreamHasNoChildren() {
|
||||
assertEquals(List.of(MapPickPath.Kind.REGION, MapPickPath.Kind.BIOME), kinds(explain(MapLayer.of(MapView.LAND_BIOMES))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anImageMappedRegionWasChosenNotPicked() {
|
||||
when(world.imageMap.sampleRegion(X, Z)).thenReturn(world.dry);
|
||||
|
||||
@@ -87,14 +87,6 @@ public class MapTileRendererTest {
|
||||
assertEquals(Color.RED.getRGB() & 0xFFFFFF, tile.subjectAt(0, 0).color());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void biomeLayersLabelWithTheirOwnStreamAndColouring() {
|
||||
MapTile tile = render(MapView.CAVE_BIOMES, -4D, 0D, 1D, false);
|
||||
|
||||
assertEquals("cavern", tile.subjectAt(0, 0).key());
|
||||
assertEquals("warm", tile.regionAt(0, 0).key());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aFlatWorldStaysFlat() {
|
||||
heights((x, z) -> 70D);
|
||||
@@ -199,12 +191,9 @@ public class MapTileRendererTest {
|
||||
MapTile plain = render(MapView.REGIONS, 0D, 0D, 1D, false);
|
||||
MapTile withNoise = new MapTileRenderer(engine).render(MapLayer.of(MapView.REGIONS), 0D, 0D, 1D, SIZE,
|
||||
Set.of(MapTile.Extra.PICK_NOISE), () -> false);
|
||||
MapTile caves = new MapTileRenderer(engine).render(MapLayer.of(MapView.CAVE_BIOMES), 0D, 0D, 1D, SIZE,
|
||||
Set.of(MapTile.Extra.PICK_NOISE), () -> false);
|
||||
|
||||
assertNull(plain.pickNoise());
|
||||
assertEquals(0.13F, withNoise.pickNoise()[withNoise.gridIndex(3, 5)], 1e-6F);
|
||||
assertNull("no noise picks the cave biome layer here", caves.pickNoise());
|
||||
}
|
||||
|
||||
private MapTile render(MapView view, double startX, double startZ, double blocksPerPixel, boolean withHeights) {
|
||||
|
||||
@@ -79,7 +79,7 @@ public class SavedWorldTest {
|
||||
SavedRegion.SavedColumn underTree = world.columnAt(0, 0);
|
||||
assertEquals(TREE_GROUND_TOP, underTree.groundY());
|
||||
assertEquals(SavedRegion.NO_WATER, underTree.waterSurfaceY());
|
||||
assertEquals("minecraft:stone", underTree.block());
|
||||
assertEquals(new SavedBlock("minecraft:stone", "minecraft:stone"), underTree.block());
|
||||
assertEquals("test:meadow", underTree.biome());
|
||||
|
||||
SavedRegion.SavedColumn pond = world.columnAt(1, 0);
|
||||
@@ -96,7 +96,7 @@ public class SavedWorldTest {
|
||||
assertEquals(TREE_GROUND_TOP, world.columnAt(0, 0).groundY());
|
||||
SavedRegion.SavedColumn snowyGround = world.columnAt(2, 0);
|
||||
assertEquals(PLAIN_GROUND_TOP + 1, snowyGround.groundY());
|
||||
assertEquals("minecraft:snow", snowyGround.block());
|
||||
assertEquals("minecraft:snow", snowyGround.block().name());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,11 +105,11 @@ public class SavedWorldTest {
|
||||
|
||||
SavedRegion.SavedColumn plugin = world.columnAt(3, 0);
|
||||
assertEquals(PLAIN_GROUND_TOP + 1, plugin.groundY());
|
||||
assertEquals("etopia:grass_block", plugin.block());
|
||||
assertEquals(new SavedBlock("etopia:grass_block", "minecraft:tripwire[attached=true]"), plugin.block());
|
||||
|
||||
SavedRegion.SavedColumn otherState = world.columnAt(5, 0);
|
||||
assertEquals(PLAIN_GROUND_TOP, otherState.groundY());
|
||||
assertEquals("minecraft:stone", otherState.block());
|
||||
assertEquals("minecraft:stone", otherState.block().name());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,7 +118,7 @@ public class SavedWorldTest {
|
||||
|
||||
SavedRegion.SavedColumn borrowed = world.columnAt(3, 0);
|
||||
assertEquals(PLAIN_GROUND_TOP, borrowed.groundY());
|
||||
assertEquals("minecraft:stone", borrowed.block());
|
||||
assertEquals("minecraft:stone", borrowed.block().name());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,7 +151,7 @@ public class SavedWorldTest {
|
||||
assertEquals(PLAIN_GROUND_TOP + 1, tile.groundY()[1]);
|
||||
assertEquals(PLAIN_GROUND_TOP, tile.groundY()[2]);
|
||||
assertEquals(SavedTile.NO_GROUND, tile.groundY()[8]);
|
||||
assertEquals(List.of("minecraft:stone", "minecraft:snow"), tile.blockNames());
|
||||
assertEquals(List.of("minecraft:stone", "minecraft:snow"), tile.savedBlocks().stream().map(SavedBlock::name).toList());
|
||||
assertEquals(List.of("test:meadow"), tile.biomeNames());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user