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