Search in sources :

Example 6 with BuildingEntry

use of com.minecolonies.api.colony.buildings.registry.BuildingEntry in project minecolonies by ldtteam.

the class CommonMinecoloniesAPIImpl method onRegistryNewRegistry.

public void onRegistryNewRegistry(final RegistryEvent.NewRegistry event) {
    buildingRegistry = new RegistryBuilder<BuildingEntry>().setName(new ResourceLocation(Constants.MOD_ID, "buildings")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(BuildingEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    jobRegistry = new RegistryBuilder<JobEntry>().setName(new ResourceLocation(Constants.MOD_ID, "jobs")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(JobEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    guardTypeRegistry = new RegistryBuilder<GuardType>().setName(new ResourceLocation(Constants.MOD_ID, "guardtypes")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setDefaultKey(ModGuardTypes.KNIGHT_ID).setType(GuardType.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    interactionHandlerRegistry = new RegistryBuilder<InteractionResponseHandlerEntry>().setName(new ResourceLocation(Constants.MOD_ID, "interactionresponsehandlers")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(InteractionResponseHandlerEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    colonyEventRegistry = new RegistryBuilder<ColonyEventTypeRegistryEntry>().setName(new ResourceLocation(Constants.MOD_ID, "colonyeventtypes")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(ColonyEventTypeRegistryEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    colonyEventDescriptionRegistry = new RegistryBuilder<ColonyEventDescriptionTypeRegistryEntry>().setName(new ResourceLocation(Constants.MOD_ID, "colonyeventdesctypes")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(ColonyEventDescriptionTypeRegistryEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    recipeTypeEntryRegistry = new RegistryBuilder<RecipeTypeEntry>().setName(new ResourceLocation(Constants.MOD_ID, "recipetypeentries")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "classic")).disableSaving().allowModification().setType(RecipeTypeEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    researchRequirementRegistry = new RegistryBuilder<ResearchRequirementEntry>().setName(new ResourceLocation(Constants.MOD_ID, "researchrequirementtypes")).setDefaultKey(RESEARCH_RESEARCH_REQ_ID).disableSaving().allowModification().setType(ResearchRequirementEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    researchEffectRegistry = new RegistryBuilder<ResearchEffectEntry>().setName(new ResourceLocation(Constants.MOD_ID, "researcheffecttypes")).setDefaultKey(GLOBAL_EFFECT_ID).disableSaving().allowModification().setType(ResearchEffectEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ColonyEventDescriptionTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventDescriptionTypeRegistryEntry) ResearchEffectEntry(com.minecolonies.api.research.effects.registry.ResearchEffectEntry) InteractionResponseHandlerEntry(com.minecolonies.api.colony.interactionhandling.registry.InteractionResponseHandlerEntry) RecipeTypeEntry(com.minecolonies.api.crafting.registry.RecipeTypeEntry) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) ResourceLocation(net.minecraft.util.ResourceLocation) RegistryBuilder(net.minecraftforge.registries.RegistryBuilder) GuardType(com.minecolonies.api.colony.guardtype.GuardType) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry) ResearchRequirementEntry(com.minecolonies.api.research.registry.ResearchRequirementEntry)

Example 7 with BuildingEntry

use of com.minecolonies.api.colony.buildings.registry.BuildingEntry in project minecolonies by ldtteam.

the class JEIPlugin method registerCategories.

@Override
public void registerCategories(@NotNull final IRecipeCategoryRegistration registration) {
    final IJeiHelpers jeiHelpers = registration.getJeiHelpers();
    final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
    registration.addRecipeCategories(new CompostRecipeCategory(guiHelper));
    registration.addRecipeCategories(new FishermanRecipeCategory(guiHelper));
    categories.clear();
    for (final BuildingEntry building : IMinecoloniesAPI.getInstance().getBuildingRegistry()) {
        for (final Supplier<IBuildingModule> producer : building.getModuleProducers()) {
            final IBuildingModule module = producer.get();
            if (module instanceof ICraftingBuildingModule) {
                final ICraftingBuildingModule crafting = (ICraftingBuildingModule) module;
                final IJob<?> job = crafting.getCraftingJob();
                if (job != null) {
                    registerCategory(registration, new GenericRecipeCategory(building, job, crafting, guiHelper));
                }
            }
            if (module instanceof AnimalHerdingModule) {
                final AnimalHerdingModule herding = (AnimalHerdingModule) module;
                registerCategory(registration, new HerderRecipeCategory(building, herding.getHerdingJob(), herding, guiHelper));
            }
        }
    }
}
Also used : IGuiHelper(mezz.jei.api.helpers.IGuiHelper) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) IBuildingModule(com.minecolonies.api.colony.buildings.modules.IBuildingModule) AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule) ICraftingBuildingModule(com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule) IJeiHelpers(mezz.jei.api.helpers.IJeiHelpers)

Example 8 with BuildingEntry

use of com.minecolonies.api.colony.buildings.registry.BuildingEntry in project minecolonies by ldtteam.

the class CustomRecipeManager method buildLootData.

/**
 * Analyses and builds an approximate list of possible loot drops from registered recipes.
 * @param lootTableManager the loot table manager
 */
public void buildLootData(@NotNull final LootTableManager lootTableManager) {
    final List<ResourceLocation> lootIds = new ArrayList<>();
    for (final Map<ResourceLocation, CustomRecipe> recipes : recipeMap.values()) {
        for (final CustomRecipe recipe : recipes.values()) {
            final ResourceLocation lootTable = recipe.getLootTable();
            if (lootTable != null) {
                lootIds.add(lootTable);
            }
        }
    }
    for (final BuildingEntry building : IMinecoloniesAPI.getInstance().getBuildingRegistry()) {
        building.getModuleProducers().stream().map(Supplier::get).filter(m -> m instanceof AnimalHerdingModule).map(m -> (AnimalHerdingModule) m).forEach(herding -> lootIds.add(herding.getDefaultLootTable()));
    }
    lootIds.add(ModLootTables.FISHING);
    lootIds.addAll(ModLootTables.FISHERMAN_BONUS.values());
    lootTables.clear();
    lootTables.putAll(lootIds.stream().filter(// just in case
    Objects::nonNull).distinct().collect(Collectors.toConcurrentMap(Function.identity(), id -> LootTableAnalyzer.toDrops(lootTableManager, id))));
}
Also used : AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) java.util(java.util) Item(net.minecraft.item.Item) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) LootTableManager(net.minecraft.loot.LootTableManager) Unpooled(io.netty.buffer.Unpooled) StandardFactoryController(com.minecolonies.api.colony.requestsystem.StandardFactoryController) ItemStack(net.minecraft.item.ItemStack) Nullable(org.jetbrains.annotations.Nullable) MinecraftForge(net.minecraftforge.common.MinecraftForge) IMinecoloniesAPI(com.minecolonies.api.IMinecoloniesAPI) ResourceLocation(net.minecraft.util.ResourceLocation) Network(com.minecolonies.coremod.Network) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) PacketBuffer(net.minecraft.network.PacketBuffer) ModLootTables(com.minecolonies.api.loot.ModLootTables) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) ResourceLocation(net.minecraft.util.ResourceLocation) AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule)

Example 9 with BuildingEntry

use of com.minecolonies.api.colony.buildings.registry.BuildingEntry in project minecolonies by Minecolonies.

the class JEIPlugin method registerCategories.

@Override
public void registerCategories(@NotNull final IRecipeCategoryRegistration registration) {
    final IJeiHelpers jeiHelpers = registration.getJeiHelpers();
    final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
    registration.addRecipeCategories(new CompostRecipeCategory(guiHelper));
    registration.addRecipeCategories(new FishermanRecipeCategory(guiHelper));
    categories.clear();
    for (final BuildingEntry building : IMinecoloniesAPI.getInstance().getBuildingRegistry()) {
        for (final Supplier<IBuildingModule> producer : building.getModuleProducers()) {
            final IBuildingModule module = producer.get();
            if (module instanceof ICraftingBuildingModule) {
                final ICraftingBuildingModule crafting = (ICraftingBuildingModule) module;
                final IJob<?> job = crafting.getCraftingJob();
                if (job != null) {
                    registerCategory(registration, new GenericRecipeCategory(building, job, crafting, guiHelper));
                }
            }
            if (module instanceof AnimalHerdingModule) {
                final AnimalHerdingModule herding = (AnimalHerdingModule) module;
                registerCategory(registration, new HerderRecipeCategory(building, herding.getHerdingJob(), herding, guiHelper));
            }
        }
    }
}
Also used : IGuiHelper(mezz.jei.api.helpers.IGuiHelper) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) IBuildingModule(com.minecolonies.api.colony.buildings.modules.IBuildingModule) AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule) ICraftingBuildingModule(com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule) IJeiHelpers(mezz.jei.api.helpers.IJeiHelpers)

Example 10 with BuildingEntry

use of com.minecolonies.api.colony.buildings.registry.BuildingEntry in project minecolonies by Minecolonies.

the class BuildingDataManager method createViewFrom.

@Override
public IBuildingView createViewFrom(final IColonyView colony, final BlockPos position, final PacketBuffer networkBuffer) {
    final ResourceLocation buildingName = new ResourceLocation(networkBuffer.readUtf(32767));
    final BuildingEntry entry = IBuildingRegistry.getInstance().getValue(buildingName);
    if (entry == null) {
        Log.getLogger().error(String.format("Unknown building type '%s'.", buildingName), new Exception());
        return null;
    }
    final IBuildingView view = entry.produceBuildingView(position, colony);
    if (view != null) {
        view.deserialize(networkBuffer);
    }
    return view;
}
Also used : BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) ResourceLocation(net.minecraft.util.ResourceLocation) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView)

Aggregations

BuildingEntry (com.minecolonies.api.colony.buildings.registry.BuildingEntry)12 ResourceLocation (net.minecraft.util.ResourceLocation)8 AnimalHerdingModule (com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule)4 ItemStack (net.minecraft.item.ItemStack)4 IMinecoloniesAPI (com.minecolonies.api.IMinecoloniesAPI)2 ModBlocks (com.minecolonies.api.blocks.ModBlocks)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 ISchematicProvider (com.minecolonies.api.colony.buildings.ISchematicProvider)2 ModBuildings (com.minecolonies.api.colony.buildings.ModBuildings)2 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)2 ColonyEventDescriptionTypeRegistryEntry (com.minecolonies.api.colony.colonyEvents.registry.ColonyEventDescriptionTypeRegistryEntry)2 ColonyEventTypeRegistryEntry (com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)2 GuardType (com.minecolonies.api.colony.guardtype.GuardType)2 ModGuardTypes (com.minecolonies.api.colony.guardtype.registry.ModGuardTypes)2 InteractionResponseHandlerEntry (com.minecolonies.api.colony.interactionhandling.registry.InteractionResponseHandlerEntry)2 ModJobs (com.minecolonies.api.colony.jobs.ModJobs)2 JobEntry (com.minecolonies.api.colony.jobs.registry.JobEntry)2 StandardFactoryController (com.minecolonies.api.colony.requestsystem.StandardFactoryController)2 CompatibilityManager (com.minecolonies.api.compatibility.CompatibilityManager)2 ItemStorage (com.minecolonies.api.crafting.ItemStorage)2