Search in sources :

Example 26 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.

the class PrivateWorkerCraftingRequestResolverFactory method deserialize.

@Override
public PrivateWorkerCraftingRequestResolver deserialize(IFactoryController controller, PacketBuffer buffer) throws Throwable {
    final IToken<?> token = controller.deserialize(buffer);
    final ILocation location = controller.deserialize(buffer);
    final JobEntry entry = buffer.readRegistryId();
    return new PrivateWorkerCraftingRequestResolver(location, token, entry);
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) PrivateWorkerCraftingRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PrivateWorkerCraftingRequestResolver)

Example 27 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.

the class PublicWorkerCraftingProductionResolverFactory method deserialize.

@NotNull
@Override
public PublicWorkerCraftingProductionResolver deserialize(@NotNull final IFactoryController controller, @NotNull final CompoundNBT nbt) {
    final IToken<?> token = controller.deserialize(nbt.getCompound(NBT_TOKEN));
    final ILocation location = controller.deserialize(nbt.getCompound(NBT_LOCATION));
    final JobEntry entry = IJobRegistry.getInstance().getValue(new ResourceLocation(nbt.getString(NBT_JOB)));
    return new PublicWorkerCraftingProductionResolver(location, token, entry);
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) PublicWorkerCraftingProductionResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingProductionResolver) ResourceLocation(net.minecraft.util.ResourceLocation) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by ldtteam.

the class ICraftingBuildingModule method getUid.

/**
 * Gets a unique identifier for this crafting module, based on
 * the job and disambiguation suffix.  May be null where there
 * was no job.
 * @return The unique id or null.
 */
@Nullable
default ResourceLocation getUid() {
    final IJob<?> job = getCraftingJob();
    if (job == null)
        return null;
    final JobEntry entry = job.getJobRegistryEntry();
    return getUid(entry, getId());
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) Nullable(org.jetbrains.annotations.Nullable)

Example 29 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by ldtteam.

the class ModSoundEvents method registerSounds.

/**
 * Register the {@link SoundEvent}s.
 *
 * @param registry the registry to register at.
 */
public static void registerSounds(final IForgeRegistry<SoundEvent> registry) {
    for (final JobEntry job : IJobRegistry.getInstance().getValues()) {
        if (job.getRegistryName().getNamespace().equals(Constants.MOD_ID) && !job.getRegistryName().getPath().equals("placeholder")) {
            final Map<EventType, Tuple<SoundEvent, SoundEvent>> map = new HashMap<>();
            for (final EventType soundEvents : EventType.values()) {
                final SoundEvent maleSoundEvent = ModSoundEvents.getSoundID("mob." + job.getRegistryName().getPath() + ".male." + soundEvents.name().toLowerCase(Locale.US));
                final SoundEvent femaleSoundEvent = ModSoundEvents.getSoundID("mob." + job.getRegistryName().getPath() + ".female." + soundEvents.name().toLowerCase(Locale.US));
                registry.register(maleSoundEvent);
                registry.register(femaleSoundEvent);
                map.put(soundEvents, new Tuple<>(maleSoundEvent, femaleSoundEvent));
            }
            CITIZEN_SOUND_EVENTS.put(job.getRegistryName().getPath(), map);
        }
    }
    final Map<EventType, Tuple<SoundEvent, SoundEvent>> citizenMap = new HashMap<>();
    for (final EventType soundEvents : EventType.values()) {
        final SoundEvent maleSoundEvent = ModSoundEvents.getSoundID("mob.citizen.male." + soundEvents.name().toLowerCase(Locale.US));
        final SoundEvent femaleSoundEvent = ModSoundEvents.getSoundID("mob.citizen.female." + soundEvents.name().toLowerCase(Locale.US));
        registry.register(maleSoundEvent);
        registry.register(femaleSoundEvent);
        citizenMap.put(soundEvents, new Tuple<>(maleSoundEvent, femaleSoundEvent));
    }
    CITIZEN_SOUND_EVENTS.put("citizen", citizenMap);
    final Map<EventType, Tuple<SoundEvent, SoundEvent>> childMap = new HashMap<>();
    for (final EventType soundEvents : EventType.values()) {
        final SoundEvent maleSoundEvent = ModSoundEvents.getSoundID("mob.child.male." + soundEvents.name().toLowerCase(Locale.US));
        final SoundEvent femaleSoundEvent = ModSoundEvents.getSoundID("mob.child.female." + soundEvents.name().toLowerCase(Locale.US));
        registry.register(maleSoundEvent);
        registry.register(femaleSoundEvent);
        childMap.put(soundEvents, new Tuple<>(maleSoundEvent, femaleSoundEvent));
    }
    CITIZEN_SOUND_EVENTS.put("child", childMap);
    registry.register(TavernSounds.tavernTheme);
    for (final RaiderType raiderType : RaiderType.values()) {
        final SoundEvent raiderHurt = ModSoundEvents.getSoundID("mob." + raiderType.name().toLowerCase(Locale.US) + ".hurt");
        final SoundEvent raiderDeath = ModSoundEvents.getSoundID("mob." + raiderType.name().toLowerCase(Locale.US) + ".death");
        final SoundEvent raiderSay = ModSoundEvents.getSoundID("mob." + raiderType.name().toLowerCase(Locale.US) + ".say");
        registry.register(raiderHurt);
        registry.register(raiderDeath);
        registry.register(raiderSay);
        final Map<RaiderSounds.RaiderSoundTypes, SoundEvent> sounds = new HashMap<>();
        sounds.put(RaiderSounds.RaiderSoundTypes.HURT, raiderHurt);
        sounds.put(RaiderSounds.RaiderSoundTypes.DEATH, raiderDeath);
        sounds.put(RaiderSounds.RaiderSoundTypes.SAY, raiderSay);
        RaiderSounds.raiderSounds.put(raiderType, sounds);
    }
    registry.register(RaidSounds.WARNING);
    registry.register(RaidSounds.WARNING_EARLY);
    registry.register(RaidSounds.VICTORY);
    registry.register(RaidSounds.VICTORY_EARLY);
    registry.register(RaidSounds.AMAZON_RAID);
    registry.register(RaidSounds.DESERT_RAID);
    registry.register(RaidSounds.DESERT_RAID_WARNING);
    registry.register(MercenarySounds.mercenaryAttack);
    registry.register(MercenarySounds.mercenaryCelebrate);
    registry.register(MercenarySounds.mercenaryDie);
    registry.register(MercenarySounds.mercenaryHurt);
    registry.register(MercenarySounds.mercenarySay);
    registry.register(MercenarySounds.mercenaryStep);
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) SoundEvent(net.minecraft.util.SoundEvent) HashMap(java.util.HashMap) RaiderType(com.minecolonies.api.entity.mobs.RaiderType) Tuple(com.minecolonies.api.util.Tuple)

