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>
|
||||||
<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";
|
||||||
@ -97,7 +97,6 @@ public class GeyserConnector implements Connector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GeyserConnector() {
|
private GeyserConnector() {
|
||||||
|
|
||||||
long startupTime = System.currentTimeMillis();
|
long startupTime = System.currentTimeMillis();
|
||||||
|
|
||||||
// Metric
|
// Metric
|
||||||
@ -117,7 +116,6 @@ public class GeyserConnector implements Connector {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||||
|
|
||||||
config = FileUtils.loadConfig(configFile, GeyserConfiguration.class);
|
config = FileUtils.loadConfig(configFile, GeyserConfiguration.class);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", 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());
|
logger.setDebug(config.isDebugMode());
|
||||||
|
|
||||||
|
Toolbox.init();
|
||||||
TranslatorsInit.start();
|
TranslatorsInit.start();
|
||||||
|
|
||||||
commandMap = new GeyserCommandMap(this);
|
commandMap = new GeyserCommandMap(this);
|
||||||
|
@ -90,55 +90,40 @@ public class GeyserLogger implements org.geysermc.api.logger.Logger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void severe(String message) {
|
public void severe(String message) {
|
||||||
waitFor();
|
|
||||||
System.out.println(printConsole(ChatColor.DARK_RED + message, colored));
|
System.out.println(printConsole(ChatColor.DARK_RED + message, colored));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void severe(String message, Throwable error) {
|
public void severe(String message, Throwable error) {
|
||||||
waitFor();
|
|
||||||
System.out.println(printConsole(ChatColor.DARK_RED + message + "\n" + error.getMessage(), colored));
|
System.out.println(printConsole(ChatColor.DARK_RED + message + "\n" + error.getMessage(), colored));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(String message) {
|
public void error(String message) {
|
||||||
waitFor();
|
|
||||||
System.out.println(printConsole(ChatColor.RED + message, colored));
|
System.out.println(printConsole(ChatColor.RED + message, colored));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(String message, Throwable error) {
|
public void error(String message, Throwable error) {
|
||||||
waitFor();
|
|
||||||
System.out.println(printConsole(ChatColor.RED + message + "\n" + error, colored));
|
System.out.println(printConsole(ChatColor.RED + message + "\n" + error, colored));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void warning(String message) {
|
public void warning(String message) {
|
||||||
waitFor();
|
|
||||||
System.out.println(printConsole(ChatColor.YELLOW + message, colored));
|
System.out.println(printConsole(ChatColor.YELLOW + message, colored));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void info(String message) {
|
public void info(String message) {
|
||||||
waitFor();
|
|
||||||
System.out.println(printConsole(ChatColor.WHITE + message, colored));
|
System.out.println(printConsole(ChatColor.WHITE + message, colored));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String message) {
|
public void debug(String message) {
|
||||||
waitFor();
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println(printConsole(ChatColor.GRAY + message, colored));
|
System.out.println(printConsole(ChatColor.GRAY + message, colored));
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void waitFor() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String printConsole(String message, boolean colors) {
|
public static String printConsole(String message, boolean colors) {
|
||||||
return colors ? ChatColor.toANSI(message + ChatColor.RESET) : ChatColor.stripColors(message + ChatColor.RESET);
|
return colors ? ChatColor.toANSI(message + ChatColor.RESET) : ChatColor.stripColors(message + ChatColor.RESET);
|
||||||
}
|
}
|
||||||
|
@ -55,48 +55,45 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
|
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
|
||||||
PingEvent pong = new PingEvent(inetSocketAddress);
|
|
||||||
GeyserLogger.DEFAULT.debug(inetSocketAddress + " has pinged you!");
|
GeyserLogger.DEFAULT.debug(inetSocketAddress + " has pinged you!");
|
||||||
GeyserConfiguration config = connector.getConfig();
|
GeyserConfiguration config = connector.getConfig();
|
||||||
pong.setEdition("MCPE");
|
PingEvent pongEvent = new PingEvent(inetSocketAddress);
|
||||||
pong.setGameType("Default");
|
pongEvent.setEdition("MCPE");
|
||||||
pong.setNintendoLimited(false);
|
pongEvent.setGameType("Default");
|
||||||
pong.setProtocolVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion());
|
pongEvent.setNintendoLimited(false);
|
||||||
pong.setVersion("1.12.0");
|
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()) {
|
if (connector.getConfig().isPingPassthrough()) {
|
||||||
ServerStatusInfo serverInfo = connector.getPassthroughThread().getInfo();
|
ServerStatusInfo serverInfo = connector.getPassthroughThread().getInfo();
|
||||||
|
|
||||||
if (serverInfo != null) {
|
if (serverInfo != null) {
|
||||||
pong.setMotd(MessageUtils.getBedrockMessage(serverInfo.getDescription()));
|
pongEvent.setMotd(MessageUtils.getBedrockMessage(serverInfo.getDescription()));
|
||||||
pong.setSubMotd(config.getBedrock().getMotd2());
|
pongEvent.setSubMotd(config.getBedrock().getMotd2());
|
||||||
pong.setPlayerCount(serverInfo.getPlayerInfo().getOnlinePlayers());
|
pongEvent.setPlayerCount(serverInfo.getPlayerInfo().getOnlinePlayers());
|
||||||
pong.setMaximumPlayerCount(serverInfo.getPlayerInfo().getMaxPlayers());
|
pongEvent.setMaximumPlayerCount(serverInfo.getPlayerInfo().getMaxPlayers());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pong.setPlayerCount(1);
|
pongEvent.setPlayerCount(1);
|
||||||
pong.setMaximumPlayerCount(config.getMaxPlayers());
|
pongEvent.setMaximumPlayerCount(config.getMaxPlayers());
|
||||||
pong.setMotd(config.getBedrock().getMotd1());
|
pongEvent.setMotd(config.getBedrock().getMotd1());
|
||||||
pong.setSubMotd(config.getBedrock().getMotd2());
|
pongEvent.setSubMotd(config.getBedrock().getMotd2());
|
||||||
}
|
}
|
||||||
|
|
||||||
BedrockPong c = new BedrockPong();
|
BedrockPong pong = new BedrockPong();
|
||||||
|
pong.setEdition(pongEvent.getEdition());
|
||||||
c.setEdition(pong.getEdition());
|
pong.setGameType(pongEvent.getGameType());
|
||||||
c.setGameType(pong.getGameType());
|
pong.setNintendoLimited(pongEvent.isNintendoLimited());
|
||||||
c.setNintendoLimited(pong.isNintendoLimited());
|
pong.setProtocolVersion(pongEvent.getProtocolVersion());
|
||||||
c.setProtocolVersion(pong.getProtocolVersion());
|
pong.setVersion(pongEvent.getVersion());
|
||||||
c.setVersion(pong.getVersion());
|
pong.setMotd(pongEvent.getMotd());
|
||||||
|
pong.setSubMotd(pongEvent.getSubMotd());
|
||||||
c.setMotd(pong.getMotd());
|
pong.setPlayerCount(pongEvent.getPlayerCount());
|
||||||
c.setSubMotd(pong.getSubMotd());
|
pong.setMaximumPlayerCount(pongEvent.getMaximumPlayerCount());
|
||||||
c.setPlayerCount(pong.getPlayerCount());
|
pong.setIpv4Port(config.getBedrock().getPort());
|
||||||
c.setMaximumPlayerCount(pong.getMaximumPlayerCount());
|
|
||||||
c.setIpv4Port(config.getBedrock().getPort());
|
|
||||||
|
|
||||||
return c;
|
|
||||||
|
|
||||||
|
return pong;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -716,4 +716,49 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
|
|||||||
public boolean handle(VideoStreamConnectPacket packet) {
|
public boolean handle(VideoStreamConnectPacket packet) {
|
||||||
return defaultHandler(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
|
@Override
|
||||||
public boolean handle(LoginPacket loginPacket) {
|
public boolean handle(LoginPacket loginPacket) {
|
||||||
// TODO: Implement support for multiple protocols
|
|
||||||
if (loginPacket.getProtocolVersion() != GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion()) {
|
if (loginPacket.getProtocolVersion() != GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion()) {
|
||||||
connector.getLogger().debug("unsupported");
|
connector.getLogger().debug("unsupported");
|
||||||
session.getUpstream().disconnect("Unsupported Bedrock version. Are you running an outdated version?");
|
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();
|
PlayStatusPacket playStatus = new PlayStatusPacket();
|
||||||
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
|
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
|
||||||
session.getUpstream().sendPacketImmediately(playStatus);
|
session.getUpstream().sendPacket(playStatus);
|
||||||
|
|
||||||
ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket();
|
ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket();
|
||||||
session.getUpstream().sendPacketImmediately(resourcePacksInfo);
|
session.getUpstream().sendPacket(resourcePacksInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ResourcePackClientResponsePacket textPacket) {
|
public boolean handle(ResourcePackClientResponsePacket packet) {
|
||||||
switch (textPacket.getStatus()) {
|
switch (packet.getStatus()) {
|
||||||
case COMPLETED:
|
case COMPLETED:
|
||||||
session.connect(connector.getRemoteServer());
|
session.connect(connector.getRemoteServer());
|
||||||
connector.getLogger().info("Player connected with username " + session.getAuthenticationData().getName());
|
connector.getLogger().info("Player connected with username " + session.getAuthenticationData().getName());
|
||||||
@ -74,7 +73,8 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||||||
ResourcePackStackPacket stack = new ResourcePackStackPacket();
|
ResourcePackStackPacket stack = new ResourcePackStackPacket();
|
||||||
stack.setExperimental(false);
|
stack.setExperimental(false);
|
||||||
stack.setForcedToAccept(false);
|
stack.setForcedToAccept(false);
|
||||||
session.getUpstream().sendPacketImmediately(stack);
|
stack.setGameVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
||||||
|
session.getUpstream().sendPacket(stack);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
session.getUpstream().disconnect("disconnectionScreen.resourcePack");
|
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.Vector2i;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
|
import com.nukkitx.nbt.tag.CompoundTag;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||||
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
||||||
import com.nukkitx.protocol.bedrock.data.GameRule;
|
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.InventoryContentPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
|
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
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.inventory.PlayerInventory;
|
||||||
import org.geysermc.connector.network.session.cache.*;
|
import org.geysermc.connector.network.session.cache.*;
|
||||||
import org.geysermc.connector.network.translators.Registry;
|
import org.geysermc.connector.network.translators.Registry;
|
||||||
|
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||||
import org.geysermc.connector.utils.Toolbox;
|
import org.geysermc.connector.utils.Toolbox;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
@ -129,14 +135,49 @@ public class GeyserSession implements Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void connect(RemoteServer remoteServer) {
|
public void connect(RemoteServer remoteServer) {
|
||||||
// This has to be sent first so the player actually joins
|
|
||||||
startGame();
|
startGame();
|
||||||
|
|
||||||
this.remoteServer = remoteServer;
|
this.remoteServer = remoteServer;
|
||||||
if (!(connector.getConfig().getRemote().getAuthType().hashCode() == "online".hashCode())) {
|
if (!(connector.getConfig().getRemote().getAuthType().hashCode() == "online".hashCode())) {
|
||||||
connector.getLogger().info("Attempting to login using offline mode... authentication is disabled.");
|
connector.getLogger().info("Attempting to login using offline mode... authentication is disabled.");
|
||||||
authenticate(authenticationData.getName());
|
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) {
|
public void authenticate(String username) {
|
||||||
@ -268,15 +309,15 @@ public class GeyserSession implements Player {
|
|||||||
startGamePacket.setPlayerPosition(Vector3f.from(0, 69, 0));
|
startGamePacket.setPlayerPosition(Vector3f.from(0, 69, 0));
|
||||||
startGamePacket.setRotation(Vector2f.from(1, 1));
|
startGamePacket.setRotation(Vector2f.from(1, 1));
|
||||||
|
|
||||||
startGamePacket.setSeed(0);
|
startGamePacket.setSeed(-1);
|
||||||
startGamePacket.setDimensionId(playerEntity.getDimension());
|
startGamePacket.setDimensionId(playerEntity.getDimension());
|
||||||
startGamePacket.setGeneratorId(1);
|
startGamePacket.setGeneratorId(1);
|
||||||
startGamePacket.setLevelGamemode(0);
|
startGamePacket.setLevelGamemode(0);
|
||||||
startGamePacket.setDifficulty(1);
|
startGamePacket.setDifficulty(1);
|
||||||
startGamePacket.setDefaultSpawn(Vector3i.ZERO);
|
startGamePacket.setDefaultSpawn(Vector3i.ZERO);
|
||||||
startGamePacket.setAcheivementsDisabled(true);
|
startGamePacket.setAcheivementsDisabled(true);
|
||||||
startGamePacket.setTime(0);
|
startGamePacket.setTime(-1);
|
||||||
startGamePacket.setEduLevel(false);
|
startGamePacket.setEduEditionOffers(0);
|
||||||
startGamePacket.setEduFeaturesEnabled(false);
|
startGamePacket.setEduFeaturesEnabled(false);
|
||||||
startGamePacket.setRainLevel(0);
|
startGamePacket.setRainLevel(0);
|
||||||
startGamePacket.setLightningLevel(0);
|
startGamePacket.setLightningLevel(0);
|
||||||
@ -302,20 +343,13 @@ public class GeyserSession implements Player {
|
|||||||
startGamePacket.setLevelId("world");
|
startGamePacket.setLevelId("world");
|
||||||
startGamePacket.setWorldName("world");
|
startGamePacket.setWorldName("world");
|
||||||
startGamePacket.setPremiumWorldTemplateId("00000000-0000-0000-0000-000000000000");
|
startGamePacket.setPremiumWorldTemplateId("00000000-0000-0000-0000-000000000000");
|
||||||
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.BLOCKS);
|
||||||
startGamePacket.setItemEntries(Toolbox.ITEMS);
|
startGamePacket.setItemEntries(Toolbox.ITEMS);
|
||||||
|
startGamePacket.setVanillaVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
||||||
|
// startGamePacket.setMovementServerAuthoritative(true);
|
||||||
upstream.sendPacket(startGamePacket);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class UpstreamSession {
|
|||||||
public void sendPacket(@NonNull BedrockPacket packet) {
|
public void sendPacket(@NonNull BedrockPacket packet) {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
session.sendPacket(packet);
|
session.sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,17 @@
|
|||||||
package org.geysermc.connector.network.translators.java;
|
package org.geysermc.connector.network.translators.java;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
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.entity.PlayerEntity;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
|
import org.geysermc.connector.world.chunk.ChunkPosition;
|
||||||
|
|
||||||
public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacket> {
|
public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacket> {
|
||||||
|
|
||||||
@ -38,16 +45,14 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
|||||||
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
|
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
|
||||||
bedrockPacket.setUniqueEntityId(session.getPlayerEntity().getGeyserId());
|
bedrockPacket.setUniqueEntityId(session.getPlayerEntity().getGeyserId());
|
||||||
bedrockPacket.setPlayerPermission(1);
|
bedrockPacket.setPlayerPermission(1);
|
||||||
session.getUpstream().sendPacketImmediately(bedrockPacket);
|
session.getUpstream().sendPacket(bedrockPacket);
|
||||||
|
|
||||||
PlayStatusPacket playStatus = new PlayStatusPacket();
|
PlayStatusPacket playStatus = new PlayStatusPacket();
|
||||||
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
|
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
|
||||||
session.getUpstream().sendPacketImmediately(playStatus);
|
// session.getUpstream().sendPacket(playStatus);
|
||||||
|
|
||||||
PlayerEntity entity = session.getPlayerEntity();
|
PlayerEntity entity = session.getPlayerEntity();
|
||||||
if (entity == null) return;
|
entity.setEntityId(packet.getEntityId());
|
||||||
|
|
||||||
session.getPlayerEntity().setEntityId(packet.getEntityId());
|
|
||||||
|
|
||||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||||
playerGameTypePacket.setGamemode(packet.getGameMode().ordinal());
|
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
|
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)
|
if (session.getRenderDistance() > 32) session.setRenderDistance(32); // <3 u ViaVersion but I don't like crashing clients x)
|
||||||
|
|
||||||
ChunkRadiusUpdatedPacket packet1 = new ChunkRadiusUpdatedPacket();
|
ChunkRadiusUpdatedPacket chunkRadiusPacket = new ChunkRadiusUpdatedPacket();
|
||||||
packet1.setRadius(session.getRenderDistance());
|
chunkRadiusPacket.setRadius(session.getRenderDistance());
|
||||||
session.getUpstream().sendPacket(packet1);
|
session.getUpstream().sendPacket(chunkRadiusPacket);
|
||||||
|
|
||||||
session.setSpawned(true);
|
session.setSpawned(true);
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,11 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
|||||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||||
session.setGameMode(packet.getGamemode());
|
session.setGameMode(packet.getGamemode());
|
||||||
|
|
||||||
|
/*
|
||||||
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
||||||
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||||
session.getUpstream().sendPacket(playStatusPacket);
|
session.getUpstream().sendPacket(playStatusPacket);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDimension(int javaDimension) {
|
private int getDimension(int javaDimension) {
|
||||||
|
@ -61,8 +61,10 @@ 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));
|
||||||
session.getUpstream().sendPacket(new RespawnPacket());
|
respawnPacket.setSpawnState(0); // state searching for spawn
|
||||||
|
session.getUpstream().sendPacket(respawnPacket);
|
||||||
|
|
||||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||||
session.getDownstream().getSession().send(javaRespawnPacket);
|
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.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;
|
||||||
@ -25,7 +27,7 @@ public class SkinUtils {
|
|||||||
profile.getIdAsString(),
|
profile.getIdAsString(),
|
||||||
SkinProvider.getCachedSkin(profile.getId()).getSkinData(),
|
SkinProvider.getCachedSkin(profile.getId()).getSkinData(),
|
||||||
SkinProvider.getCachedCape(data.getCapeUrl()).getCapeData(),
|
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(),
|
profile.getIdAsString(),
|
||||||
SkinProvider.STEVE_SKIN,
|
SkinProvider.STEVE_SKIN,
|
||||||
SkinProvider.EMPTY_CAPE.getCapeData(),
|
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,
|
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(64, 64, skinData), ImageData.of(64, 32, 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("");
|
||||||
|
entry.setTeacher(false);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ public class SkinUtils {
|
|||||||
entity.getUuid().toString(),
|
entity.getUuid().toString(),
|
||||||
skin.getSkinData(),
|
skin.getSkinData(),
|
||||||
cape.getCapeData(),
|
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.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.nukkitx.nbt.NbtUtils;
|
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.data.ItemData;
|
||||||
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;
|
||||||
@ -21,40 +22,41 @@ import java.util.*;
|
|||||||
|
|
||||||
public class Toolbox {
|
public class Toolbox {
|
||||||
|
|
||||||
public static final Collection<StartGamePacket.ItemEntry> ITEMS;
|
public static final Collection<StartGamePacket.ItemEntry> ITEMS = new ArrayList<>();
|
||||||
public static final ByteBuf CACHED_PALLETE;
|
public static ListTag<CompoundTag> BLOCKS;
|
||||||
public static final ItemData[] CREATIVE_ITEMS;
|
public static ItemData[] CREATIVE_ITEMS;
|
||||||
|
|
||||||
public static final TIntObjectMap<ItemEntry> ITEM_ENTRIES;
|
public static final TIntObjectMap<ItemEntry> ITEM_ENTRIES = new TIntObjectHashMap<>();
|
||||||
public static final TIntObjectMap<BlockEntry> BLOCK_ENTRIES;
|
public static final TIntObjectMap<BlockEntry> BLOCK_ENTRIES = new TIntObjectHashMap<>();
|
||||||
|
|
||||||
static {
|
public static void init() {
|
||||||
InputStream stream = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/cached_palette.json");
|
InputStream stream = GeyserConnector.class.getClassLoader().getResourceAsStream("bedrock/runtime_block_states.dat");
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
if (stream == null) {
|
||||||
List<LinkedHashMap<String, Object>> entries = new ArrayList<>();
|
throw new AssertionError("Unable to find bedrock/runtime_block_states.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<>();
|
||||||
|
ListTag<CompoundTag> blocksTag;
|
||||||
|
|
||||||
for (Map<String, Object> entry : entries) {
|
NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream);
|
||||||
blockIdToIdentifier.put((String) entry.get("name"), (int) entry.get("id"));
|
try {
|
||||||
|
blocksTag = (ListTag<CompoundTag>) nbtInputStream.readTag();
|
||||||
GlobalBlockPalette.registerMapping((int) entry.get("id") << 4 | (int) entry.get("data"));
|
nbtInputStream.close();
|
||||||
BedrockUtils.writeString(cachedPalette, (String) entry.get("name"));
|
} catch (Exception ex) {
|
||||||
cachedPalette.writeShortLE((int) entry.get("data"));
|
GeyserLogger.DEFAULT.warning("Failed to get blocks from runtime block states, please report this error!");
|
||||||
cachedPalette.writeShortLE((int) entry.get("id"));
|
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");
|
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");
|
||||||
@ -68,13 +70,10 @@ public class Toolbox {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StartGamePacket.ItemEntry> startGameEntries = new ArrayList<>();
|
|
||||||
for (Map entry : startGameItems) {
|
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");
|
InputStream itemStream = Toolbox.class.getClassLoader().getResourceAsStream("items.json");
|
||||||
ObjectMapper itemMapper = new ObjectMapper();
|
ObjectMapper itemMapper = new ObjectMapper();
|
||||||
Map<String, Map<String, Object>> items = new HashMap<>();
|
Map<String, Map<String, Object>> items = new HashMap<>();
|
||||||
@ -85,16 +84,12 @@ public class Toolbox {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
TIntObjectMap<ItemEntry> itemEntries = new TIntObjectHashMap<>();
|
|
||||||
int itemIndex = 0;
|
int itemIndex = 0;
|
||||||
|
|
||||||
for (Map.Entry<String, Map<String, Object>> itemEntry : items.entrySet()) {
|
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++;
|
itemIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITEM_ENTRIES = itemEntries;
|
|
||||||
|
|
||||||
InputStream blockStream = Toolbox.class.getClassLoader().getResourceAsStream("blocks.json");
|
InputStream blockStream = Toolbox.class.getClassLoader().getResourceAsStream("blocks.json");
|
||||||
ObjectMapper blockMapper = new ObjectMapper();
|
ObjectMapper blockMapper = new ObjectMapper();
|
||||||
Map<String, Map<String, Object>> blocks = new HashMap<>();
|
Map<String, Map<String, Object>> blocks = new HashMap<>();
|
||||||
@ -105,22 +100,18 @@ public class Toolbox {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
TIntObjectMap<BlockEntry> blockEntries = new TIntObjectHashMap<>();
|
|
||||||
int blockIndex = 0;
|
int blockIndex = 0;
|
||||||
|
|
||||||
for (Map.Entry<String, Map<String, Object>> itemEntry : blocks.entrySet()) {
|
for (Map.Entry<String, Map<String, Object>> itemEntry : blocks.entrySet()) {
|
||||||
if (!blockIdToIdentifier.containsKey(itemEntry.getValue().get("bedrock_identifier"))) {
|
if (!blockIdToIdentifier.containsKey(itemEntry.getValue().get("bedrock_identifier"))) {
|
||||||
GeyserLogger.DEFAULT.debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " does not exist on bedrock edition!");
|
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 {
|
} 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++;
|
blockIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLOCK_ENTRIES = blockEntries;
|
|
||||||
|
|
||||||
InputStream creativeItemStream = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/creative_items.json");
|
InputStream creativeItemStream = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/creative_items.json");
|
||||||
ObjectMapper creativeItemMapper = new ObjectMapper();
|
ObjectMapper creativeItemMapper = new ObjectMapper();
|
||||||
List<LinkedHashMap<String, Object>> creativeItemEntries = new ArrayList<>();
|
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>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources/</directory>
|
<directory>src/main/resources/</directory>
|
||||||
<filtering>true</filtering>
|
<filtering>false</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren