Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Merge branch 'master' into feature/new-protocol-lib
Dieser Commit ist enthalten in:
Commit
e6d166d4d4
@ -154,6 +154,8 @@ public class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateBedrockAttributes(GeyserSession session) {
|
public void updateBedrockAttributes(GeyserSession session) {
|
||||||
|
if (!valid) return;
|
||||||
|
|
||||||
List<com.nukkitx.protocol.bedrock.data.Attribute> attributes = new ArrayList<>();
|
List<com.nukkitx.protocol.bedrock.data.Attribute> attributes = new ArrayList<>();
|
||||||
for (Map.Entry<AttributeType, Attribute> entry : this.attributes.entrySet()) {
|
for (Map.Entry<AttributeType, Attribute> entry : this.attributes.entrySet()) {
|
||||||
if (!entry.getValue().getType().isBedrockAttribute())
|
if (!entry.getValue().getType().isBedrockAttribute())
|
||||||
@ -191,6 +193,7 @@ public class Entity {
|
|||||||
metadata.put(EntityData.NAMETAG, MessageUtils.getBedrockMessage(name));
|
metadata.put(EntityData.NAMETAG, MessageUtils.getBedrockMessage(name));
|
||||||
break;
|
break;
|
||||||
case 3: // is custom name visible
|
case 3: // is custom name visible
|
||||||
|
if (!this.is(PlayerEntity.class))
|
||||||
metadata.put(EntityData.ALWAYS_SHOW_NAMETAG, (byte) ((boolean) entityMetadata.getValue() ? 1 : 0));
|
metadata.put(EntityData.ALWAYS_SHOW_NAMETAG, (byte) ((boolean) entityMetadata.getValue() ? 1 : 0));
|
||||||
break;
|
break;
|
||||||
case 4: // silent
|
case 4: // silent
|
||||||
@ -201,6 +204,12 @@ public class Entity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateBedrockMetadata(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateBedrockMetadata(GeyserSession session) {
|
||||||
|
if (!valid) return;
|
||||||
|
|
||||||
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
||||||
entityDataPacket.setRuntimeEntityId(geyserId);
|
entityDataPacket.setRuntimeEntityId(geyserId);
|
||||||
entityDataPacket.getMetadata().putAll(metadata);
|
entityDataPacket.getMetadata().putAll(metadata);
|
||||||
|
@ -27,6 +27,7 @@ package org.geysermc.connector.entity;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||||
import com.nukkitx.protocol.bedrock.data.EntityData;
|
import com.nukkitx.protocol.bedrock.data.EntityData;
|
||||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
||||||
@ -42,11 +43,12 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||||||
@Setter
|
@Setter
|
||||||
public class LivingEntity extends Entity {
|
public class LivingEntity extends Entity {
|
||||||
|
|
||||||
protected ItemData helmet;
|
protected ItemData helmet = ItemData.AIR;
|
||||||
protected ItemData chestplate;
|
protected ItemData chestplate = ItemData.AIR;
|
||||||
protected ItemData leggings;
|
protected ItemData leggings = ItemData.AIR;
|
||||||
protected ItemData boots;
|
protected ItemData boots = ItemData.AIR;
|
||||||
protected ItemData hand = ItemData.of(0, (short) 0, 0);
|
protected ItemData hand = ItemData.AIR;
|
||||||
|
protected ItemData offHand = ItemData.AIR;
|
||||||
|
|
||||||
public LivingEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
public LivingEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||||
super(entityId, geyserId, entityType, position, motion, rotation);
|
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||||
@ -80,11 +82,22 @@ public class LivingEntity extends Entity {
|
|||||||
armorEquipmentPacket.setLeggings(leggings);
|
armorEquipmentPacket.setLeggings(leggings);
|
||||||
armorEquipmentPacket.setBoots(boots);
|
armorEquipmentPacket.setBoots(boots);
|
||||||
|
|
||||||
MobEquipmentPacket mobEquipmentPacket = new MobEquipmentPacket();
|
MobEquipmentPacket handPacket = new MobEquipmentPacket();
|
||||||
mobEquipmentPacket.setRuntimeEntityId(geyserId);
|
handPacket.setRuntimeEntityId(geyserId);
|
||||||
mobEquipmentPacket.setItem(hand);
|
handPacket.setItem(hand);
|
||||||
|
handPacket.setHotbarSlot(-1);
|
||||||
|
handPacket.setInventorySlot(0);
|
||||||
|
handPacket.setContainerId(ContainerId.INVENTORY);
|
||||||
|
|
||||||
|
MobEquipmentPacket offHandPacket = new MobEquipmentPacket();
|
||||||
|
offHandPacket.setRuntimeEntityId(geyserId);
|
||||||
|
offHandPacket.setItem(offHand);
|
||||||
|
offHandPacket.setHotbarSlot(-1);
|
||||||
|
offHandPacket.setInventorySlot(0);
|
||||||
|
offHandPacket.setContainerId(ContainerId.OFFHAND);
|
||||||
|
|
||||||
session.getUpstream().sendPacket(armorEquipmentPacket);
|
session.getUpstream().sendPacket(armorEquipmentPacket);
|
||||||
session.getUpstream().sendPacket(mobEquipmentPacket);
|
session.getUpstream().sendPacket(handPacket);
|
||||||
|
session.getUpstream().sendPacket(offHandPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,10 +80,13 @@ public class PlayerEntity extends LivingEntity {
|
|||||||
addPlayerPacket.getAdventureSettings().setPlayerPermission(PlayerPermission.VISITOR);
|
addPlayerPacket.getAdventureSettings().setPlayerPermission(PlayerPermission.VISITOR);
|
||||||
addPlayerPacket.setDeviceId("");
|
addPlayerPacket.setDeviceId("");
|
||||||
addPlayerPacket.setPlatformChatId("");
|
addPlayerPacket.setPlatformChatId("");
|
||||||
addPlayerPacket.getMetadata().putAll(getMetadata());
|
addPlayerPacket.getMetadata().putAll(metadata);
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
session.getUpstream().sendPacket(addPlayerPacket);
|
session.getUpstream().sendPacket(addPlayerPacket);
|
||||||
|
|
||||||
|
updateEquipment(session);
|
||||||
|
updateBedrockAttributes(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayer(GeyserSession session) {
|
public void sendPlayer(GeyserSession session) {
|
||||||
|
@ -56,9 +56,13 @@ public class EntityCache {
|
|||||||
|
|
||||||
public void spawnEntity(Entity entity) {
|
public void spawnEntity(Entity entity) {
|
||||||
entity.moveAbsolute(entity.getPosition(), entity.getRotation().getX(), entity.getRotation().getY());
|
entity.moveAbsolute(entity.getPosition(), entity.getRotation().getX(), entity.getRotation().getY());
|
||||||
|
cacheEntity(entity);
|
||||||
|
entity.spawnEntity(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cacheEntity(Entity entity) {
|
||||||
entityIdTranslations.put(entity.getEntityId(), entity.getGeyserId());
|
entityIdTranslations.put(entity.getEntityId(), entity.getGeyserId());
|
||||||
entities.put(entity.getGeyserId(), entity);
|
entities.put(entity.getGeyserId(), entity);
|
||||||
entity.spawnEntity(session);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeEntity(Entity entity, boolean force) {
|
public boolean removeEntity(Entity entity, boolean force) {
|
||||||
|
@ -70,7 +70,7 @@ public class JavaEntityEquipmentTranslator extends PacketTranslator<ServerEntity
|
|||||||
livingEntity.setHand(item);
|
livingEntity.setHand(item);
|
||||||
break;
|
break;
|
||||||
case OFF_HAND:
|
case OFF_HAND:
|
||||||
// TODO: livingEntity.setOffHand(item);
|
livingEntity.setOffHand(item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,12 +41,8 @@ public class JavaEntityMetadataTranslator extends PacketTranslator<ServerEntityM
|
|||||||
}
|
}
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
|
|
||||||
if (entity.isValid()) {
|
|
||||||
for (EntityMetadata metadata : packet.getMetadata()) {
|
for (EntityMetadata metadata : packet.getMetadata()) {
|
||||||
entity.updateBedrockMetadata(metadata, session);
|
entity.updateBedrockMetadata(metadata, session);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
entity.spawnEntity(session);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class JavaEntityPropertiesTranslator extends PacketTranslator<ServerEntit
|
|||||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||||
entity = session.getPlayerEntity();
|
entity = session.getPlayerEntity();
|
||||||
}
|
}
|
||||||
if (entity == null || !entity.isValid()) return;
|
if (entity == null) return;
|
||||||
|
|
||||||
for (Attribute attribute : packet.getAttributes()) {
|
for (Attribute attribute : packet.getAttributes()) {
|
||||||
switch (attribute.getType()) {
|
switch (attribute.getType()) {
|
||||||
|
@ -50,6 +50,7 @@ public class JavaSpawnPlayerTranslator extends PacketTranslator<ServerSpawnPlaye
|
|||||||
entity.setEntityId(packet.getEntityId());
|
entity.setEntityId(packet.getEntityId());
|
||||||
entity.setPosition(position);
|
entity.setPosition(position);
|
||||||
entity.setRotation(rotation);
|
entity.setRotation(rotation);
|
||||||
|
session.getEntityCache().cacheEntity(entity);
|
||||||
|
|
||||||
// async skin loading
|
// async skin loading
|
||||||
if (session.getUpstream().isInitialized()) {
|
if (session.getUpstream().isInitialized()) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren