Search in sources :

Example 1 with VillagerRegistry

use of org.spongepowered.api.item.merchant.VillagerRegistry in project SpongeCommon by SpongePowered.

the class SpongeVillagerRegistry method registerVanillaTrades.

static void registerVanillaTrades() {
    VillagerRegistry instance = getInstance();
    for (Career career : CareerRegistryModule.getInstance().getAll()) {
        SpongeCareer spongeCareer = (SpongeCareer) career;
        EntityVillager.ITradeList[][] careerLevels = EntityVillager.DEFAULT_TRADE_LIST_MAP[((SpongeProfession) spongeCareer.getProfession()).type][spongeCareer.type];
        for (int level = 0; level < careerLevels.length; level++) {
            EntityVillager.ITradeList[] offers = careerLevels[level];
            ImmutableList.Builder<TradeOfferListMutator> builder = ImmutableList.builder();
            for (int i = 0; i < offers.length; i++) {
                builder.add(generatorFor(offers[i]));
            }
            instance.setMutators(career, level + 1, builder.build());
        }
    }
}
Also used : TradeOfferListMutator(org.spongepowered.api.item.merchant.TradeOfferListMutator) SpongeProfession(org.spongepowered.common.entity.SpongeProfession) ImmutableList(com.google.common.collect.ImmutableList) VillagerRegistry(org.spongepowered.api.item.merchant.VillagerRegistry) EntityVillager(net.minecraft.entity.passive.EntityVillager) SpongeCareer(org.spongepowered.common.entity.SpongeCareer) Career(org.spongepowered.api.data.type.Career) SpongeCareer(org.spongepowered.common.entity.SpongeCareer)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 EntityVillager (net.minecraft.entity.passive.EntityVillager)1 Career (org.spongepowered.api.data.type.Career)1 TradeOfferListMutator (org.spongepowered.api.item.merchant.TradeOfferListMutator)1 VillagerRegistry (org.spongepowered.api.item.merchant.VillagerRegistry)1 SpongeCareer (org.spongepowered.common.entity.SpongeCareer)1 SpongeProfession (org.spongepowered.common.entity.SpongeProfession)1