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

Get chunks working to some degree.

Dieser Commit ist enthalten in:
SupremeMortal 2019-09-13 11:49:18 +01:00
Ursprung ed7213d7c7
Commit 9a9f67b45f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: DDBB25F8EE4FA29A
3 geänderte Dateien mit 28 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -29,6 +29,8 @@ import com.flowpowered.math.vector.Vector3f;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPropertiesPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPropertiesPacket;
import com.nukkitx.protocol.bedrock.data.EntityData; import com.nukkitx.protocol.bedrock.data.EntityData;
import com.nukkitx.protocol.bedrock.data.EntityDataDictionary; import com.nukkitx.protocol.bedrock.data.EntityDataDictionary;
import com.nukkitx.protocol.bedrock.data.EntityFlag;
import com.nukkitx.protocol.bedrock.data.EntityFlags;
import com.nukkitx.protocol.bedrock.packet.AddEntityPacket; import com.nukkitx.protocol.bedrock.packet.AddEntityPacket;
import com.nukkitx.protocol.bedrock.packet.RemoveEntityPacket; import com.nukkitx.protocol.bedrock.packet.RemoveEntityPacket;
import com.nukkitx.protocol.bedrock.packet.UpdateAttributesPacket; import com.nukkitx.protocol.bedrock.packet.UpdateAttributesPacket;
@ -41,12 +43,7 @@ import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.utils.AttributeUtils; import org.geysermc.connector.utils.AttributeUtils;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Getter @Getter
@Setter @Setter
@ -139,6 +136,9 @@ public class Entity {
public EntityDataDictionary getMetadata() { public EntityDataDictionary getMetadata() {
EntityFlags flags = new EntityFlags();
flags.setFlag(EntityFlag.HAS_GRAVITY, true);
EntityDataDictionary dictionary = new EntityDataDictionary(); EntityDataDictionary dictionary = new EntityDataDictionary();
dictionary.put(EntityData.NAMETAG, ""); dictionary.put(EntityData.NAMETAG, "");
dictionary.put(EntityData.ENTITY_AGE, 0); dictionary.put(EntityData.ENTITY_AGE, 0);
@ -147,6 +147,7 @@ public class Entity {
dictionary.put(EntityData.AIR, (short) 0); dictionary.put(EntityData.AIR, (short) 0);
dictionary.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight()); dictionary.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight());
dictionary.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth()); dictionary.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth());
dictionary.putFlags(flags);
return dictionary; return dictionary;
} }

Datei anzeigen

@ -26,6 +26,7 @@
package org.geysermc.connector.network.session; package org.geysermc.connector.network.session;
import com.flowpowered.math.vector.Vector2f; import com.flowpowered.math.vector.Vector2f;
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3f; import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector3i; import com.flowpowered.math.vector.Vector3i;
import com.github.steveice10.mc.auth.exception.request.RequestException; import com.github.steveice10.mc.auth.exception.request.RequestException;
@ -47,7 +48,6 @@ 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 lombok.Setter; import lombok.Setter;
import org.geysermc.api.Geyser;
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;
@ -56,11 +56,7 @@ import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.entity.PlayerEntity; import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.inventory.PlayerInventory; import org.geysermc.connector.inventory.PlayerInventory;
import org.geysermc.connector.network.session.cache.DataCache; import org.geysermc.connector.network.session.cache.*;
import org.geysermc.connector.network.session.cache.EntityCache;
import org.geysermc.connector.network.session.cache.InventoryCache;
import org.geysermc.connector.network.session.cache.ScoreboardCache;
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;
@ -87,6 +83,9 @@ public class GeyserSession implements PlayerSession, Player {
private DataCache<Packet> javaPacketCache; private DataCache<Packet> javaPacketCache;
@Setter
private Vector2i lastChunkPosition = null;
private boolean loggedIn; private boolean loggedIn;
@Setter @Setter

Datei anzeigen

@ -1,8 +1,11 @@
package org.geysermc.connector.network.translators.java.world; package org.geysermc.connector.network.translators.java.world;
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3f;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket;
import com.nukkitx.network.VarInts; import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import org.geysermc.api.Geyser; import org.geysermc.api.Geyser;
@ -18,6 +21,19 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
public void translate(ServerChunkDataPacket packet, GeyserSession session) { public void translate(ServerChunkDataPacket packet, GeyserSession session) {
// Not sure if this is safe or not, however without this the client usually times out // Not sure if this is safe or not, however without this the client usually times out
Geyser.getConnector().getGeneralThreadPool().execute(() -> { Geyser.getConnector().getGeneralThreadPool().execute(() -> {
Vector2i chunkPos = session.getLastChunkPosition();
Vector3f position = session.getPlayerEntity().getPosition();
Vector2i newChunkPos = Vector2i.from(position.getFloorX() >> 4, position.getFloorZ() >> 4);
if (chunkPos == null || !chunkPos.equals(newChunkPos)) {
NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket();
chunkPublisherUpdatePacket.setPosition(position.toInt());
chunkPublisherUpdatePacket.setRadius(8 << 4);
session.getUpstream().sendPacket(chunkPublisherUpdatePacket);
session.setLastChunkPosition(newChunkPos);
}
try { try {
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(packet.getColumn()); ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(packet.getColumn());
ByteBuf byteBuf = Unpooled.buffer(32); ByteBuf byteBuf = Unpooled.buffer(32);