Example 30 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by ldtteam.

the class AbstractCraftingBuildingModule method fullFillRecipe.

@Override
public boolean fullFillRecipe(final IRecipeStorage storage) {
    final List<IItemHandler> handlers = building.getHandlers();
    final ICitizenData data = building.getModuleMatching(WorkerBuildingModule.class, m -> m.getJobEntry() == jobEntry).getFirstCitizen();
    if (data == null || !data.getEntity().isPresent()) {
        // we shouldn't hit this case, but just in case...
        return storage.fullfillRecipe(building.getColony().getWorld(), handlers);
    }
    final AbstractEntityCitizen worker = data.getEntity().get();
    final int primarySkill = worker.getCitizenData().getCitizenSkillHandler().getLevel(building.getModuleMatching(WorkerBuildingModule.class, m -> m.getJobEntry() == jobEntry).getPrimarySkill());
    final int luck = (int) (((primarySkill + 1) * 2) - Math.pow((primarySkill + 1) / 10.0, 2));
    LootContext.Builder builder = (new LootContext.Builder((ServerWorld) building.getColony().getWorld()).withParameter(LootParameters.ORIGIN, worker.position()).withParameter(LootParameters.THIS_ENTITY, worker).withParameter(LootParameters.TOOL, worker.getMainHandItem()).withRandom(worker.getRandom()).withLuck((float) luck));
    return storage.fullfillRecipe(builder.create(RecipeStorage.recipeLootParameters), handlers);
}
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) IItemHandler(net.minecraftforge.items.IItemHandler) LootContext(net.minecraft.loot.LootContext) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) ICitizenData(com.minecolonies.api.colony.ICitizenData)

Aggregations

JobEntry (com.minecolonies.api.colony.jobs.registry.JobEntry)37 ResourceLocation (net.minecraft.util.ResourceLocation)18 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)16 NotNull (org.jetbrains.annotations.NotNull)13 Nullable (org.jetbrains.annotations.Nullable)7 PublicWorkerCraftingRequestResolver (com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingRequestResolver)6 ICitizenData (com.minecolonies.api.colony.ICitizenData)5 IColony (com.minecolonies.api.colony.IColony)5 PublicWorkerCraftingProductionResolver (com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingProductionResolver)5 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)4 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)3 RaiderType (com.minecolonies.api.entity.mobs.RaiderType)3 PrivateWorkerCraftingRequestResolver (com.minecolonies.coremod.colony.requestsystem.resolvers.PrivateWorkerCraftingRequestResolver)3 PacketBuffer (net.minecraft.network.PacketBuffer)3 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 BuildingEntry (com.minecolonies.api.colony.buildings.registry.BuildingEntry)2 IWareHouse (com.minecolonies.api.colony.buildings.workerbuildings.IWareHouse)2