Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
new remapper (:
Dieser Commit ist enthalten in:
Ursprung
5318a664b8
Commit
7fccb0d69d
@ -35,6 +35,7 @@ import com.github.steveice10.packetlib.event.session.ConnectedEvent;
|
|||||||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||||
import com.github.steveice10.packetlib.event.session.PacketReceivedEvent;
|
import com.github.steveice10.packetlib.event.session.PacketReceivedEvent;
|
||||||
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
||||||
|
import com.github.steveice10.packetlib.packet.Packet;
|
||||||
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||||
import com.nukkitx.network.util.DisconnectReason;
|
import com.nukkitx.network.util.DisconnectReason;
|
||||||
import com.nukkitx.protocol.PlayerSession;
|
import com.nukkitx.protocol.PlayerSession;
|
||||||
@ -45,58 +46,71 @@ import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
|
|||||||
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.Geyser;
|
import lombok.Setter;
|
||||||
import org.geysermc.api.Player;
|
import org.geysermc.api.Player;
|
||||||
import org.geysermc.api.RemoteServer;
|
import org.geysermc.api.RemoteServer;
|
||||||
import org.geysermc.api.session.AuthData;
|
import org.geysermc.api.session.AuthData;
|
||||||
import org.geysermc.api.window.FormWindow;
|
import org.geysermc.api.window.FormWindow;
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
|
import org.geysermc.connector.entity.PlayerEntity;
|
||||||
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
|
import org.geysermc.connector.inventory.PlayerInventory;
|
||||||
|
import org.geysermc.connector.network.session.cache.DataCache;
|
||||||
|
import org.geysermc.connector.network.session.cache.EntityCache;
|
||||||
import org.geysermc.connector.network.session.cache.InventoryCache;
|
import org.geysermc.connector.network.session.cache.InventoryCache;
|
||||||
import org.geysermc.connector.network.session.cache.ScoreboardCache;
|
import org.geysermc.connector.network.session.cache.ScoreboardCache;
|
||||||
import org.geysermc.connector.network.session.cache.WindowCache;
|
import org.geysermc.connector.network.session.cache.WindowCache;
|
||||||
import org.geysermc.connector.network.translators.Registry;
|
import org.geysermc.connector.network.translators.Registry;
|
||||||
import org.geysermc.connector.utils.Toolbox;
|
import org.geysermc.connector.utils.Toolbox;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class GeyserSession implements PlayerSession, Player {
|
public class GeyserSession implements PlayerSession, Player {
|
||||||
|
|
||||||
private GeyserConnector connector;
|
private GeyserConnector connector;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private RemoteServer remoteServer;
|
private RemoteServer remoteServer;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private BedrockServerSession upstream;
|
private BedrockServerSession upstream;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private Client downstream;
|
private Client downstream;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private AuthData authenticationData;
|
private AuthData authenticationData;
|
||||||
|
|
||||||
@Getter
|
private PlayerEntity playerEntity;
|
||||||
|
private PlayerInventory inventory;
|
||||||
|
|
||||||
|
private EntityCache entityCache;
|
||||||
private InventoryCache inventoryCache;
|
private InventoryCache inventoryCache;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private WindowCache windowCache;
|
private WindowCache windowCache;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private ScoreboardCache scoreboardCache;
|
private ScoreboardCache scoreboardCache;
|
||||||
|
|
||||||
@Getter
|
private DataCache<Packet> javaPacketCache;
|
||||||
|
|
||||||
private boolean loggedIn;
|
private boolean loggedIn;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private boolean spawned;
|
||||||
|
|
||||||
private boolean closed;
|
private boolean closed;
|
||||||
|
|
||||||
public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServerSession) {
|
public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServerSession) {
|
||||||
this.connector = connector;
|
this.connector = connector;
|
||||||
this.upstream = bedrockServerSession;
|
this.upstream = bedrockServerSession;
|
||||||
|
|
||||||
|
this.entityCache = new EntityCache(this);
|
||||||
this.inventoryCache = new InventoryCache(this);
|
this.inventoryCache = new InventoryCache(this);
|
||||||
this.windowCache = new WindowCache(this);
|
this.windowCache = new WindowCache(this);
|
||||||
|
|
||||||
this.scoreboardCache = new ScoreboardCache(this);
|
this.scoreboardCache = new ScoreboardCache(this);
|
||||||
|
|
||||||
|
this.playerEntity = new PlayerEntity(UUID.randomUUID(), 1, 1, EntityType.PLAYER, new Vector3f(0, 0, 0), new Vector3f(0, 0, 0), new Vector3f(0, 0, 0));
|
||||||
|
this.inventory = new PlayerInventory();
|
||||||
|
|
||||||
|
this.javaPacketCache = new DataCache<Packet>();
|
||||||
|
|
||||||
|
this.spawned = false;
|
||||||
this.loggedIn = false;
|
this.loggedIn = false;
|
||||||
|
|
||||||
|
this.inventoryCache.getInventories().put(0, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(RemoteServer remoteServer) {
|
public void connect(RemoteServer remoteServer) {
|
||||||
@ -107,7 +121,6 @@ public class GeyserSession implements PlayerSession, Player {
|
|||||||
if (!connector.getConfig().getRemote().isOnlineMode()) {
|
if (!connector.getConfig().getRemote().isOnlineMode()) {
|
||||||
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());
|
||||||
Geyser.addPlayer(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,18 +149,20 @@ public class GeyserSession implements PlayerSession, Player {
|
|||||||
public void connected(ConnectedEvent event) {
|
public void connected(ConnectedEvent event) {
|
||||||
loggedIn = true;
|
loggedIn = true;
|
||||||
connector.getLogger().info(authenticationData.getName() + " (logged in as: " + protocol.getProfile().getName() + ")" + " has connected to remote java server on address " + remoteServer.getAddress());
|
connector.getLogger().info(authenticationData.getName() + " (logged in as: " + protocol.getProfile().getName() + ")" + " has connected to remote java server on address " + remoteServer.getAddress());
|
||||||
|
playerEntity.setUuid(protocol.getProfile().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(DisconnectedEvent event) {
|
public void disconnected(DisconnectedEvent event) {
|
||||||
loggedIn = false;
|
loggedIn = false;
|
||||||
connector.getLogger().info(authenticationData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason());
|
connector.getLogger().info(authenticationData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason());
|
||||||
upstream.disconnect(event.getReason());
|
disconnect(event.getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void packetReceived(PacketReceivedEvent event) {
|
public void packetReceived(PacketReceivedEvent event) {
|
||||||
Registry.JAVA.translate(event.getPacket().getClass(), event.getPacket(), GeyserSession.this);
|
if (!closed)
|
||||||
|
Registry.JAVA.translate(event.getPacket().getClass(), event.getPacket(), GeyserSession.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -167,6 +182,8 @@ public class GeyserSession implements PlayerSession, Player {
|
|||||||
upstream.disconnect(reason);
|
upstream.disconnect(reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -228,15 +245,15 @@ public class GeyserSession implements PlayerSession, Player {
|
|||||||
|
|
||||||
private void startGame() {
|
private void startGame() {
|
||||||
StartGamePacket startGamePacket = new StartGamePacket();
|
StartGamePacket startGamePacket = new StartGamePacket();
|
||||||
startGamePacket.setUniqueEntityId(1); // TODO: Cache this value
|
startGamePacket.setUniqueEntityId(playerEntity.getGeyserId());
|
||||||
startGamePacket.setRuntimeEntityId(1); // TODO: Cache this value
|
startGamePacket.setRuntimeEntityId(playerEntity.getGeyserId());
|
||||||
startGamePacket.setPlayerGamemode(0);
|
startGamePacket.setPlayerGamemode(0);
|
||||||
startGamePacket.setPlayerPosition(new Vector3f(0, 0, 0));
|
startGamePacket.setPlayerPosition(new Vector3f(0, 69, 0));
|
||||||
startGamePacket.setRotation(new Vector2f(1, 1));
|
startGamePacket.setRotation(new Vector2f(1, 1));
|
||||||
|
|
||||||
startGamePacket.setSeed(1111);
|
startGamePacket.setSeed(0);
|
||||||
startGamePacket.setDimensionId(0);
|
startGamePacket.setDimensionId(playerEntity.getDimension());
|
||||||
startGamePacket.setGeneratorId(0);
|
startGamePacket.setGeneratorId(1);
|
||||||
startGamePacket.setLevelGamemode(0);
|
startGamePacket.setLevelGamemode(0);
|
||||||
startGamePacket.setDifficulty(1);
|
startGamePacket.setDifficulty(1);
|
||||||
startGamePacket.setDefaultSpawn(new Vector3i(0, 0, 0));
|
startGamePacket.setDefaultSpawn(new Vector3i(0, 0, 0));
|
||||||
@ -265,7 +282,7 @@ public class GeyserSession implements PlayerSession, Player {
|
|||||||
startGamePacket.setFromWorldTemplate(false);
|
startGamePacket.setFromWorldTemplate(false);
|
||||||
startGamePacket.setWorldTemplateOptionLocked(false);
|
startGamePacket.setWorldTemplateOptionLocked(false);
|
||||||
|
|
||||||
startGamePacket.setLevelId("oerjhii");
|
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);
|
||||||
|
@ -54,7 +54,7 @@ class RemapUtils {
|
|||||||
//TODO: add stone support
|
//TODO: add stone support
|
||||||
/*Remapper.predicates.put((x) -> x.getF().contains("oak"), (x, y) -> {
|
/*Remapper.predicates.put((x) -> x.getF().contains("oak"), (x, y) -> {
|
||||||
//System.out.println(x.getIdentifier());
|
//System.out.println(x.getIdentifier());
|
||||||
//if(customWoodIfNeeded(y)) return;
|
//if(customStoneIfNeeded(y)) return;
|
||||||
|
|
||||||
if (y.getIdentifier().replaceAll("oak_", "")
|
if (y.getIdentifier().replaceAll("oak_", "")
|
||||||
.equalsIgnoreCase(x.getIdentifier()) && x.getData() == 0) {
|
.equalsIgnoreCase(x.getIdentifier()) && x.getData() == 0) {
|
||||||
@ -87,4 +87,8 @@ class RemapUtils {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean customStoneIfNeeded(JavaItem j) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren