forked from GeyserMC/Geyser
Start on 1.13 changes (not functional yet)
Cached palette still needs fixing, therefore this build actually does nothing yet.
This commit is contained in:
parent
7ce4b22693
commit
0e2f64b95a
8 changed files with 45 additions and 16592 deletions
|
@ -74,8 +74,8 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.nukkitx.protocol</groupId>
|
<groupId>com.nukkitx.protocol</groupId>
|
||||||
<artifactId>bedrock-v361</artifactId>
|
<artifactId>bedrock-v388</artifactId>
|
||||||
<version>2.3.0</version>
|
<version>2.4.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -27,7 +27,8 @@ package org.geysermc.connector;
|
||||||
|
|
||||||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServer;
|
import com.nukkitx.protocol.bedrock.BedrockServer;
|
||||||
import com.nukkitx.protocol.bedrock.v361.Bedrock_v361;
|
import com.nukkitx.protocol.bedrock.v388.Bedrock_v388;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.fusesource.jansi.AnsiConsole;
|
import org.fusesource.jansi.AnsiConsole;
|
||||||
import org.geysermc.api.Connector;
|
import org.geysermc.api.Connector;
|
||||||
|
@ -55,7 +56,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -67,7 +67,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
@Getter
|
@Getter
|
||||||
public class GeyserConnector implements Connector {
|
public class GeyserConnector implements Connector {
|
||||||
|
|
||||||
public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v361.V361_CODEC;
|
public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v388.V388_CODEC;
|
||||||
|
|
||||||
public static final String NAME = "Geyser";
|
public static final String NAME = "Geyser";
|
||||||
public static final String VERSION = "1.0-SNAPSHOT";
|
public static final String VERSION = "1.0-SNAPSHOT";
|
||||||
|
@ -130,6 +130,7 @@ public class GeyserConnector implements Connector {
|
||||||
|
|
||||||
logger.setDebug(config.isDebugMode());
|
logger.setDebug(config.isDebugMode());
|
||||||
|
|
||||||
|
Toolbox.init();
|
||||||
TranslatorsInit.start();
|
TranslatorsInit.start();
|
||||||
|
|
||||||
commandMap = new GeyserCommandMap(this);
|
commandMap = new GeyserCommandMap(this);
|
||||||
|
|
|
@ -296,8 +296,9 @@ public class GeyserSession implements Player {
|
||||||
startGamePacket.setCurrentTick(0);
|
startGamePacket.setCurrentTick(0);
|
||||||
startGamePacket.setEnchantmentSeed(0);
|
startGamePacket.setEnchantmentSeed(0);
|
||||||
startGamePacket.setMultiplayerCorrelationId("");
|
startGamePacket.setMultiplayerCorrelationId("");
|
||||||
startGamePacket.setCachedPalette(Toolbox.CACHED_PALLETE.retainedDuplicate());
|
startGamePacket.setBlockPalette(Toolbox.CACHED_PALLETE);
|
||||||
startGamePacket.setItemEntries(Toolbox.ITEMS);
|
startGamePacket.setItemEntries(Toolbox.ITEMS);
|
||||||
|
startGamePacket.setMovementServerAuthoritative(true);
|
||||||
upstream.sendPacket(startGamePacket);
|
upstream.sendPacket(startGamePacket);
|
||||||
|
|
||||||
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
||||||
|
|
|
@ -61,7 +61,9 @@ public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHea
|
||||||
|
|
||||||
if (packet.getHealth() <= 0) {
|
if (packet.getHealth() <= 0) {
|
||||||
RespawnPacket respawnPacket = new RespawnPacket();
|
RespawnPacket respawnPacket = new RespawnPacket();
|
||||||
|
respawnPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
respawnPacket.setPosition(Vector3f.from(0, 72, 0));
|
respawnPacket.setPosition(Vector3f.from(0, 72, 0));
|
||||||
|
respawnPacket.setSpawnState(2); // client ready to respawn
|
||||||
session.getUpstream().sendPacket(new RespawnPacket());
|
session.getUpstream().sendPacket(new RespawnPacket());
|
||||||
|
|
||||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||||
|
|
|
@ -2,6 +2,8 @@ package org.geysermc.connector.utils;
|
||||||
|
|
||||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.ImageData;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.SerializedSkin;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -46,14 +48,12 @@ public class SkinUtils {
|
||||||
public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String username, long geyserId,
|
public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String username, long geyserId,
|
||||||
String skinId, byte[] skinData, byte[] capeData,
|
String skinId, byte[] skinData, byte[] capeData,
|
||||||
String geometryName, String geometryData) {
|
String geometryName, String geometryData) {
|
||||||
|
SerializedSkin serializedSkin = SerializedSkin.of(skinId, ImageData.of(skinData), ImageData.of(capeData), geometryName, geometryData, true);
|
||||||
|
|
||||||
PlayerListPacket.Entry entry = new PlayerListPacket.Entry(uuid);
|
PlayerListPacket.Entry entry = new PlayerListPacket.Entry(uuid);
|
||||||
entry.setName(username);
|
entry.setName(username);
|
||||||
entry.setEntityId(geyserId);
|
entry.setEntityId(geyserId);
|
||||||
entry.setSkinId(skinId);
|
entry.setSkin(serializedSkin);
|
||||||
entry.setSkinData(skinData != null ? skinData : SkinProvider.STEVE_SKIN);
|
|
||||||
entry.setCapeData(capeData);
|
|
||||||
entry.setGeometryName(geometryName);
|
|
||||||
entry.setGeometryData(geometryData);
|
|
||||||
entry.setXuid("");
|
entry.setXuid("");
|
||||||
entry.setPlatformChatId("");
|
entry.setPlatformChatId("");
|
||||||
return entry;
|
return entry;
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package org.geysermc.connector.utils;
|
package org.geysermc.connector.utils;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.nukkitx.network.VarInts;
|
import com.nukkitx.nbt.NbtUtils;
|
||||||
|
import com.nukkitx.nbt.stream.NBTInputStream;
|
||||||
|
import com.nukkitx.nbt.tag.CompoundTag;
|
||||||
|
import com.nukkitx.nbt.tag.ListTag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
||||||
import com.nukkitx.protocol.bedrock.v361.BedrockUtils;
|
|
||||||
import gnu.trove.map.TIntObjectMap;
|
import gnu.trove.map.TIntObjectMap;
|
||||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||||
import io.netty.buffer.ByteBuf;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
import org.geysermc.connector.console.GeyserLogger;
|
||||||
import org.geysermc.connector.network.translators.block.BlockEntry;
|
import org.geysermc.connector.network.translators.block.BlockEntry;
|
||||||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||||
|
@ -19,38 +21,42 @@ import java.util.*;
|
||||||
public class Toolbox {
|
public class Toolbox {
|
||||||
|
|
||||||
public static final Collection<StartGamePacket.ItemEntry> ITEMS;
|
public static final Collection<StartGamePacket.ItemEntry> ITEMS;
|
||||||
public static final ByteBuf CACHED_PALLETE;
|
public static ListTag<CompoundTag> CACHED_PALLETE;
|
||||||
|
|
||||||
public static final TIntObjectMap<ItemEntry> ITEM_ENTRIES;
|
public static final TIntObjectMap<ItemEntry> ITEM_ENTRIES;
|
||||||
public static final TIntObjectMap<BlockEntry> BLOCK_ENTRIES;
|
public static final TIntObjectMap<BlockEntry> BLOCK_ENTRIES;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
InputStream stream = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/cached_palette.json");
|
InputStream stream = GeyserConnector.class.getClassLoader().getResourceAsStream("bedrock/cached_palette.dat");
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
if (stream == null) {
|
||||||
List<LinkedHashMap<String, Object>> entries = new ArrayList<>();
|
throw new AssertionError("Unable to find cached_palette.dat");
|
||||||
|
|
||||||
try {
|
|
||||||
entries = mapper.readValue(stream, ArrayList.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuf cachedPalette = Unpooled.buffer();
|
|
||||||
VarInts.writeUnsignedInt(cachedPalette, entries.size());
|
|
||||||
|
|
||||||
Map<String, Integer> blockIdToIdentifier = new HashMap<>();
|
Map<String, Integer> blockIdToIdentifier = new HashMap<>();
|
||||||
|
CompoundTag tag;
|
||||||
|
|
||||||
for (Map<String, Object> entry : entries) {
|
NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream);
|
||||||
blockIdToIdentifier.put((String) entry.get("name"), (int) entry.get("id"));
|
try {
|
||||||
|
tag = (CompoundTag) nbtInputStream.readTag();
|
||||||
GlobalBlockPalette.registerMapping((int) entry.get("id") << 4 | (int) entry.get("data"));
|
System.out.println(tag.getValue().values());
|
||||||
BedrockUtils.writeString(cachedPalette, (String) entry.get("name"));
|
System.out.println(tag.getAsList("Palette", CompoundTag.class));
|
||||||
cachedPalette.writeShortLE((int) entry.get("data"));
|
nbtInputStream.close();
|
||||||
cachedPalette.writeShortLE((int) entry.get("id"));
|
} catch (Exception ex) {
|
||||||
|
GeyserLogger.DEFAULT.warning("Failed to get blocks from cached palette, please report this error!");
|
||||||
|
throw new AssertionError(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
CACHED_PALLETE = cachedPalette;
|
List<CompoundTag> entries = tag.getAsList("Palette", CompoundTag.class);
|
||||||
|
for (CompoundTag entry : entries) {
|
||||||
|
String name = entry.getAsString("name");
|
||||||
|
int id = entry.getAsShort("id");
|
||||||
|
int data = entry.getAsShort("meta");
|
||||||
|
|
||||||
|
blockIdToIdentifier.put(name, id);
|
||||||
|
GlobalBlockPalette.registerMapping(id << 4 | data);
|
||||||
|
}
|
||||||
|
|
||||||
|
CACHED_PALLETE = new ListTag<>("Palette", CompoundTag.class, tag.getAsList("Palette", CompoundTag.class));
|
||||||
InputStream stream2 = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/items.json");
|
InputStream stream2 = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/items.json");
|
||||||
if (stream2 == null) {
|
if (stream2 == null) {
|
||||||
throw new AssertionError("Items Table not found");
|
throw new AssertionError("Items Table not found");
|
||||||
|
|
BIN
connector/src/main/resources/bedrock/cached_palette.dat
Normal file
BIN
connector/src/main/resources/bedrock/cached_palette.dat
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue