2020-04-10 16:39:52 +00:00
|
|
|
package org.geysermc.connector.entity;
|
|
|
|
|
|
|
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
|
|
|
import com.nukkitx.math.vector.Vector3f;
|
2020-04-11 17:06:50 +00:00
|
|
|
import com.nukkitx.protocol.bedrock.data.EntityData;
|
|
|
|
import com.nukkitx.protocol.bedrock.packet.AddEntityPacket;
|
2020-04-10 16:39:52 +00:00
|
|
|
import org.geysermc.connector.entity.type.EntityType;
|
|
|
|
import org.geysermc.connector.network.session.GeyserSession;
|
|
|
|
|
|
|
|
public class EnderCrystalEntity extends Entity {
|
|
|
|
|
|
|
|
public EnderCrystalEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
|
|
|
super(entityId, geyserId, entityType, position, motion, rotation);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
2020-04-11 17:06:50 +00:00
|
|
|
System.out.println("ID: " + entityMetadata.getId() + ", " + entityMetadata.getValue());
|
2020-04-10 16:39:52 +00:00
|
|
|
super.updateBedrockMetadata(entityMetadata, session);
|
|
|
|
}
|
2020-04-11 17:06:50 +00:00
|
|
|
|
|
|
|
@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 + ")");
|
|
|
|
}
|
2020-04-10 16:39:52 +00:00
|
|
|
}
|