May or may not work at any given time

This commit is contained in:
EOT3000 2019-11-27 14:38:05 -05:00
parent 4cba8b05a5
commit 564179c1c2
3 changed files with 25 additions and 11 deletions

View file

@ -89,6 +89,7 @@ public class BlockEntityUtils {
try {
return MAPPINGS.get(tag.get("id").getValue()).getExtraTags(tag);
} catch (Exception e) {
System.out.println(tag);
int x = ((Number) tag.getValue().get("x").getValue()).intValue();
int y = ((Number) tag.getValue().get("y").getValue()).intValue();
int z = ((Number) tag.getValue().get("z").getValue()).intValue();

View file

@ -52,6 +52,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
byteBuf.writeBytes(chunkData.biomes); // Biomes - 256 bytes
byteBuf.writeByte(0); // Border blocks - Edu edition only
VarInts.writeUnsignedInt(byteBuf, 0); // extra data length, 0 for now
byteBuf.writeBytes(chunkData.blockEntities);
byte[] payload = new byte[byteBuf.writerIndex()];
byteBuf.readBytes(payload);

View file

@ -20,6 +20,8 @@ import org.geysermc.connector.world.chunk.ChunkSection;
import java.io.ByteArrayOutputStream;
import java.util.*;
import static org.geysermc.connector.network.translators.BlockEntityUtils.MINECRAFT;
public class ChunkUtils {
public static ChunkData translateToBedrock(Column column) {
@ -47,17 +49,28 @@ public class ChunkUtils {
BlockState blockState = chunk.get(x, y, z);
BlockEntry block = TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);
if(!block.getJavaIdentifier().contains("sign")) {
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
block.getBedrockId() << 4 | block.getBedrockData());
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
block.getBedrockId() << 4 | block.getBedrockData());
if (block.getJavaIdentifier().contains("waterlogged=true")) {
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
9 << 4); // water id
}
} else {
if (block.getJavaIdentifier().contains("waterlogged=true")) {
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
0);
9 << 4); // water id
}
//Signs are special
if(block.getJavaIdentifier().contains("sign")) {
CompoundTag tag = new CompoundTag("");
tag.put(new com.github.steveice10.opennbt.tag.builtin.StringTag("id", MINECRAFT + "sign"));
tag.put(new com.github.steveice10.opennbt.tag.builtin.StringTag("Text1", "\"text\":\"\""));
tag.put(new com.github.steveice10.opennbt.tag.builtin.StringTag("Text2", "\"text\":\"\""));
tag.put(new com.github.steveice10.opennbt.tag.builtin.StringTag("Text3", "\"text\":\"\""));
tag.put(new com.github.steveice10.opennbt.tag.builtin.StringTag("Text4", "\"text\":\"\""));
tag.put(new com.github.steveice10.opennbt.tag.builtin.IntTag("x", x));
tag.put(new com.github.steveice10.opennbt.tag.builtin.IntTag("y", y));
tag.put(new com.github.steveice10.opennbt.tag.builtin.IntTag("z", z));
tiles.add(tag);
}
}
}
@ -70,11 +83,10 @@ public class ChunkUtils {
NBTOutputStream nbtStream = NbtUtils.createNetworkWriter(stream);
for (CompoundTag tag : tiles) {
if(tag.get("id").getValue().toString().contains("sign")) continue;
try {
nbtStream.write(BlockEntityUtils.getExtraTags(tag));
} catch (Exception e) {
//
//The close method of the streams doesn't do anything anyway
}
}