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();
}
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));
}
}
}
}
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))));
}
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));
}
}
}
}
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;
}
Aggregations