use of org.spongepowered.common.entity.living.human.HumanEntity in project SpongeCommon by SpongePowered.
the class ServerEntityMixin method impl$sendHumanMetadata.
@Inject(method = "sendDirtyEntityData", at = @At("HEAD"))
public void impl$sendHumanMetadata(final CallbackInfo ci) {
if (!(this.entity instanceof HumanEntity)) {
return;
}
final HumanEntity human = (HumanEntity) this.entity;
Stream<Packet<?>> packets = human.popQueuedPackets(null);
packets.forEach(this.broadcast);
// Note that this will further call in ChunkManager_EntityTrackerMixin
// for any player specific packets to send.
}
use of org.spongepowered.common.entity.living.human.HumanEntity in project SpongeCommon by SpongePowered.
the class ServerEntityMixin method impl$sendHumanSpawnPacket.
/**
* @author gabizou
* @reason Because the entity spawn packet is just a lone packet, we have to actually
* do some hackery to create the player list packet first, then the spawn packet,
* then perform the remove packet.
*/
@Redirect(method = "sendPairingData", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V", ordinal = 0))
public void impl$sendHumanSpawnPacket(final Consumer<Packet<?>> consumer, final Object spawnPacket) {
if (!(this.entity instanceof HumanEntity)) {
consumer.accept((Packet<?>) spawnPacket);
return;
}
final HumanEntity human = (HumanEntity) this.entity;
// Adds the GameProfile to the client
consumer.accept(human.createPlayerListPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER));
// Actually spawn the human (a player)
consumer.accept((Packet<?>) spawnPacket);
// Remove from tab list
final ClientboundPlayerInfoPacket removePacket = human.createPlayerListPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER);
if (human.canRemoveFromListImmediately()) {
consumer.accept(removePacket);
} else {
// TODO - find out if this is still needed.
human.removeFromTabListDelayed(null, removePacket);
}
}
Aggregations