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

More work on 1.13

Dieser Commit ist enthalten in:
RednedEpic 2019-11-05 18:55:59 -06:00 committet von RednedEpic
Ursprung 18c13067b8
Commit 90e6ebc1be
6 geänderte Dateien mit 57 neuen und 50 gelöschten Zeilen

Datei anzeigen

@ -50,6 +50,7 @@ import org.geysermc.connector.plugin.GeyserPluginLoader;
import org.geysermc.connector.plugin.GeyserPluginManager;
import org.geysermc.connector.thread.PingPassthroughThread;
import org.geysermc.connector.utils.FileUtils;
import org.geysermc.connector.utils.Toolbox;
import java.io.File;
import java.io.IOException;
@ -128,6 +129,7 @@ public class GeyserConnector implements Connector {
logger.setDebug(config.isDebugMode());
Toolbox.init();
TranslatorsInit.start();
commandMap = new GeyserCommandMap(this);

Datei anzeigen

@ -43,6 +43,7 @@ import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
import com.nukkitx.protocol.bedrock.data.GameRule;
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
import com.nukkitx.protocol.bedrock.packet.TextPacket;
@ -57,7 +58,9 @@ import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.inventory.PlayerInventory;
import org.geysermc.connector.network.session.cache.*;
import org.geysermc.connector.network.translators.Registry;
import org.geysermc.connector.network.translators.TranslatorsInit;
import org.geysermc.connector.utils.Toolbox;
import org.geysermc.connector.world.chunk.ChunkPosition;
import java.net.InetSocketAddress;
import java.util.UUID;
@ -119,14 +122,33 @@ public class GeyserSession implements Player {
}
public void connect(RemoteServer remoteServer) {
// This has to be sent first so the player actually joins
startGame();
this.remoteServer = remoteServer;
if (!(connector.getConfig().getRemote().getAuthType().hashCode() == "online".hashCode())) {
connector.getLogger().info("Attempting to login using offline mode... authentication is disabled.");
authenticate(authenticationData.getName());
}
Vector3f pos = Vector3f.ZERO;
int chunkX = pos.getFloorX() >> 4;
int chunkZ = pos.getFloorZ() >> 4;
for (int x = -3; x < 3; x++) {
for (int z = -3; z < 3; z++) {
LevelChunkPacket data = new LevelChunkPacket();
data.setChunkX(chunkX + x);
data.setChunkZ(chunkZ + z);
data.setSubChunksLength(0);
data.setData(TranslatorsInit.EMPTY_LEVEL_CHUNK_DATA);
upstream.sendPacket(data);
}
}
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
upstream.sendPacket(playStatusPacket);
System.out.println("play status sent");
System.out.println(playerEntity.getPosition());
}
public void authenticate(String username) {
@ -299,9 +321,5 @@ public class GeyserSession implements Player {
startGamePacket.setItemEntries(Toolbox.ITEMS);
startGamePacket.setVanillaVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
upstream.sendPacket(startGamePacket);
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
upstream.sendPacket(playStatusPacket);
}
}

Datei anzeigen

@ -26,10 +26,17 @@
package org.geysermc.connector.network.translators.java;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import com.nukkitx.protocol.bedrock.packet.*;
import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.bedrock.packet.ChunkRadiusUpdatedPacket;
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.world.chunk.ChunkPosition;
public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacket> {
@ -38,16 +45,14 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
bedrockPacket.setUniqueEntityId(session.getPlayerEntity().getGeyserId());
bedrockPacket.setPlayerPermission(1);
session.getUpstream().sendPacketImmediately(bedrockPacket);
session.getUpstream().sendPacket(bedrockPacket);
PlayStatusPacket playStatus = new PlayStatusPacket();
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
session.getUpstream().sendPacketImmediately(playStatus);
session.getUpstream().sendPacket(playStatus);
PlayerEntity entity = session.getPlayerEntity();
if (entity == null) return;
session.getPlayerEntity().setEntityId(packet.getEntityId());
entity.setEntityId(packet.getEntityId());
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(packet.getGameMode().ordinal());
@ -62,9 +67,9 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
session.setRenderDistance(packet.getViewDistance() + 1); // +1 to be sure it includes every chunk
if (session.getRenderDistance() > 32) session.setRenderDistance(32); // <3 u ViaVersion but I don't like crashing clients x)
ChunkRadiusUpdatedPacket packet1 = new ChunkRadiusUpdatedPacket();
packet1.setRadius(session.getRenderDistance());
session.getUpstream().sendPacket(packet1);
ChunkRadiusUpdatedPacket chunkRadiusPacket = new ChunkRadiusUpdatedPacket();
chunkRadiusPacket.setRadius(session.getRenderDistance());
session.getUpstream().sendPacket(chunkRadiusPacket);
session.setSpawned(true);
}

Datei anzeigen

@ -1,12 +0,0 @@
package org.geysermc.connector.utils;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@Getter
public class BiValue<F, S> {
private F f;
private S s;
}

Datei anzeigen

@ -27,7 +27,7 @@ public class SkinUtils {
profile.getIdAsString(),
SkinProvider.getCachedSkin(profile.getId()).getSkinData(),
SkinProvider.getCachedCape(data.getCapeUrl()).getCapeData(),
"geometry.humanoid.custom" + (data.isAlex() ? "Slim" : ""),
getLegacySkinGeometry("geometry.humanoid.custom" + (data.isAlex() ? "Slim" : "")),
""
);
}
@ -40,7 +40,7 @@ public class SkinUtils {
profile.getIdAsString(),
SkinProvider.STEVE_SKIN,
SkinProvider.EMPTY_CAPE.getCapeData(),
"geometry.humanoid",
getLegacySkinGeometry("geometry.humanoid"),
""
);
}
@ -48,7 +48,7 @@ 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);
SerializedSkin serializedSkin = SerializedSkin.of(skinId, ImageData.of(32, 64, skinData), ImageData.of(32, 64, capeData), geometryName, geometryData, true);
PlayerListPacket.Entry entry = new PlayerListPacket.Entry(uuid);
entry.setName(username);
@ -56,6 +56,7 @@ public class SkinUtils {
entry.setSkin(serializedSkin);
entry.setXuid("");
entry.setPlatformChatId("");
entry.setTeacher(false);
return entry;
}
@ -122,7 +123,7 @@ public class SkinUtils {
entity.getUuid().toString(),
skin.getSkinData(),
cape.getCapeData(),
"geometry.humanoid.custom" + (data.isAlex() ? "Slim" : ""),
getLegacySkinGeometry("geometry.humanoid.custom" + (data.isAlex() ? "Slim" : "")),
""
);
@ -145,4 +146,8 @@ public class SkinUtils {
});
});
}
private static String getLegacySkinGeometry(String geometryName) {
return "{\"geometry\" :{\"default\" :\"" + geometryName + "\"}}";
}
}

