Skip to content

Commit

Permalink
Improve food list (ldtteam#6897)
Browse files Browse the repository at this point in the history
Exclude cookable food items from the food list in the GUI
Only request food if it or (if smeltable) the smelting result is not in the food exclusion list
  • Loading branch information
vroni92 authored Apr 12, 2021
1 parent c5dcfb4 commit c07eb66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.minecolonies.api.colony.requestsystem.requestable;

import com.google.common.reflect.TypeToken;
import com.minecolonies.api.MinecoloniesAPIProxy;
import com.minecolonies.api.colony.requestsystem.factory.IFactoryController;
import com.minecolonies.api.crafting.ItemStorage;
import com.minecolonies.api.util.ItemStackUtils;
import com.minecolonies.api.util.ReflectionUtils;
import com.minecolonies.api.util.constant.TypeConstants;
import com.minecolonies.api.compatibility.IFurnaceRecipes;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
Expand Down Expand Up @@ -169,7 +171,7 @@ public static Food deserialize(final IFactoryController controller, final Packet
@Override
public boolean matches(@NotNull final ItemStack stack)
{
return stack.getItem().isFood() && !exclusionList.contains(new ItemStorage(stack));
return stack.getItem().isFood() && !exclusionList.contains(new ItemStorage(stack)) && !(ItemStackUtils.ISCOOKABLE.test(stack) && exclusionList.contains(new ItemStorage(MinecoloniesAPIProxy.getInstance().getFurnaceRecipes().getSmeltingResult(stack))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.minecolonies.api.blocks.ModBlocks;
import com.minecolonies.api.colony.IColonyManager;
import com.minecolonies.api.colony.buildings.ModBuildings;
import com.minecolonies.api.crafting.ItemStorage;
import com.minecolonies.coremod.colony.buildings.AbstractBuildingWorker;
import com.minecolonies.coremod.colony.buildings.modules.settings.BoolSetting;
import com.minecolonies.api.colony.buildings.registry.BuildingEntry;
Expand All @@ -21,8 +22,11 @@
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.registries.IForgeRegistry;

import java.util.Set;

import static com.minecolonies.api.util.constant.BuildingConstants.FLORIST_FLOWER_LIST;
import static com.minecolonies.api.util.constant.TranslationConstants.*;
import static com.minecolonies.api.util.ItemStackUtils.ISCOOKABLE;
import static com.minecolonies.coremod.colony.buildings.AbstractBuildingFurnaceUser.FUEL_LIST;
import static com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingCook.FOOD_EXCLUSION_LIST;
import static com.minecolonies.coremod.entity.ai.citizen.composter.EntityAIWorkComposter.COMPOSTABLE_LIST;
Expand Down Expand Up @@ -126,7 +130,12 @@ public static void init(final RegistryEvent.Register<BuildingEntry> event)
.addBuildingModuleProducer(() -> new ItemListModule(FUEL_LIST), () -> new ItemListModuleView(FUEL_LIST, COM_MINECOLONIES_REQUESTS_BURNABLE, false,
(buildingView) -> IColonyManager.getInstance().getCompatibilityManager().getFuel()))
.addBuildingModuleProducer(() -> new ItemListModule(FOOD_EXCLUSION_LIST), () -> new ItemListModuleView(FOOD_EXCLUSION_LIST, COM_MINECOLONIES_REQUESTS_FOOD, true,
(buildingView) -> IColonyManager.getInstance().getCompatibilityManager().getEdibles()))
(buildingView) ->
{
Set<ItemStorage> edibles = IColonyManager.getInstance().getCompatibilityManager().getEdibles();
edibles.removeIf(item -> ISCOOKABLE.test(item.getItemStack()));
return edibles;
}))
.addBuildingModuleProducer(CrafterTaskModule::new, CrafterTaskModuleView::new)
.createBuildingEntry();

Expand Down

0 comments on commit c07eb66

Please sign in to comment.