3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 16:12:46 +01:00

Start on 1.13 changes (not functional yet)

Cached palette still needs fixing, therefore this build actually does nothing yet.
Dieser Commit ist enthalten in:
RednedEpic 2019-10-30 21:14:23 -05:00 committet von RednedEpic
Ursprung 7ce4b22693
Commit 0e2f64b95a
8 geänderte Dateien mit 45 neuen und 16592 gelöschten Zeilen

Datei anzeigen

@ -74,8 +74,8 @@
</dependency>
<dependency>
<groupId>com.nukkitx.protocol</groupId>
<artifactId>bedrock-v361</artifactId>
<version>2.3.0</version>
<artifactId>bedrock-v388</artifactId>
<version>2.4.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>

Datei anzeigen

@ -27,7 +27,8 @@ package org.geysermc.connector;
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
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 org.fusesource.jansi.AnsiConsole;
import org.geysermc.api.Connector;
@ -55,7 +56,6 @@ import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@ -67,7 +67,7 @@ import java.util.concurrent.TimeUnit;
@Getter
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 VERSION = "1.0-SNAPSHOT";
@ -130,6 +130,7 @@ public class GeyserConnector implements Connector {
logger.setDebug(config.isDebugMode());
Toolbox.init();
TranslatorsInit.start();
commandMap = new GeyserCommandMap(this);

Datei anzeigen

@ -296,8 +296,9 @@ public class GeyserSession implements Player {
startGamePacket.setCurrentTick(0);
startGamePacket.setEnchantmentSeed(0);
startGamePacket.setMultiplayerCorrelationId("");
startGamePacket.setCachedPalette(Toolbox.CACHED_PALLETE.retainedDuplicate());
startGamePacket.setBlockPalette(Toolbox.CACHED_PALLETE);
startGamePacket.setItemEntries(Toolbox.ITEMS);
startGamePacket.setMovementServerAuthoritative(true);
upstream.sendPacket(startGamePacket);
PlayStatusPacket playStatusPacket = new PlayStatusPacket();

Datei anzeigen

@ -61,7 +61,9 @@ public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHea
if (packet.getHealth() <= 0) {
RespawnPacket respawnPacket = new RespawnPacket();
respawnPacket.setRuntimeEntityId(entity.getGeyserId());
respawnPacket.setPosition(Vector3f.from(0, 72, 0));
respawnPacket.setSpawnState(2); // client ready to respawn
session.getUpstream().sendPacket(new RespawnPacket());
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);

Datei anzeigen

@ -2,6 +2,8 @@ package org.geysermc.connector.utils;
import com.github.steveice10.mc.auth.data.GameProfile;
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 lombok.AllArgsConstructor;
import lombok.Getter;
@ -46,14 +48,12 @@ public class SkinUtils {
public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String username, long geyserId,
String skinId, byte[] skinData, byte[] capeData,
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);
entry.setName(username);
entry.setEntityId(geyserId);
entry.setSkinId(skinId);
entry.setSkinData(skinData != null ? skinData : SkinProvider.STEVE_SKIN);
entry.setCapeData(capeData);
entry.setGeometryName(geometryName);
entry.setGeometryData(geometryData);
entry.setSkin(serializedSkin);
entry.setXuid("");
entry.setPlatformChatId("");
return entry;

Datei anzeigen

@ -1,13 +1,15 @@
package org.geysermc.connector.utils;
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.v361.BedrockUtils;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.console.GeyserLogger;
import org.geysermc.connector.network.translators.block.BlockEntry;
import org.geysermc.connector.network.translators.item.ItemEntry;
@ -19,38 +21,42 @@ import java.util.*;
public class Toolbox {
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<BlockEntry> BLOCK_ENTRIES;
static {
InputStream stream = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/cached_palette.json");
ObjectMapper mapper = new ObjectMapper();
List<LinkedHashMap<String, Object>> entries = new ArrayList<>();
try {
entries = mapper.readValue(stream, ArrayList.class);
} catch (Exception e) {
e.printStackTrace();
InputStream stream = GeyserConnector.class.getClassLoader().getResourceAsStream("bedrock/cached_palette.dat");
if (stream == null) {
throw new AssertionError("Unable to find cached_palette.dat");
}
ByteBuf cachedPalette = Unpooled.buffer();
VarInts.writeUnsignedInt(cachedPalette, entries.size());
Map<String, Integer> blockIdToIdentifier = new HashMap<>();
CompoundTag tag;
for (Map<String, Object> entry : entries) {
blockIdToIdentifier.put((String) entry.get("name"), (int) entry.get("id"));
GlobalBlockPalette.registerMapping((int) entry.get("id") << 4 | (int) entry.get("data"));
BedrockUtils.writeString(cachedPalette, (String) entry.get("name"));
cachedPalette.writeShortLE((int) entry.get("data"));
cachedPalette.writeShortLE((int) entry.get("id"));
NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream);
try {
tag = (CompoundTag) nbtInputStream.readTag();
System.out.println(tag.getValue().values());
System.out.println(tag.getAsList("Palette", CompoundTag.class));
nbtInputStream.close();
} 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");
if (stream2 == null) {
throw new AssertionError("Items Table not found");

Binäre Datei nicht angezeigt.

Datei-Diff unterdrückt, da er zu groß ist Diff laden