Search in sources :

Example 1 with ColonyViewCitizenViewMessage

use of com.minecolonies.coremod.network.messages.client.colony.ColonyViewCitizenViewMessage in project minecolonies by Minecolonies.

the class CitizenManager method sendPackets.

@Override
public void sendPackets(@NotNull final Set<ServerPlayerEntity> closeSubscribers, @NotNull final Set<ServerPlayerEntity> newSubscribers) {
    if (isCitizensDirty || !newSubscribers.isEmpty()) {
        final Set<ServerPlayerEntity> players = new HashSet<>();
        if (isCitizensDirty) {
            players.addAll(closeSubscribers);
        }
        players.addAll(newSubscribers);
        for (@NotNull final ICitizenData citizen : citizens.values()) {
            if (citizen.isDirty() || !newSubscribers.isEmpty()) {
                players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewCitizenViewMessage(colony, citizen), player));
            }
        }
    }
}
Also used : ColonyViewCitizenViewMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewCitizenViewMessage) ICitizenData(com.minecolonies.api.colony.ICitizenData) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ColonyViewCitizenViewMessage

use of com.minecolonies.coremod.network.messages.client.colony.ColonyViewCitizenViewMessage in project minecolonies by ldtteam.

the class CitizenManager method sendPackets.

@Override
public void sendPackets(@NotNull final Set<ServerPlayerEntity> closeSubscribers, @NotNull final Set<ServerPlayerEntity> newSubscribers) {
    if (isCitizensDirty || !newSubscribers.isEmpty()) {
        final Set<ServerPlayerEntity> players = new HashSet<>();
        if (isCitizensDirty) {
            players.addAll(closeSubscribers);
        }
        players.addAll(newSubscribers);
        for (@NotNull final ICitizenData citizen : citizens.values()) {
            if (citizen.isDirty() || !newSubscribers.isEmpty()) {
                players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewCitizenViewMessage(colony, citizen), player));
            }
        }
    }
}
Also used : ColonyViewCitizenViewMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewCitizenViewMessage) ICitizenData(com.minecolonies.api.colony.ICitizenData) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ICitizenData (com.minecolonies.api.colony.ICitizenData)2 ColonyViewCitizenViewMessage (com.minecolonies.coremod.network.messages.client.colony.ColonyViewCitizenViewMessage)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 NotNull (org.jetbrains.annotations.NotNull)2