mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-11-23 07:16:39 +01:00
Get chunks working to some degree.
This commit is contained in:
parent
ed7213d7c7
commit
9a9f67b45f
3 changed files with 28 additions and 12 deletions
|
@ -29,6 +29,8 @@ import com.flowpowered.math.vector.Vector3f;
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPropertiesPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.EntityData;
|
||||
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.RemoveEntityPacket;
|
||||
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.utils.AttributeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -139,6 +136,9 @@ public class Entity {
|
|||
|
||||
|
||||
public EntityDataDictionary getMetadata() {
|
||||
EntityFlags flags = new EntityFlags();
|
||||
flags.setFlag(EntityFlag.HAS_GRAVITY, true);
|
||||
|
||||
EntityDataDictionary dictionary = new EntityDataDictionary();
|
||||
dictionary.put(EntityData.NAMETAG, "");
|
||||
dictionary.put(EntityData.ENTITY_AGE, 0);
|
||||
|
@ -147,6 +147,7 @@ public class Entity {
|
|||
dictionary.put(EntityData.AIR, (short) 0);
|
||||
dictionary.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight());
|
||||
dictionary.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth());
|
||||
dictionary.putFlags(flags);
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package org.geysermc.connector.network.session;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2f;
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3f;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
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 lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.api.Geyser;
|
||||
import org.geysermc.api.Player;
|
||||
import org.geysermc.api.RemoteServer;
|
||||
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.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.ScoreboardCache;
|
||||
import org.geysermc.connector.network.session.cache.WindowCache;
|
||||
import org.geysermc.connector.network.session.cache.*;
|
||||
import org.geysermc.connector.network.translators.Registry;
|
||||
import org.geysermc.connector.utils.Toolbox;
|
||||
|
||||
|
@ -87,6 +83,9 @@ public class GeyserSession implements PlayerSession, Player {
|
|||
|
||||
private DataCache<Packet> javaPacketCache;
|
||||
|
||||
@Setter
|
||||
private Vector2i lastChunkPosition = null;
|
||||
|
||||
private boolean loggedIn;
|
||||
|
||||
@Setter
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
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.nukkitx.network.VarInts;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.geysermc.api.Geyser;
|
||||
|
@ -18,6 +21,19 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
|||
public void translate(ServerChunkDataPacket packet, GeyserSession session) {
|
||||
// Not sure if this is safe or not, however without this the client usually times out
|
||||
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 {
|
||||
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(packet.getColumn());
|
||||
ByteBuf byteBuf = Unpooled.buffer(32);
|
||||
|
|
Loading…
Reference in a new issue