Search in sources :

Example 1 with TAG_RECIPES

use of com.minecolonies.api.util.constant.NbtTagConstants.TAG_RECIPES in project minecolonies by Minecolonies.

the class AbstractCraftingBuildingModule method serializeNBT.

@Override
public void serializeNBT(@NotNull final CompoundNBT compound) {
    final CompoundNBT moduleCompound = new CompoundNBT();
    @NotNull final ListNBT recipesTagList = recipes.stream().map(iToken -> StandardFactoryController.getInstance().serialize(iToken)).collect(NBTUtils.toListNBT());
    moduleCompound.put(TAG_RECIPES, recipesTagList);
    @NotNull final ListNBT disabledRecipesTag = new ListNBT();
    for (@NotNull final IToken<?> recipe : disabledRecipes) {
        if (disabledRecipes.contains(recipe)) {
            disabledRecipesTag.add(StandardFactoryController.getInstance().serialize(recipe));
        }
    }
    moduleCompound.put(TAG_DISABLED_RECIPES, disabledRecipesTag);
    compound.put(getId(), moduleCompound);
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) IItemHandler(net.minecraftforge.items.IItemHandler) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) SettingKey(com.minecolonies.coremod.colony.buildings.modules.settings.SettingKey) Constants(net.minecraftforge.common.util.Constants) CompoundNBT(net.minecraft.nbt.CompoundNBT) IFormattableTextComponent(net.minecraft.util.text.IFormattableTextComponent) AbstractJobCrafter(com.minecolonies.coremod.colony.jobs.AbstractJobCrafter) MinecoloniesAPIProxy(com.minecolonies.api.MinecoloniesAPIProxy) StandardFactoryController(com.minecolonies.api.colony.requestsystem.StandardFactoryController) RECIPE_IMPROVED(com.minecolonies.api.util.constant.TranslationConstants.RECIPE_IMPROVED) JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) CraftingType(com.minecolonies.api.crafting.registry.CraftingType) ListNBT(net.minecraft.nbt.ListNBT) ImmutableSet(com.google.common.collect.ImmutableSet) PublicWorkerCraftingProductionResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingProductionResolver) TAG_RECIPES(com.minecolonies.api.util.constant.NbtTagConstants.TAG_RECIPES) Predicate(java.util.function.Predicate) TAG_DISABLED_RECIPES(com.minecolonies.api.util.constant.NbtTagConstants.TAG_DISABLED_RECIPES) LootParameters(net.minecraft.loot.LootParameters) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) com.minecolonies.api.crafting(com.minecolonies.api.crafting) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) IRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver) com.minecolonies.api.colony.buildings.modules(com.minecolonies.api.colony.buildings.modules) NotNull(org.jetbrains.annotations.NotNull) java.util(java.util) PublicWorkerCraftingRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingRequestResolver) CRAFTING_REDUCEABLE(com.minecolonies.api.util.constant.TagConstants.CRAFTING_REDUCEABLE) ISettingKey(com.minecolonies.api.colony.buildings.modules.settings.ISettingKey) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ICitizenData(com.minecolonies.api.colony.ICitizenData) IWareHouse(com.minecolonies.api.colony.buildings.workerbuildings.IWareHouse) ItemStack(net.minecraft.item.ItemStack) LootContext(net.minecraft.loot.LootContext) CustomRecipe(com.minecolonies.coremod.colony.crafting.CustomRecipe) com.minecolonies.api.util(com.minecolonies.api.util) RECIPES(com.minecolonies.api.research.util.ResearchConstants.RECIPES) IDeliverable(com.minecolonies.api.colony.requestsystem.requestable.IDeliverable) ModTags(com.minecolonies.api.items.ModTags) IColonyManager(com.minecolonies.api.colony.IColonyManager) Tuple(net.minecraft.util.Tuple) CrafterRecipeSetting(com.minecolonies.coremod.colony.buildings.modules.settings.CrafterRecipeSetting) Blocks(net.minecraft.block.Blocks) TypeConstants(com.minecolonies.api.util.constant.TypeConstants) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) PublicCrafting(com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting) ResourceLocation(net.minecraft.util.ResourceLocation) IColony(com.minecolonies.api.colony.IColony) CustomRecipeManager(com.minecolonies.coremod.colony.crafting.CustomRecipeManager) PacketBuffer(net.minecraft.network.PacketBuffer) IJob(com.minecolonies.api.colony.jobs.IJob) ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with TAG_RECIPES

use of com.minecolonies.api.util.constant.NbtTagConstants.TAG_RECIPES in project minecolonies by ldtteam.

the class AbstractCraftingBuildingModule method serializeNBT.

