Skip to content

Commit

Permalink
Removed unnecessary sided-create supplier method
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed Apr 25, 2023
1 parent ff74ca9 commit c81e3e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.cstav.genshinstrument.client.config.enumType.label;

import static com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier.create;

import com.cstav.genshinstrument.client.gui.screens.instrument.drum.DrumNoteButton;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel;
Expand All @@ -14,15 +12,15 @@

@OnlyIn(Dist.CLIENT)
public enum DrumNoteLabel implements INoteLabel {
DON_KA(create(() -> (note) ->
DON_KA((note) ->
Component.translatable(dn(note).btnType.getTransKey())
)),
KEYBOARD_LAYOUT(create(() -> (note) -> {
),
KEYBOARD_LAYOUT((note) -> {
final DrumNoteButton dnb = dn(note);
final DrumKeys keys = dnb.btnType.getKeys();

return INoteLabel.upperComponent((dnb.isRight ? keys.right : keys.left).getDisplayName());
})),
}),
NONE(NoteLabelSupplier.EMPTY);


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.cstav.genshinstrument.client.config.enumType.label;

import static com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier.create;

import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteGridButton;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.AbsGridLabels;
Expand All @@ -17,19 +15,19 @@
* an instance of {@code NoteGridButton}.
*/
public enum NoteGridLabel implements INoteLabel {
KEYBOARD_LAYOUT(create(() -> (note) -> INoteLabel.upperComponent(
KEYBOARD_LAYOUT((note) -> INoteLabel.upperComponent(
KeyMappings.GRID_INSTRUMENT_MAPPINGS[ng(note).column][ng(note).row].getDisplayName()
))),
DO_RE_MI(create(() -> (note) -> Component.translatable(
)),
DO_RE_MI((note) -> Component.translatable(
INoteLabel.TRANSLATABLE_PATH + AbsGridLabels.DO_RE_MI[ng(note).row % ng(note).maxRows]
))),
ABC(create(() -> (note) -> Component.literal(
)),
ABC((note) -> Component.literal(
(
(ng(note).column == 0) ? "A" :
(ng(note).column == 1) ? "B" :
"C"
) + (ng(note).row + 1)
))),
)),
NONE(NoteLabelSupplier.EMPTY);


Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
package com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label;

import java.util.function.Supplier;

import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton;

import net.minecraft.network.chat.Component;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.loading.FMLEnvironment;

@OnlyIn(Dist.CLIENT)
@FunctionalInterface
public interface NoteLabelSupplier {
public static final NoteLabelSupplier EMPTY = create(() -> (note) -> Component.empty());

/**
* Creates a new common-sided NoteLabelSupplier.
* Its result will always return null if {@link FMLEnvironment#dist} is not set to {@link Dist#CLIENT}.
* @param sup A supplier that holds the label supplier
*/
public static NoteLabelSupplier create(final Supplier<NoteLabelSupplier> sup) {
return (FMLEnvironment.dist == Dist.CLIENT)
? (note) -> sup.get().get(note)
: null
;
}
public static final NoteLabelSupplier EMPTY = (note) -> Component.empty();

public Component get(final NoteButton note);
}

0 comments on commit c81e3e2

Please sign in to comment.