mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-09 08:51:38 +01:00
Switched all direct spawn packets interactions to EntityType#getSpawnType#getSpawnPacket
This commit is contained in:
parent
c8d0b783d8
commit
1308f81678
@ -12,7 +12,6 @@ import net.minestom.server.event.item.ArmorEquipEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.EntityEquipmentPacket;
|
||||
import net.minestom.server.network.packet.server.play.SpawnLivingEntityPacket;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
@ -116,14 +115,7 @@ public class EntityCreature extends LivingEntity implements NavigableEntity, Ent
|
||||
|
||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||
|
||||
SpawnLivingEntityPacket spawnLivingEntityPacket = new SpawnLivingEntityPacket();
|
||||
spawnLivingEntityPacket.entityId = getEntityId();
|
||||
spawnLivingEntityPacket.entityUuid = getUuid();
|
||||
spawnLivingEntityPacket.entityType = getEntityType().getId();
|
||||
spawnLivingEntityPacket.position = getPosition();
|
||||
spawnLivingEntityPacket.headPitch = getPosition().getYaw();
|
||||
|
||||
playerConnection.sendPacket(spawnLivingEntityPacket);
|
||||
playerConnection.sendPacket(getEntityType().getSpawnType().getSpawnPacket(this));
|
||||
playerConnection.sendPacket(getVelocityPacket());
|
||||
playerConnection.sendPacket(getMetadataPacket());
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.network.packet.server.play.SpawnExperienceOrbPacket;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -87,25 +85,6 @@ public class ExperienceOrb extends Entity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addViewer(@NotNull Player player) {
|
||||
final boolean result = super.addViewer(player); // Add player to viewers list
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||
|
||||
SpawnExperienceOrbPacket experienceOrbPacket = new SpawnExperienceOrbPacket();
|
||||
experienceOrbPacket.entityId = getEntityId();
|
||||
experienceOrbPacket.position = getPosition();
|
||||
experienceOrbPacket.expCount = experienceCount;
|
||||
|
||||
playerConnection.sendPacket(experienceOrbPacket);
|
||||
playerConnection.sendPacket(getVelocityPacket());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the experience count.
|
||||
*
|
||||
|
@ -1,10 +1,13 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.network.packet.server.play.SpawnEntityPacket;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link net.minestom.server.entity.metadata.EntityMeta} that inherits
|
||||
* {@link net.minestom.server.entity.metadata.ObjectDataProvider} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class ObjectEntity extends Entity {
|
||||
|
||||
public ObjectEntity(@NotNull EntityType entityType, @NotNull Position spawnPosition) {
|
||||
@ -30,29 +33,4 @@ public abstract class ObjectEntity extends Entity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addViewer(@NotNull Player player) {
|
||||
final boolean result = super.addViewer(player);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||
|
||||
SpawnEntityPacket spawnEntityPacket = new SpawnEntityPacket();
|
||||
spawnEntityPacket.entityId = getEntityId();
|
||||
spawnEntityPacket.uuid = getUuid();
|
||||
spawnEntityPacket.type = getEntityType().getId();
|
||||
spawnEntityPacket.position = getPosition();
|
||||
spawnEntityPacket.data = getObjectData();
|
||||
playerConnection.sendPacket(spawnEntityPacket);
|
||||
playerConnection.sendPacket(getVelocityPacket());
|
||||
playerConnection.sendPacket(getMetadataPacket());
|
||||
|
||||
if (hasPassenger()) {
|
||||
playerConnection.sendPacket(getPassengersPacket());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1417,11 +1417,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
protected void refreshAfterTeleport() {
|
||||
getInventory().update();
|
||||
|
||||
SpawnPlayerPacket spawnPlayerPacket = new SpawnPlayerPacket();
|
||||
spawnPlayerPacket.entityId = getEntityId();
|
||||
spawnPlayerPacket.playerUuid = getUuid();
|
||||
spawnPlayerPacket.position = getPosition();
|
||||
sendPacketToViewers(spawnPlayerPacket);
|
||||
sendPacketsToViewers(getEntityType().getSpawnType().getSpawnPacket(this));
|
||||
|
||||
// Update for viewers
|
||||
sendPacketToViewersAndSelf(getVelocityPacket());
|
||||
@ -2400,14 +2396,9 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
* @param connection the connection to show the player to
|
||||
*/
|
||||
protected void showPlayer(@NotNull PlayerConnection connection) {
|
||||
SpawnPlayerPacket spawnPlayerPacket = new SpawnPlayerPacket();
|
||||
spawnPlayerPacket.entityId = getEntityId();
|
||||
spawnPlayerPacket.playerUuid = getUuid();
|
||||
spawnPlayerPacket.position = getPosition();
|
||||
|
||||
connection.sendPacket(getAddPlayerToList());
|
||||
|
||||
connection.sendPacket(spawnPlayerPacket);
|
||||
connection.sendPacket(getEntityType().getSpawnType().getSpawnPacket(this));
|
||||
connection.sendPacket(getVelocityPacket());
|
||||
connection.sendPacket(getMetadataPacket());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user