mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
Fix equipments synchronization and error with unloaded chunk
This commit is contained in:
parent
83449aecc9
commit
e092eba4c1
@ -34,7 +34,7 @@ public abstract class EntityCreature extends LivingEntity {
|
||||
|
||||
|
||||
public EntityCreature(EntityType entityType, Position spawnPosition) {
|
||||
super(entityType.getId(), spawnPosition);
|
||||
super(entityType, spawnPosition);
|
||||
|
||||
this.mainHandItem = ItemStack.getAirItem();
|
||||
this.offHandItem = ItemStack.getAirItem();
|
||||
@ -155,6 +155,9 @@ public abstract class EntityCreature extends LivingEntity {
|
||||
playerConnection.sendPacket(getVelocityPacket());
|
||||
playerConnection.sendPacket(getMetadataPacket());
|
||||
|
||||
// Equipments synchronization
|
||||
syncEquipments();
|
||||
|
||||
if (hasPassenger()) {
|
||||
playerConnection.sendPacket(getPassengersPacket());
|
||||
}
|
||||
|
@ -51,13 +51,13 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler {
|
||||
*/
|
||||
private long fireDamagePeriod = 1000L;
|
||||
|
||||
public LivingEntity(int entityType, Position spawnPosition) {
|
||||
super(entityType, spawnPosition);
|
||||
public LivingEntity(EntityType entityType, Position spawnPosition) {
|
||||
super(entityType.getId(), spawnPosition);
|
||||
setupAttributes();
|
||||
setGravity(0.02f);
|
||||
}
|
||||
|
||||
public LivingEntity(int entityType) {
|
||||
public LivingEntity(EntityType entityType) {
|
||||
this(entityType, new Position());
|
||||
}
|
||||
|
||||
@ -139,15 +139,6 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addViewer(Player player) {
|
||||
boolean result = super.addViewer(player);
|
||||
|
||||
// Equipments synchronization
|
||||
syncEquipments();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill the entity, trigger the {@link EntityDeathEvent} event
|
||||
*/
|
||||
|
@ -113,7 +113,7 @@ public class Player extends LivingEntity {
|
||||
private PlayerVehicleInformation vehicleInformation = new PlayerVehicleInformation();
|
||||
|
||||
public Player(UUID uuid, String username, PlayerConnection playerConnection) {
|
||||
super(EntityType.PLAYER.getId());
|
||||
super(EntityType.PLAYER);
|
||||
this.uuid = uuid;
|
||||
this.username = username;
|
||||
this.playerConnection = playerConnection;
|
||||
@ -327,7 +327,10 @@ public class Player extends LivingEntity {
|
||||
if (getOpenInventory() != null)
|
||||
getOpenInventory().removeViewer(this);
|
||||
this.viewableEntities.forEach(entity -> entity.removeViewer(this));
|
||||
this.viewableChunks.forEach(chunk -> chunk.removeViewer(this));
|
||||
this.viewableChunks.forEach(chunk -> {
|
||||
if (chunk.isLoaded())
|
||||
chunk.removeViewer(this);
|
||||
});
|
||||
resetTargetBlock();
|
||||
callEvent(PlayerDisconnectEvent.class, new PlayerDisconnectEvent());
|
||||
}
|
||||
@ -356,6 +359,9 @@ public class Player extends LivingEntity {
|
||||
viewerConnection.sendPacket(getVelocityPacket());
|
||||
viewerConnection.sendPacket(getMetadataPacket());
|
||||
|
||||
// Equipments synchronization
|
||||
syncEquipments();
|
||||
|
||||
if (hasPassenger()) {
|
||||
viewerConnection.sendPacket(getPassengersPacket());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user