Datei anzeigen

@ -20,13 +20,13 @@ import java.util.*;
public class Toolbox {
public static final Collection<StartGamePacket.ItemEntry> ITEMS;
public static final Collection<StartGamePacket.ItemEntry> ITEMS = new ArrayList<>();
public static ListTag<CompoundTag> BLOCKS;
public static final TIntObjectMap<ItemEntry> ITEM_ENTRIES;
public static final TIntObjectMap<BlockEntry> BLOCK_ENTRIES;
public static final TIntObjectMap<ItemEntry> ITEM_ENTRIES = new TIntObjectHashMap<>();
public static final TIntObjectMap<BlockEntry> BLOCK_ENTRIES = new TIntObjectHashMap<>();
static {
public static void init() {
InputStream stream = GeyserConnector.class.getClassLoader().getResourceAsStream("bedrock/runtime_block_states.dat");
if (stream == null) {
throw new AssertionError("Unable to find bedrock/runtime_block_states.dat");
@ -67,13 +67,10 @@ public class Toolbox {
e.printStackTrace();
}
List<StartGamePacket.ItemEntry> startGameEntries = new ArrayList<>();
for (Map entry : startGameItems) {
startGameEntries.add(new StartGamePacket.ItemEntry((String) entry.get("name"), (short) ((int) entry.get("id"))));
ITEMS.add(new StartGamePacket.ItemEntry((String) entry.get("name"), (short) ((int) entry.get("id"))));
}
ITEMS = startGameEntries;
InputStream itemStream = Toolbox.class.getClassLoader().getResourceAsStream("items.json");
ObjectMapper itemMapper = new ObjectMapper();
Map<String, Map<String, Object>> items = new HashMap<>();
@ -84,16 +81,12 @@ public class Toolbox {
ex.printStackTrace();
}
TIntObjectMap<ItemEntry> itemEntries = new TIntObjectHashMap<>();
int itemIndex = 0;
for (Map.Entry<String, Map<String, Object>> itemEntry : items.entrySet()) {
itemEntries.put(itemIndex, new ItemEntry(itemEntry.getKey(), itemIndex, (int) itemEntry.getValue().get("bedrock_id"), (int) itemEntry.getValue().get("bedrock_data")));
ITEM_ENTRIES.put(itemIndex, new ItemEntry(itemEntry.getKey(), itemIndex, (int) itemEntry.getValue().get("bedrock_id"), (int) itemEntry.getValue().get("bedrock_data")));
itemIndex++;
}
ITEM_ENTRIES = itemEntries;
InputStream blockStream = Toolbox.class.getClassLoader().getResourceAsStream("blocks.json");
ObjectMapper blockMapper = new ObjectMapper();
Map<String, Map<String, Object>> blocks = new HashMap<>();
@ -104,20 +97,16 @@ public class Toolbox {
ex.printStackTrace();
}
TIntObjectMap<BlockEntry> blockEntries = new TIntObjectHashMap<>();
int blockIndex = 0;
for (Map.Entry<String, Map<String, Object>> itemEntry : blocks.entrySet()) {
if (!blockIdToIdentifier.containsKey(itemEntry.getValue().get("bedrock_identifier"))) {
GeyserLogger.DEFAULT.debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " was not found for bedrock edition!");
blockEntries.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, 248, 0)); // update block
BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, 248, 0)); // update block
} else {
blockEntries.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, blockIdToIdentifier.get(itemEntry.getValue().get("bedrock_identifier")), (int) itemEntry.getValue().get("bedrock_data")));
BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, blockIdToIdentifier.get(itemEntry.getValue().get("bedrock_identifier")), (int) itemEntry.getValue().get("bedrock_data")));
}
blockIndex++;
}
BLOCK_ENTRIES = blockEntries;
}
}