Search in sources :

Example 1 with BuildingBuilderView

use of com.minecolonies.coremod.colony.buildings.views.BuildingBuilderView in project minecolonies by Minecolonies.

the class WindowHutBuilder method pullResourcesFromHut.

/**
     * Retrieve resources from the building to display in GUI.
     */
private void pullResourcesFromHut() {
    final AbstractBuilding.View newView = builder.getColony().getBuilding(builder.getID());
    if (newView instanceof BuildingBuilderView) {
        final BuildingBuilderView updatedView = (BuildingBuilderView) newView;
        final InventoryPlayer inventory = this.mc.player.inventory;
        resources.clear();
        resources.addAll(updatedView.getResources().values());
        for (final BuildingBuilderResource resource : resources) {
            resource.setPlayerAmount(InventoryUtils.getItemCountInItemHandler(new InvWrapper(inventory), resource.getItem(), resource.getDamageValue()));
        }
        resources.sort(new BuildingBuilderResource.ResourceComparator());
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) BuildingBuilderResource(com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource) BuildingBuilderView(com.minecolonies.coremod.colony.buildings.views.BuildingBuilderView) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding)

Aggregations

AbstractBuilding (com.minecolonies.coremod.colony.buildings.AbstractBuilding)1 BuildingBuilderResource (com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource)1 BuildingBuilderView (com.minecolonies.coremod.colony.buildings.views.BuildingBuilderView)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 InvWrapper (net.minecraftforge.items.wrapper.InvWrapper)1