@Override
public void serializeNBT(@NotNull final CompoundNBT compound) {
    final CompoundNBT moduleCompound = new CompoundNBT();
    @NotNull final ListNBT recipesTagList = recipes.stream().map(iToken -> StandardFactoryController.getInstance().serialize(iToken)).collect(NBTUtils.toListNBT());
    moduleCompound.put(TAG_RECIPES, recipesTagList);
    @NotNull final ListNBT disabledRecipesTag = new ListNBT();
    for (@NotNull final IToken<?> recipe : disabledRecipes) {
        if (disabledRecipes.contains(recipe)) {
            disabledRecipesTag.add(StandardFactoryController.getInstance().serialize(recipe));
        }
    }
    moduleCompound.put(TAG_DISABLED_RECIPES, disabledRecipesTag);
    compound.put(getId(), moduleCompound);
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) IItemHandler(net.minecraftforge.items.IItemHandler) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) SettingKey(com.minecolonies.coremod.colony.buildings.modules.settings.SettingKey) Constants(net.minecraftforge.common.util.Constants) CompoundNBT(net.minecraft.nbt.CompoundNBT) AbstractJobCrafter(com.minecolonies.coremod.colony.jobs.AbstractJobCrafter) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StandardFactoryController(com.minecolonies.api.colony.requestsystem.StandardFactoryController) RECIPE_IMPROVED(com.minecolonies.api.util.constant.TranslationConstants.RECIPE_IMPROVED) JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ListNBT(net.minecraft.nbt.ListNBT) PublicWorkerCraftingProductionResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingProductionResolver) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TAG_RECIPES(com.minecolonies.api.util.constant.NbtTagConstants.TAG_RECIPES) Predicate(java.util.function.Predicate) TAG_DISABLED_RECIPES(com.minecolonies.api.util.constant.NbtTagConstants.TAG_DISABLED_RECIPES) LootParameters(net.minecraft.loot.LootParameters) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) com.minecolonies.api.crafting(com.minecolonies.api.crafting) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) IRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver) com.minecolonies.api.colony.buildings.modules(com.minecolonies.api.colony.buildings.modules) NotNull(org.jetbrains.annotations.NotNull) java.util(java.util) PublicWorkerCraftingRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingRequestResolver) CRAFTING_REDUCEABLE(com.minecolonies.api.util.constant.TagConstants.CRAFTING_REDUCEABLE) ISettingKey(com.minecolonies.api.colony.buildings.modules.settings.ISettingKey) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ICitizenData(com.minecolonies.api.colony.ICitizenData) IWareHouse(com.minecolonies.api.colony.buildings.workerbuildings.IWareHouse) ItemStack(net.minecraft.item.ItemStack) LootContext(net.minecraft.loot.LootContext) CustomRecipe(com.minecolonies.coremod.colony.crafting.CustomRecipe) com.minecolonies.api.util(com.minecolonies.api.util) RECIPES(com.minecolonies.api.research.util.ResearchConstants.RECIPES) IDeliverable(com.minecolonies.api.colony.requestsystem.requestable.IDeliverable) ModTags(com.minecolonies.api.items.ModTags) IColonyManager(com.minecolonies.api.colony.IColonyManager) Tuple(net.minecraft.util.Tuple) CrafterRecipeSetting(com.minecolonies.coremod.colony.buildings.modules.settings.CrafterRecipeSetting) Blocks(net.minecraft.block.Blocks) TypeConstants(com.minecolonies.api.util.constant.TypeConstants) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) PublicCrafting(com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting) ResourceLocation(net.minecraft.util.ResourceLocation) IColony(com.minecolonies.api.colony.IColony) CustomRecipeManager(com.minecolonies.coremod.colony.crafting.CustomRecipeManager) PacketBuffer(net.minecraft.network.PacketBuffer) IJob(com.minecolonies.api.colony.jobs.IJob) ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ICitizenData (com.minecolonies.api.colony.ICitizenData)2 IColony (com.minecolonies.api.colony.IColony)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 com.minecolonies.api.colony.buildings.modules (com.minecolonies.api.colony.buildings.modules)2 ISettingKey (com.minecolonies.api.colony.buildings.modules.settings.ISettingKey)2 IWareHouse (com.minecolonies.api.colony.buildings.workerbuildings.IWareHouse)2 IJob (com.minecolonies.api.colony.jobs.IJob)2 JobEntry (com.minecolonies.api.colony.jobs.registry.JobEntry)2 StandardFactoryController (com.minecolonies.api.colony.requestsystem.StandardFactoryController)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)2 IDeliverable (com.minecolonies.api.colony.requestsystem.requestable.IDeliverable)2 PublicCrafting (com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting)2 IRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver)2 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)2 com.minecolonies.api.crafting (com.minecolonies.api.crafting)2 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)2 ModTags (com.minecolonies.api.items.ModTags)2 RECIPES (com.minecolonies.api.research.util.ResearchConstants.RECIPES)2 com.minecolonies.api.util (com.minecolonies.api.util)2