Search in sources :

Example 26 with Tuple

use of com.minecolonies.api.util.Tuple in project minecolonies by Minecolonies.

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 27 with Tuple

use of com.minecolonies.api.util.Tuple in project minecolonies by ldtteam.

the class AbstractWindowWorkerModuleBuilding method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    final List<Tuple<String, Integer>> workers = new ArrayList<>();
    for (final WorkerBuildingModuleView module : buildingView.getModuleViews(WorkerBuildingModuleView.class)) {
        for (final int worker : module.getAssignedCitizens()) {
            workers.add(new Tuple<>(new TranslationTextComponent(module.getJobEntry().getTranslationKey()).getString(), worker));
        }
    }
    if (findPaneByID(LIST_WORKERS) != null) {
        ScrollingList workerList = findPaneOfTypeByID(LIST_WORKERS, ScrollingList.class);
        workerList.setDataProvider(new ScrollingList.DataProvider() {

            @Override
            public int getElementCount() {
                return workers.size();
            }

            @Override
            public void updateElement(final int index, @NotNull final Pane rowPane) {
                final ICitizenDataView worker = building.getColony().getCitizen(workers.get(index).getB());
                if (worker != null) {
                    rowPane.findPaneOfTypeByID(LABEL_WORKERNAME, Text.class).setText(new TranslationTextComponent(workers.get(index).getA()).getString() + ": " + worker.getName());
                }
            }
        });
    }
    updatePriorityLabel();
}
Also used : ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) Tuple(com.minecolonies.api.util.Tuple)

Example 28 with Tuple

use of com.minecolonies.api.util.Tuple in project minecolonies by ldtteam.

the class EntityAIWorkPlanter method decide.

@Override
protected IAIState decide() {
    final IAIState nextState = super.decide();
    if (nextState != START_WORKING && nextState != IDLE) {
        return nextState;
    }
    final BuildingPlantation plantation = getOwnBuilding();
    final List<BlockPos> list = plantation.getPosForPhase();
    for (final BlockPos pos : list) {
        if (isAtLeastThreeHigh(pos)) {
            this.workPos = pos;
            return PLANTATION_FARM;
        }
    }
    final Item current = plantation.nextPlantPhase();
    final int plantInBuilding = InventoryUtils.getCountFromBuilding(getOwnBuilding(), itemStack -> itemStack.sameItem(new ItemStack(current)));
    final int plantInInv = InventoryUtils.getItemCountInItemHandler((worker.getInventoryCitizen()), itemStack -> itemStack.sameItem(new ItemStack(current)));
    if (plantInBuilding + plantInInv <= 0) {
        requestPlantable(current);
        return START_WORKING;
    }
    if (plantInInv == 0 && plantInBuilding > 0) {
        needsCurrently = new Tuple<>(itemStack -> itemStack.sameItem(new ItemStack(current)), Math.min(plantInBuilding, PLANT_TO_REQUEST));
        return GATHERING_REQUIRED_MATERIALS;
    }
    for (final BlockPos pos : list) {
        if (world.getBlockState(pos.above()).getBlock() instanceof AirBlock) {
            this.workPos = pos;
            return PLANTATION_PLANT;
        }
    }
    return START_WORKING;
}
Also used : BuildingPlantation(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingPlantation) JobPlanter(com.minecolonies.coremod.colony.jobs.JobPlanter) TICKS_20(com.minecolonies.api.util.constant.CitizenConstants.TICKS_20) BuildingPlantation(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingPlantation) Item(net.minecraft.item.Item) AirBlock(net.minecraft.block.AirBlock) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockPos(net.minecraft.util.math.BlockPos) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) Tuple(com.minecolonies.api.util.Tuple) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) BlockUtils(com.ldtteam.structurize.util.BlockUtils) InventoryUtils(com.minecolonies.api.util.InventoryUtils) AbstractEntityAICrafting(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAICrafting) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) ItemEntity(net.minecraft.entity.item.ItemEntity) NotNull(org.jetbrains.annotations.NotNull) Stack(com.minecolonies.api.colony.requestsystem.requestable.Stack) Item(net.minecraft.item.Item) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) AirBlock(net.minecraft.block.AirBlock) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 29 with Tuple

use of com.minecolonies.api.util.Tuple in project minecolonies by ldtteam.

the class SpecialAssignmentModuleWindow method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    final List<Tuple<String, Integer>> workers = new ArrayList<>();
    for (final IAssignmentModuleView module : buildingView.getModuleViews(IAssignmentModuleView.class)) {
        for (final int worker : module.getAssignedCitizens()) {
            workers.add(new Tuple<>(new TranslationTextComponent(module.getJobEntry().getTranslationKey()).getString(), worker));
        }
    }
    if (findPaneByID(LIST_WORKERS) != null) {
        ScrollingList workerList = findPaneOfTypeByID(LIST_WORKERS, ScrollingList.class);
        workerList.setDataProvider(new ScrollingList.DataProvider() {

            @Override
            public int getElementCount() {
                return workers.size();
            }

            @Override
            public void updateElement(final int index, @NotNull final Pane rowPane) {
                final ICitizenDataView worker = buildingView.getColony().getCitizen(workers.get(index).getB());
                if (worker != null) {
                    rowPane.findPaneOfTypeByID(LABEL_WORKERNAME, Text.class).setText(new TranslationTextComponent(workers.get(index).getA()).getString() + ": " + worker.getName());
                }
            }
        });
    }
}
Also used : IAssignmentModuleView(com.minecolonies.api.colony.buildings.modules.IAssignmentModuleView) ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) Tuple(com.minecolonies.api.util.Tuple)

Example 30 with Tuple

use of com.minecolonies.api.util.Tuple 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)

Aggregations

Tuple (com.minecolonies.api.util.Tuple)34 BlockPos (net.minecraft.util.math.BlockPos)22 ItemStack (net.minecraft.item.ItemStack)20 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)20 NotNull (org.jetbrains.annotations.NotNull)18 IAIState (com.minecolonies.api.entity.ai.statemachine.states.IAIState)14 AIWorkerState (com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState)12 InventoryUtils (com.minecolonies.api.util.InventoryUtils)12 ItemStackUtils (com.minecolonies.api.util.ItemStackUtils)12 ItemStorage (com.minecolonies.api.crafting.ItemStorage)10 AITarget (com.minecolonies.api.entity.ai.statemachine.AITarget)10 ArrayList (java.util.ArrayList)10 List (java.util.List)10 Predicate (java.util.function.Predicate)10 Hand (net.minecraft.util.Hand)10 TypeToken (com.google.common.reflect.TypeToken)8 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)8 ChatPriority (com.minecolonies.api.colony.interactionhandling.ChatPriority)8 RequestState (com.minecolonies.api.colony.requestsystem.request.RequestState)8 StackList (com.minecolonies.api.colony.requestsystem.requestable.StackList)8