mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-12-04 08:23:37 +01:00
First mock of an improved nether-render mode
This commit is contained in:
parent
969f7a78f3
commit
7c1d7a9cc2
@ -30,25 +30,33 @@
|
||||
import net.querz.nbt.CompoundTag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public abstract class MCAChunk implements Chunk {
|
||||
|
||||
private final MCAWorld world;
|
||||
private final int dataVersion;
|
||||
|
||||
private int[] netherCeilingHeights;
|
||||
|
||||
protected MCAChunk() {
|
||||
this.world = null;
|
||||
this.dataVersion = -1;
|
||||
this(null, -1);
|
||||
}
|
||||
|
||||
protected MCAChunk(MCAWorld world) {
|
||||
this.world = world;
|
||||
this.dataVersion = -1;
|
||||
this(world, -1);
|
||||
}
|
||||
|
||||
protected MCAChunk(MCAWorld world, CompoundTag chunkTag) {
|
||||
this(world, chunkTag.getInt("DataVersion"));
|
||||
}
|
||||
|
||||
private MCAChunk(MCAWorld world, int dataVersion) {
|
||||
this.world = world;
|
||||
dataVersion = chunkTag.getInt("DataVersion");
|
||||
this.dataVersion = dataVersion;
|
||||
|
||||
this.netherCeilingHeights = new int[16 * 16];
|
||||
Arrays.fill(this.netherCeilingHeights, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,6 +94,26 @@ public int getMinY(int x, int z) {
|
||||
@Override
|
||||
public int getOceanFloorY(int x, int z) { return 0; }
|
||||
|
||||
@Override
|
||||
public int getNetherCeilingY(int x, int z) {
|
||||
int lx = x & 0xF, lz = z & 0xF;
|
||||
int i = lz * 16 + lx;
|
||||
int y = netherCeilingHeights[i];
|
||||
|
||||
if (y == Integer.MIN_VALUE) {
|
||||
int maxY = getMaxY(x, z);
|
||||
int minY = getMinY(x, z);
|
||||
|
||||
for (y = Math.min(maxY, 120); y >= minY; y--){
|
||||
if (!getBlockState(x, y, z).isNetherCeiling()) break;
|
||||
}
|
||||
|
||||
netherCeilingHeights[i] = y;
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
protected MCAWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
@ -136,7 +136,10 @@ public Chunk getChunk() {
|
||||
}
|
||||
|
||||
public BlockState getBlockState() {
|
||||
if (blockState == null) blockState = getChunk().getBlockState(x, y, z);
|
||||
if (blockState == null){
|
||||
if (y > getChunk().getNetherCeilingY(x, z)) blockState = BlockState.AIR;
|
||||
else blockState = getChunk().getBlockState(x, y, z);
|
||||
}
|
||||
return blockState;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class BlockState extends Key {
|
||||
private final Map<String, String> properties;
|
||||
private final Property[] propertiesArray;
|
||||
|
||||
private final boolean isAir, isWater, isWaterlogged;
|
||||
private final boolean isAir, isWater, isWaterlogged, isNetherCeiling;
|
||||
private int liquidLevel = -1, redstonePower = -1;
|
||||
|
||||
public BlockState(String value) {
|
||||
@ -82,6 +82,17 @@ public BlockState(String value, Map<String, String> properties) {
|
||||
this.isWater = "minecraft:water".equals(this.getFormatted());
|
||||
this.isWaterlogged = "true".equals(properties.get("waterlogged"));
|
||||
|
||||
this.isNetherCeiling =
|
||||
"minecraft:bedrock".equals(this.getFormatted()) ||
|
||||
"minecraft:netherrack".equals(this.getFormatted()) ||
|
||||
"minecraft:nether_quartz_ore".equals(this.getFormatted()) ||
|
||||
"minecraft:lava".equals(this.getFormatted()) ||
|
||||
"minecraft:soul_sand".equals(this.getFormatted()) ||
|
||||
"minecraft:basalt".equals(this.getFormatted()) ||
|
||||
"minecraft:blackstone".equals(this.getFormatted()) ||
|
||||
"minecraft:soul_soil".equals(this.getFormatted()) ||
|
||||
"minecraft:nether_gold_ore".equals(this.getFormatted()) ||
|
||||
"minecraft:ancient_debris".equals(this.getFormatted());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,6 +120,10 @@ public boolean isWaterlogged() {
|
||||
return isWaterlogged;
|
||||
}
|
||||
|
||||
public boolean isNetherCeiling() {
|
||||
return isNetherCeiling;
|
||||
}
|
||||
|
||||
public int getLiquidLevel() {
|
||||
if (liquidLevel == -1) {
|
||||
try {
|
||||
|
@ -44,4 +44,6 @@ public interface Chunk {
|
||||
|
||||
int getOceanFloorY(int x, int z);
|
||||
|
||||
int getNetherCeilingY(int x, int z);
|
||||
|
||||
}
|
||||
|
@ -69,4 +69,9 @@ public int getMinY(int x, int z) {
|
||||
@Override
|
||||
public int getOceanFloorY(int x, int z) { return 0; }
|
||||
|
||||
@Override
|
||||
public int getNetherCeilingY(int x, int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user