Search in sources :

Example 1 with ColonyViewBuildingViewMessage

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

the class BuildingManager method sendFieldPackets.

/**
 * Sends packages to update the fields.
 *
 * @param closeSubscribers the current event subscribers.
 * @param newSubscribers   the new event subscribers.
 */
private void sendFieldPackets(final Set<ServerPlayerEntity> closeSubscribers, final Set<ServerPlayerEntity> newSubscribers) {
    if (isFieldsDirty || !newSubscribers.isEmpty()) {
        final Set<ServerPlayerEntity> players = new HashSet<>();
        if (isFieldsDirty) {
            players.addAll(closeSubscribers);
        }
        players.addAll(newSubscribers);
        for (final IBuilding building : buildings.values()) {
            if (building instanceof BuildingFarmer) {
                players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewBuildingViewMessage(building), player));
            }
        }
    }
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BuildingFarmer(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingFarmer) ColonyViewBuildingViewMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewBuildingViewMessage)

Example 2 with ColonyViewBuildingViewMessage

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

the class BuildingManager method sendBuildingPackets.

/**
 * Sends packages to update the buildings.
 *
 * @param closeSubscribers the current event subscribers.
 * @param newSubscribers   the new event subscribers.
 */
private void sendBuildingPackets(final Set<ServerPlayerEntity> closeSubscribers, final Set<ServerPlayerEntity> newSubscribers) {
    if (isBuildingsDirty || !newSubscribers.isEmpty()) {
        final Set<ServerPlayerEntity> players = new HashSet<>();
        if (isBuildingsDirty) {
            players.addAll(closeSubscribers);
        }
        players.addAll(newSubscribers);
        for (@NotNull final IBuilding building : buildings.values()) {
            if (building.isDirty() || !newSubscribers.isEmpty()) {
                players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewBuildingViewMessage(building), player));
            }
        }
    }
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) NotNull(org.jetbrains.annotations.NotNull) ColonyViewBuildingViewMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewBuildingViewMessage)

Example 3 with ColonyViewBuildingViewMessage

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

the class BuildingManager method sendBuildingPackets.

/**
 * Sends packages to update the buildings.
 *
 * @param closeSubscribers the current event subscribers.
 * @param newSubscribers   the new event subscribers.
 */
private void sendBuildingPackets(final Set<ServerPlayerEntity> closeSubscribers, final Set<ServerPlayerEntity> newSubscribers) {
    if (isBuildingsDirty || !newSubscribers.isEmpty()) {
        final Set<ServerPlayerEntity> players = new HashSet<>();
        if (isBuildingsDirty) {
            players.addAll(closeSubscribers);
        }
        players.addAll(newSubscribers);
        for (@NotNull final IBuilding building : buildings.values()) {
            if (building.isDirty() || !newSubscribers.isEmpty()) {
                players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewBuildingViewMessage(building), player));
            }
        }
    }
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) NotNull(org.jetbrains.annotations.NotNull) ColonyViewBuildingViewMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewBuildingViewMessage)

Example 4 with ColonyViewBuildingViewMessage

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

the class BuildingManager method sendFieldPackets.

/**
 * Sends packages to update the fields.
 *
 * @param closeSubscribers the current event subscribers.
 * @param newSubscribers   the new event subscribers.
 */
private void sendFieldPackets(final Set<ServerPlayerEntity> closeSubscribers, final Set<ServerPlayerEntity> newSubscribers) {
    if (isFieldsDirty || !newSubscribers.isEmpty()) {
        final Set<ServerPlayerEntity> players = new HashSet<>();
        if (isFieldsDirty) {
            players.addAll(closeSubscribers);
        }
        players.addAll(newSubscribers);
        for (final IBuilding building : buildings.values()) {
            if (building instanceof BuildingFarmer) {
                players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewBuildingViewMessage(building), player));
            }
        }
    }
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BuildingFarmer(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingFarmer) ColonyViewBuildingViewMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewBuildingViewMessage)

Aggregations

IBuilding (com.minecolonies.api.colony.buildings.IBuilding)4 ColonyViewBuildingViewMessage (com.minecolonies.coremod.network.messages.client.colony.ColonyViewBuildingViewMessage)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 BuildingFarmer (com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingFarmer)2 NotNull (org.jetbrains.annotations.NotNull)2