Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 00:23:03 +01:00
Merge branch 'feature/1.13-bedrock' into 1.13-inventory
Dieser Commit ist enthalten in:
Commit
ce7237392b
@ -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>
|
||||
|
@ -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";
|
||||
@ -97,7 +97,6 @@ public class GeyserConnector implements Connector {
|
||||
}
|
||||
|
||||
private GeyserConnector() {
|
||||
|
||||
long startupTime = System.currentTimeMillis();
|
||||
|
||||
// Metric
|
||||
@ -117,7 +116,6 @@ public class GeyserConnector implements Connector {
|
||||
|
||||
try {
|
||||
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||
|
||||
config = FileUtils.loadConfig(configFile, GeyserConfiguration.class);
|
||||
} catch (IOException ex) {
|
||||
logger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
|
||||
@ -130,6 +128,7 @@ public class GeyserConnector implements Connector {
|
||||
|
||||
logger.setDebug(config.isDebugMode());
|
||||
|
||||
Toolbox.init();
|
||||
TranslatorsInit.start();
|
||||
|
||||
commandMap = new GeyserCommandMap(this);
|
||||
|
@ -90,55 +90,40 @@ public class GeyserLogger implements org.geysermc.api.logger.Logger {
|
||||
|
||||
@Override
|
||||
public void severe(String message) {
|
||||
waitFor();
|
||||
System.out.println(printConsole(ChatColor.DARK_RED + message, colored));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String message, Throwable error) {
|
||||
waitFor();
|
||||
System.out.println(printConsole(ChatColor.DARK_RED + message + "\n" + error.getMessage(), colored));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message) {
|
||||
waitFor();
|
||||
System.out.println(printConsole(ChatColor.RED + message, colored));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, Throwable error) {
|
||||
waitFor();
|
||||
System.out.println(printConsole(ChatColor.RED + message + "\n" + error, colored));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String message) {
|
||||
waitFor();
|
||||
System.out.println(printConsole(ChatColor.YELLOW + message, colored));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String message) {
|
||||
waitFor();
|
||||
System.out.println(printConsole(ChatColor.WHITE + message, colored));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
waitFor();
|
||||
|
||||
if (debug)
|
||||
System.out.println(printConsole(ChatColor.GRAY + message, colored));
|
||||
}
|
||||
|
||||
private synchronized void waitFor() {
|
||||
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
}
|
||||
|
||||
public static String printConsole(String message, boolean colors) {
|
||||
return colors ? ChatColor.toANSI(message + ChatColor.RESET) : ChatColor.stripColors(message + ChatColor.RESET);
|
||||
}
|
||||
|
@ -55,48 +55,45 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
||||
|
||||
@Override
|
||||
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
|
||||
PingEvent pong = new PingEvent(inetSocketAddress);
|
||||
GeyserLogger.DEFAULT.debug(inetSocketAddress + " has pinged you!");
|
||||
GeyserConfiguration config = connector.getConfig();
|
||||
pong.setEdition("MCPE");
|
||||
pong.setGameType("Default");
|
||||
pong.setNintendoLimited(false);
|
||||
pong.setProtocolVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion());
|
||||
pong.setVersion("1.12.0");
|
||||
PingEvent pongEvent = new PingEvent(inetSocketAddress);
|
||||
pongEvent.setEdition("MCPE");
|
||||
pongEvent.setGameType("Default");
|
||||
pongEvent.setNintendoLimited(false);
|
||||
pongEvent.setProtocolVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion());
|
||||
pongEvent.setVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
||||
|
||||
connector.getPluginManager().runEvent(pong);
|
||||
connector.getPluginManager().runEvent(pongEvent);
|
||||
if (connector.getConfig().isPingPassthrough()) {
|
||||
ServerStatusInfo serverInfo = connector.getPassthroughThread().getInfo();
|
||||
|
||||
if (serverInfo != null) {
|
||||
pong.setMotd(MessageUtils.getBedrockMessage(serverInfo.getDescription()));
|
||||
pong.setSubMotd(config.getBedrock().getMotd2());
|
||||
pong.setPlayerCount(serverInfo.getPlayerInfo().getOnlinePlayers());
|
||||
pong.setMaximumPlayerCount(serverInfo.getPlayerInfo().getMaxPlayers());
|
||||
pongEvent.setMotd(MessageUtils.getBedrockMessage(serverInfo.getDescription()));
|
||||
pongEvent.setSubMotd(config.getBedrock().getMotd2());
|
||||
pongEvent.setPlayerCount(serverInfo.getPlayerInfo().getOnlinePlayers());
|
||||
pongEvent.setMaximumPlayerCount(serverInfo.getPlayerInfo().getMaxPlayers());
|
||||
}
|
||||
} else {
|
||||
pong.setPlayerCount(1);
|
||||
pong.setMaximumPlayerCount(config.getMaxPlayers());
|
||||
pong.setMotd(config.getBedrock().getMotd1());
|
||||
pong.setSubMotd(config.getBedrock().getMotd2());
|
||||
pongEvent.setPlayerCount(1);
|
||||
pongEvent.setMaximumPlayerCount(config.getMaxPlayers());
|
||||
pongEvent.setMotd(config.getBedrock().getMotd1());
|
||||
pongEvent.setSubMotd(config.getBedrock().getMotd2());
|
||||
}
|
||||
|
||||
BedrockPong c = new BedrockPong();
|
||||
|
||||
c.setEdition(pong.getEdition());
|
||||
c.setGameType(pong.getGameType());
|
||||
c.setNintendoLimited(pong.isNintendoLimited());
|
||||
c.setProtocolVersion(pong.getProtocolVersion());
|
||||
c.setVersion(pong.getVersion());
|
||||
|
||||
c.setMotd(pong.getMotd());
|
||||
c.setSubMotd(pong.getSubMotd());
|
||||
c.setPlayerCount(pong.getPlayerCount());
|
||||
c.setMaximumPlayerCount(pong.getMaximumPlayerCount());
|
||||
c.setIpv4Port(config.getBedrock().getPort());
|
||||
|
||||
return c;
|
||||
BedrockPong pong = new BedrockPong();
|
||||
pong.setEdition(pongEvent.getEdition());
|
||||
pong.setGameType(pongEvent.getGameType());
|
||||
pong.setNintendoLimited(pongEvent.isNintendoLimited());
|
||||
pong.setProtocolVersion(pongEvent.getProtocolVersion());
|
||||
pong.setVersion(pongEvent.getVersion());
|
||||
pong.setMotd(pongEvent.getMotd());
|
||||
pong.setSubMotd(pongEvent.getSubMotd());
|
||||
pong.setPlayerCount(pongEvent.getPlayerCount());
|
||||
pong.setMaximumPlayerCount(pongEvent.getMaximumPlayerCount());
|
||||
pong.setIpv4Port(config.getBedrock().getPort());
|
||||
|
||||
return pong;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -716,4 +716,49 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
|
||||
public boolean handle(VideoStreamConnectPacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(EmotePacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(TickSyncPacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(AnvilDamagePacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NetworkSettingsPacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PlayerAuthInputPacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(SettingsCommandPacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(EducationSettingsPacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(CompletedUsingItemPacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MultiplayerSettingsPacket packet) {
|
||||
return defaultHandler(packet);
|
||||
}
|
||||
}
|
@ -45,7 +45,6 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean handle(LoginPacket loginPacket) {
|
||||
// TODO: Implement support for multiple protocols
|
||||
if (loginPacket.getProtocolVersion() != GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion()) {
|
||||
connector.getLogger().debug("unsupported");
|
||||
session.getUpstream().disconnect("Unsupported Bedrock version. Are you running an outdated version?");
|
||||
@ -56,16 +55,16 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||
|
||||
PlayStatusPacket playStatus = new PlayStatusPacket();
|
||||
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
|
||||
session.getUpstream().sendPacketImmediately(playStatus);
|
||||
session.getUpstream().sendPacket(playStatus);
|
||||
|
||||
ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket();
|
||||
session.getUpstream().sendPacketImmediately(resourcePacksInfo);
|
||||
session.getUpstream().sendPacket(resourcePacksInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(ResourcePackClientResponsePacket textPacket) {
|
||||
switch (textPacket.getStatus()) {
|
||||
public boolean handle(ResourcePackClientResponsePacket packet) {
|
||||
switch (packet.getStatus()) {
|
||||
case COMPLETED:
|
||||
session.connect(connector.getRemoteServer());
|
||||
connector.getLogger().info("Player connected with username " + session.getAuthenticationData().getName());
|
||||
@ -74,7 +73,8 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||
ResourcePackStackPacket stack = new ResourcePackStackPacket();
|
||||
stack.setExperimental(false);
|
||||
stack.setForcedToAccept(false);
|
||||
session.getUpstream().sendPacketImmediately(stack);
|
||||
stack.setGameVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
||||
session.getUpstream().sendPacket(stack);
|
||||
break;
|
||||
default:
|
||||
session.getUpstream().disconnect("disconnectionScreen.resourcePack");
|
||||
|
@ -40,10 +40,15 @@ import com.nukkitx.math.vector.Vector2f;
|
||||
import com.nukkitx.math.vector.Vector2i;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.nbt.tag.CompoundTag;
|
||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
||||
import com.nukkitx.protocol.bedrock.data.GameRule;
|
||||
import com.nukkitx.protocol.bedrock.packet.AvailableEntityIdentifiersPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.BiomeDefinitionListPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
||||
@ -59,6 +64,7 @@ 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 java.net.InetSocketAddress;
|
||||
@ -129,14 +135,49 @@ 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 = -5; x < 5; x++) {
|
||||
for (int z = -5; z < 5; z++) {
|
||||
NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket();
|
||||
chunkPublisherUpdatePacket.setPosition(pos.toInt());
|
||||
chunkPublisherUpdatePacket.setRadius(renderDistance << 4);
|
||||
upstream.sendPacket(chunkPublisherUpdatePacket);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
BiomeDefinitionListPacket biomePacket = new BiomeDefinitionListPacket();
|
||||
biomePacket.setTag(CompoundTag.EMPTY);
|
||||
upstream.sendPacket(biomePacket);
|
||||
AvailableEntityIdentifiersPacket entityPacket = new AvailableEntityIdentifiersPacket();
|
||||
entityPacket.setTag(CompoundTag.EMPTY);
|
||||
upstream.sendPacket(entityPacket);
|
||||
|
||||
InventoryContentPacket creativePacket = new InventoryContentPacket();
|
||||
creativePacket.setContainerId(ContainerId.CREATIVE);
|
||||
creativePacket.setContents(Toolbox.CREATIVE_ITEMS);
|
||||
upstream.sendPacket(creativePacket);
|
||||
|
||||
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
||||
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||
upstream.sendPacket(playStatusPacket);
|
||||
|
||||
connector.getLogger().debug("play status sent");
|
||||
}
|
||||
|
||||
public void authenticate(String username) {
|
||||
@ -268,15 +309,15 @@ public class GeyserSession implements Player {
|
||||
startGamePacket.setPlayerPosition(Vector3f.from(0, 69, 0));
|
||||
startGamePacket.setRotation(Vector2f.from(1, 1));
|
||||
|
||||
startGamePacket.setSeed(0);
|
||||
startGamePacket.setSeed(-1);
|
||||
startGamePacket.setDimensionId(playerEntity.getDimension());
|
||||
startGamePacket.setGeneratorId(1);
|
||||
startGamePacket.setLevelGamemode(0);
|
||||
startGamePacket.setDifficulty(1);
|
||||
startGamePacket.setDefaultSpawn(Vector3i.ZERO);
|
||||
startGamePacket.setAcheivementsDisabled(true);
|
||||
startGamePacket.setTime(0);
|
||||
startGamePacket.setEduLevel(false);
|
||||
startGamePacket.setTime(-1);
|
||||
startGamePacket.setEduEditionOffers(0);
|
||||
startGamePacket.setEduFeaturesEnabled(false);
|
||||
startGamePacket.setRainLevel(0);
|
||||
startGamePacket.setLightningLevel(0);
|
||||
@ -302,20 +343,13 @@ public class GeyserSession implements Player {
|
||||
startGamePacket.setLevelId("world");
|
||||
startGamePacket.setWorldName("world");
|
||||
startGamePacket.setPremiumWorldTemplateId("00000000-0000-0000-0000-000000000000");
|
||||
startGamePacket.setCurrentTick(0);
|
||||
// startGamePacket.setCurrentTick(0);
|
||||
startGamePacket.setEnchantmentSeed(0);
|
||||
startGamePacket.setMultiplayerCorrelationId("");
|
||||
startGamePacket.setCachedPalette(Toolbox.CACHED_PALLETE.retainedDuplicate());
|
||||
startGamePacket.setBlockPalette(Toolbox.BLOCKS);
|
||||
startGamePacket.setItemEntries(Toolbox.ITEMS);
|
||||
startGamePacket.setVanillaVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
||||
// startGamePacket.setMovementServerAuthoritative(true);
|
||||
upstream.sendPacket(startGamePacket);
|
||||
|
||||
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
||||
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||
upstream.sendPacket(playStatusPacket);
|
||||
|
||||
InventoryContentPacket creativePacket = new InventoryContentPacket();
|
||||
creativePacket.setContainerId(ContainerId.CREATIVE);
|
||||
creativePacket.setContents(Toolbox.CREATIVE_ITEMS);
|
||||
upstream.sendPacket(creativePacket);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -59,9 +59,11 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||
session.setGameMode(packet.getGamemode());
|
||||
|
||||
/*
|
||||
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
||||
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||
session.getUpstream().sendPacket(playStatusPacket);
|
||||
*/
|
||||
}
|
||||
|
||||
private int getDimension(int javaDimension) {
|
||||
|
@ -61,8 +61,10 @@ 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));
|
||||
session.getUpstream().sendPacket(new RespawnPacket());
|
||||
respawnPacket.setSpawnState(0); // state searching for spawn
|
||||
session.getUpstream().sendPacket(respawnPacket);
|
||||
|
||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.getDownstream().getSession().send(javaRespawnPacket);
|
||||
|
@ -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;
|
||||
}
|
@ -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;
|
||||
@ -25,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" : "")),
|
||||
""
|
||||
);
|
||||
}
|
||||
@ -38,7 +40,7 @@ public class SkinUtils {
|
||||
profile.getIdAsString(),
|
||||
SkinProvider.STEVE_SKIN,
|
||||
SkinProvider.EMPTY_CAPE.getCapeData(),
|
||||
"geometry.humanoid",
|
||||
getLegacySkinGeometry("geometry.humanoid"),
|
||||
""
|
||||
);
|
||||
}
|
||||
@ -46,16 +48,15 @@ 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(64, 64, skinData), ImageData.of(64, 32, 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("");
|
||||
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 + "\"}}";
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,15 @@ package org.geysermc.connector.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nukkitx.nbt.NbtUtils;
|
||||
import com.nukkitx.network.VarInts;
|
||||
import com.nukkitx.nbt.stream.NBTInputStream;
|
||||
import com.nukkitx.nbt.tag.CompoundTag;
|
||||
import com.nukkitx.nbt.tag.ListTag;
|
||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||
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;
|
||||
@ -21,40 +22,41 @@ import java.util.*;
|
||||
|
||||
public class Toolbox {
|
||||
|
||||
public static final Collection<StartGamePacket.ItemEntry> ITEMS;
|
||||
public static final ByteBuf CACHED_PALLETE;
|
||||
public static final ItemData[] CREATIVE_ITEMS;
|
||||
public static final Collection<StartGamePacket.ItemEntry> ITEMS = new ArrayList<>();
|
||||
public static ListTag<CompoundTag> BLOCKS;
|
||||
public static ItemData[] CREATIVE_ITEMS;
|
||||
|
||||
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 {
|
||||
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();
|
||||
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");
|
||||
}
|
||||
|
||||
ByteBuf cachedPalette = Unpooled.buffer();
|
||||
VarInts.writeUnsignedInt(cachedPalette, entries.size());
|
||||
|
||||
Map<String, Integer> blockIdToIdentifier = new HashMap<>();
|
||||
ListTag<CompoundTag> blocksTag;
|
||||
|
||||
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 {
|
||||
blocksTag = (ListTag<CompoundTag>) nbtInputStream.readTag();
|
||||
nbtInputStream.close();
|
||||
} catch (Exception ex) {
|
||||
GeyserLogger.DEFAULT.warning("Failed to get blocks from runtime block states, please report this error!");
|
||||
throw new AssertionError(ex);
|
||||
}
|
||||
|
||||
CACHED_PALLETE = cachedPalette;
|
||||
for (CompoundTag entry : blocksTag.getValue()) {
|
||||
String name = entry.getAsCompound("block").getAsString("name");
|
||||
int id = entry.getAsShort("id");
|
||||
int data = entry.getAsShort("meta");
|
||||
|
||||
blockIdToIdentifier.put(name, id);
|
||||
GlobalBlockPalette.registerMapping(id << 4 | data);
|
||||
}
|
||||
|
||||
BLOCKS = blocksTag;
|
||||
InputStream stream2 = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/items.json");
|
||||
if (stream2 == null) {
|
||||
throw new AssertionError("Items Table not found");
|
||||
@ -68,13 +70,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<>();
|
||||
@ -85,16 +84,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<>();
|
||||
@ -105,22 +100,18 @@ 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") + " does not exist on bedrock edition!");
|
||||
blockEntries.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, 248, 0)); // update block
|
||||
GeyserLogger.DEFAULT.debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " was not found for bedrock edition!");
|
||||
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;
|
||||
|
||||
InputStream creativeItemStream = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/creative_items.json");
|
||||
ObjectMapper creativeItemMapper = new ObjectMapper();
|
||||
List<LinkedHashMap<String, Object>> creativeItemEntries = new ArrayList<>();
|
||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
BIN
connector/src/main/resources/bedrock/runtime_block_states.dat
Normale Datei
BIN
connector/src/main/resources/bedrock/runtime_block_states.dat
Normale Datei
Binäre Datei nicht angezeigt.
2
pom.xml
2
pom.xml
@ -88,7 +88,7 @@
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources/</directory>
|
||||
<filtering>true</filtering>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren