From fd5333b77ba06200653559c28752f14c910f0f03 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Sat, 11 Apr 2020 13:06:50 -0400 Subject: [PATCH] Merge latest master --- .../connector/entity/EnderCrystalEntity.java | 22 +++++++++++++++++++ .../living/monster/EnderDragonEntity.java | 12 ++++++++++ .../connector/entity/type/EntityType.java | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java diff --git a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java index 48359248..1f766478 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java @@ -2,6 +2,8 @@ package org.geysermc.connector.entity; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.protocol.bedrock.data.EntityData; +import com.nukkitx.protocol.bedrock.packet.AddEntityPacket; import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.network.session.GeyserSession; @@ -14,6 +16,26 @@ public class EnderCrystalEntity extends Entity { @Override public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + System.out.println("ID: " + entityMetadata.getId() + ", " + entityMetadata.getValue()); super.updateBedrockMetadata(entityMetadata, session); } + + @Override + public void spawnEntity(GeyserSession session) { + AddEntityPacket addEntityPacket = new AddEntityPacket(); + // Not end crystal but ender crystal + addEntityPacket.setIdentifier("minecraft:ender_crystal"); + addEntityPacket.setRuntimeEntityId(geyserId); + addEntityPacket.setUniqueEntityId(geyserId); + addEntityPacket.setPosition(position); + addEntityPacket.setMotion(motion); + addEntityPacket.setRotation(getBedrockRotation()); + addEntityPacket.setEntityType(entityType.getType()); + addEntityPacket.getMetadata().putAll(metadata); + + valid = true; + session.getUpstream().sendPacket(addEntityPacket); + + session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); + } } diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java new file mode 100644 index 00000000..cf493e26 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java @@ -0,0 +1,12 @@ +package org.geysermc.connector.entity.living.monster; + +import com.nukkitx.math.vector.Vector3f; +import org.geysermc.connector.entity.living.InsentientEntity; +import org.geysermc.connector.entity.type.EntityType; + +public class EnderDragonEntity extends InsentientEntity { + + public EnderDragonEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { + super(entityId, geyserId, entityType, position, motion, rotation); + } +} diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java index b1452dd8..9fbb60f4 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java +++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java @@ -85,7 +85,7 @@ public enum EntityType { ELDER_GUARDIAN(GuardianEntity.class, 50, 1.9975f), NPC(PlayerEntity.class, 51, 1.8f, 0.6f, 0.6f, 1.62f), WITHER(MonsterEntity.class, 52, 3.5f, 0.9f), - ENDER_DRAGON(InsentientEntity.class, 53, 4f, 13f), + ENDER_DRAGON(EnderDragonEntity.class, 53, 4f, 13f), SHULKER(GolemEntity.class, 54, 1f, 1f), ENDERMITE(MonsterEntity.class, 55, 0.3f, 0.4f), AGENT(Entity.class, 56, 0f),