Search in sources :

Example 1 with ITownHallView

use of com.minecolonies.api.colony.buildings.workerbuildings.ITownHallView in project minecolonies by Minecolonies.

the class ColonyView method handleColonyBuildingViewMessage.

/**
 * Update a ColonyView's buildings given a network data ColonyView update packet. This uses a full-replacement - buildings do not get updated and are instead overwritten.
 *
 * @param buildingId location of the building.
 * @param buf        buffer containing ColonyBuilding information.
 * @return null == no response.
 */
@Override
@Nullable
public IMessage handleColonyBuildingViewMessage(final BlockPos buildingId, @NotNull final PacketBuffer buf) {
    if (buildings.containsKey(buildingId)) {
        // Read the string first to set up the buffer.
        buf.readUtf(32767);
        buildings.get(buildingId).deserialize(buf);
    } else {
        @Nullable final IBuildingView building = IBuildingDataManager.getInstance().createViewFrom(this, buildingId, buf);
        if (building != null) {
            buildings.put(building.getID(), building);
            if (building instanceof BuildingTownHall.View) {
                townHall = (ITownHallView) building;
            }
        }
    }
    return null;
}
Also used : IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ITownHallView(com.minecolonies.api.colony.buildings.workerbuildings.ITownHallView) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView) IWorkOrderView(com.minecolonies.api.colony.workorders.IWorkOrderView) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) PermissionsView(com.minecolonies.coremod.colony.permissions.PermissionsView) Nullable(org.jetbrains.annotations.Nullable) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ITownHallView

use of com.minecolonies.api.colony.buildings.workerbuildings.ITownHallView in project minecolonies by ldtteam.

the class ColonyView method handleColonyBuildingViewMessage.

/**
 * Update a ColonyView's buildings given a network data ColonyView update packet. This uses a full-replacement - buildings do not get updated and are instead overwritten.
 *
 * @param buildingId location of the building.
 * @param buf        buffer containing ColonyBuilding information.
 * @return null == no response.
 */
@Override
@Nullable
public IMessage handleColonyBuildingViewMessage(final BlockPos buildingId, @NotNull final PacketBuffer buf) {
    if (buildings.containsKey(buildingId)) {
        // Read the string first to set up the buffer.
        buf.readUtf(32767);
        buildings.get(buildingId).deserialize(buf);
    } else {
        @Nullable final IBuildingView building = IBuildingDataManager.getInstance().createViewFrom(this, buildingId, buf);
        if (building != null) {
            buildings.put(building.getID(), building);
            if (building instanceof BuildingTownHall.View) {
                townHall = (ITownHallView) building;
            }
        }
    }
    return null;
}
Also used : IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ITownHallView(com.minecolonies.api.colony.buildings.workerbuildings.ITownHallView) WorkOrderView(com.minecolonies.api.colony.workorders.WorkOrderView) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) PermissionsView(com.minecolonies.coremod.colony.permissions.PermissionsView) Nullable(org.jetbrains.annotations.Nullable) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)2 ITownHallView (com.minecolonies.api.colony.buildings.workerbuildings.ITownHallView)2 AbstractBuildingView (com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)2 PermissionsView (com.minecolonies.coremod.colony.permissions.PermissionsView)2 Nullable (org.jetbrains.annotations.Nullable)2 IWorkOrderView (com.minecolonies.api.colony.workorders.IWorkOrderView)1 WorkOrderView (com.minecolonies.api.colony.workorders.WorkOrderView)1