Archived
0

Merge branch 'proto_1.12.2' into world-loader-anvil

This commit is contained in:
2018-12-25 18:23:33 +03:00
29 changed files with 944 additions and 293 deletions

View File

@@ -1,6 +1,7 @@
package com.flowpowered.nbt;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum TagType {
@@ -13,6 +14,7 @@ public enum TagType {
TAG_DOUBLE(DoubleTag.class, "TAG_Double", 6),
TAG_BYTE_ARRAY(ByteArrayTag.class, "TAG_Byte_Array", 7),
TAG_STRING(StringTag.class, "TAG_String", 8),
@SuppressWarnings("unchecked")
TAG_LIST((Class) ListTag.class, "TAG_List", 9),
// Java generics, y u so suck
TAG_COMPOUND(CompoundTag.class, "TAG_Compound", 10),

View File

@@ -24,20 +24,20 @@ public class AnvilBlock implements Block {
@Override
public void setLight(int light) {
// nope...
}
@Override
public BlockType getBlockType() {
public BlockType getType() {
final byte id = chunkSection.getBlocks().get((location.getY() << 8) + (location.getZ() << 4) + location.getX());
final int meta = chunkSection.getBlocksMeta().get(location);
BlockType type = BlockType.getByIdMeta(id & 0xFF, meta);
if (type.equals(BlockType.BEDROCK) && id != 7) {
log.warn("ChunkSection: {},{},{} | Block: {}",
chunkSection.getX(),
chunkSection.getY(),
chunkSection.getZ(),
location.toString());
chunkSection.getParent().getX(),
chunkSection.getY(),
chunkSection.getParent().getZ(),
location.toString());
}
return type;
}
@@ -45,17 +45,21 @@ public class AnvilBlock implements Block {
@Override
public BlockLocation getLocation() {
if (globalLocation == null) {
globalLocation = location.toGlobal(chunkSection);
globalLocation = new BlockLocation(
(chunkSection.getParent().getX() << 4) + location.getX(),
(chunkSection.getY() << 4) + location.getY(),
(chunkSection.getParent().getZ() << 4) + location.getZ()
);
}
return globalLocation;
}
@Override
public CompoundTag getNBTData() {
CompoundTag compoundTag = chunkSection.getParent().getNbtByGlobalXYZ(
(chunkSection.getX() << 4) + location.getX(),
CompoundTag compoundTag = ((AnvilChunk)chunkSection.getParent()).getNbtByGlobalXYZ(
(chunkSection.getParent().getX() << 4) + location.getX(),
(chunkSection.getY() << 4) + location.getY(),
(chunkSection.getZ() << 4) + location.getZ()
(chunkSection.getParent().getZ() << 4) + location.getZ()
);
compoundTag.getValue().remove("Items");
@@ -68,7 +72,7 @@ public class AnvilBlock implements Block {
public String toString() {
return "AnvilBlock{" +
"location=" + getLocation() +
", type=" + getBlockType() +
", type=" + getType() +
'}';
}
}

View File

@@ -1,12 +1,18 @@
package mc.world.anvil;
import com.flowpowered.nbt.*;
import com.flowpowered.nbt.ByteArrayTag;
import com.flowpowered.nbt.ByteTag;
import com.flowpowered.nbt.CompoundMap;
import com.flowpowered.nbt.CompoundTag;
import com.flowpowered.nbt.IntTag;
import com.flowpowered.nbt.ListTag;
import gnu.trove.list.TByteList;
import gnu.trove.list.array.TByteArrayList;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import mc.core.utils.NibbleArray;
import mc.core.world.Biome;
import mc.core.world.block.Block;
import mc.core.world.chunk.Chunk;
import mc.core.world.chunk.ChunkSection;
@@ -75,12 +81,57 @@ public class AnvilChunk implements Chunk {
}
@Override
public Biome getBiomeLocal(int x, int z) {
public Block getBlock(int x, int y, int z) {
final int height = y >> 4;
return sections.get(height).getBlock(
x - getX() << 4,
y - height << 4,
z - getZ() << 4
);
}
@Override
public void setBlock(Block block) {
// nope...
}
@Override
public int getSkyLight(int x, int y, int z) {
final int height = y >> 4;
return sections.get(height).getSkyLight(
x - getX() << 4,
y - height << 4,
z - getZ() << 4
);
}
@Override
public void setSkyLight(int x, int y, int z, int lightLevel) {
// nope...
}
@Override
public int getAddition(int x, int y, int z) {
final int height = y >> 4;
return sections.get(height).getAddition(
x - getX() << 4,
y - height << 4,
z - getZ() << 4
);
}
@Override
public void setAddition(int x, int y, int z, int value) {
// nope...
}
@Override
public Biome getBiome(int x, int z) {
return Biome.getById( biomes.get( z << 4 | x) & 255 );
}
@Override
public void setBiomeLocal(int x, int z, Biome biome) {
public void setBiome(int x, int z, Biome biome) {
// nope...
}
}

View File

@@ -6,12 +6,13 @@ import lombok.Getter;
import lombok.Setter;
import mc.core.utils.NibbleArray;
import mc.core.world.block.Block;
import mc.core.world.chunk.Chunk;
import mc.core.world.chunk.ChunkSection;
@Getter
public class AnvilChunkSection implements ChunkSection {
@Setter
private AnvilChunk parent;
private Chunk parent;
@Setter
private int y;
@@ -25,33 +26,23 @@ public class AnvilChunkSection implements ChunkSection {
private NibbleArray skyLight;
@Override
public int getX() {
return parent.getX();
}
@Override
public int getZ() {
return parent.getZ();
}
@Override
public Block getBlockLocal(int x, int y, int z) {
public Block getBlock(int x, int y, int z) {
return new AnvilBlock(this, x, y, z);
}
@Override
public void setBlock(Block block) {
// nope...
}
@Override
public int getSkyLightLocal(int x, int y, int z) {
public int getSkyLight(int x, int y, int z) {
return skyLight.get(x, y, z);
}
@Override
public void setSkyLightLocal(int x, int y, int z, int lightLevel) {
public void setSkyLight(int x, int y, int z, int lightLevel) {
// nope...
}
@Override
@@ -61,6 +52,6 @@ public class AnvilChunkSection implements ChunkSection {
@Override
public void setAddition(int x, int y, int z, int value) {
// nope...
}
}