Skip to content

Commit

Permalink
Merge branch 'dev' into 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed Jul 22, 2023
2 parents 8238bf2 + ee5fcc4 commit 95e228f
Show file tree
Hide file tree
Showing 24 changed files with 453 additions and 391 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ parchment_mappings=1.20.1:2023.07.02
loader_version=0.14.21

# Mod Properties
mod_version=3.0
mod_version=3.1
maven_group=com.cstav.genshinstrument
archives_base_name=genshinstrument

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.Builder;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
import net.minecraftforge.common.ForgeConfigSpec.EnumValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;

@Environment(EnvType.CLIENT)
public class ModClientConfigs {
public static final ForgeConfigSpec CONFIGS;

public static final DoubleValue PITCH;
public static final IntValue PITCH;
public static final EnumValue<NoteGridLabel> GRID_LABEL_TYPE;
public static final EnumValue<InstrumentChannelType> CHANNEL_TYPE;
public static final BooleanValue STOP_MUSIC_ON_PLAY, EMIT_RING_ANIMATION, SHARED_INSTRUMENT,
Expand All @@ -33,7 +33,7 @@ public class ModClientConfigs {


PITCH = configBuilder.defineInRange("instrument_pitch",
1, doubleMe(NoteSound.MIN_PITCH), doubleMe(NoteSound.MAX_PITCH)
1, NoteSound.MIN_PITCH, NoteSound.MAX_PITCH
);
GRID_LABEL_TYPE = configBuilder.defineEnum("label_type", NoteGridLabel.KEYBOARD_LAYOUT);
CHANNEL_TYPE = configBuilder.defineEnum("channel_type", InstrumentChannelType.MIXED);
Expand All @@ -56,8 +56,4 @@ public class ModClientConfigs {

CONFIGS = configBuilder.build();
}

private static double doubleMe(final float num) {
return Double.valueOf(Float.toString(num));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractGridInstrumentScreen;
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;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier;
import com.cstav.genshinstrument.client.keyMaps.KeyMappings;
import com.cstav.genshinstrument.util.LabelUtil;

import net.minecraft.network.chat.Component;

Expand All @@ -20,15 +20,15 @@ public enum NoteGridLabel implements INoteLabel {
KeyMappings.GRID_INSTRUMENT_MAPPINGS[ng(note).column][ng(note).row].getDisplayName()
)),
NOTE_NAME((note) -> Component.literal(
AbsGridLabels.getCutNoteName(ng(note))
LabelUtil.getCutNoteName(ng(note))
)),
DO_RE_MI((note) ->
Component.translatable(
INoteLabel.TRANSLATABLE_PATH + AbsGridLabels.DO_RE_MI[ng(note).row % gs(note).rows()]
).append(AbsGridLabels.getCutNoteName(ng(note)).substring(1))
INoteLabel.TRANSLATABLE_PATH + LabelUtil.DO_RE_MI[ng(note).row % gs(note).rows()]
).append(LabelUtil.getCutNoteName(ng(note)).substring(1))
),
ABC_1((note) -> Component.literal(
AbsGridLabels.ABC[ng(note).row] + (gs(note).columns() - ng(note).column)
LabelUtil.ABC[ng(note).row] + (gs(note).columns() - ng(note).column)
)),
ABC_2((note) -> Component.literal(
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cstav.genshinstrument.client.config.ModClientConfigs;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButtonRenderer;
import com.cstav.genshinstrument.networking.buttonidentifier.DrumNoteIdentifier;

import net.fabricmc.api.EnvType;
Expand All @@ -17,9 +18,7 @@ public DrumNoteButton(DrumButtonType btnType, boolean isRight, AratakisGreatAndG
super(
btnType.getSound(),
ModClientConfigs.DRUM_LABEL_TYPE.get().getLabelSupplier(),
btnType.getIndex(), 2,

drumScreen, 13, .34f, 1.01f
drumScreen
);

this.btnType = btnType;
Expand All @@ -31,5 +30,14 @@ public DrumNoteButton(DrumButtonType btnType, boolean isRight, AratakisGreatAndG
public DrumNoteIdentifier getIdentifier() {
return new DrumNoteIdentifier(this);
}


@Override
protected NoteButtonRenderer initNoteRenderer() {
return new NoteButtonRenderer(this,
btnType.getIndex(), 2,
13, .34f, 1.01f
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional;

import com.cstav.genshinstrument.client.config.ModClientConfigs;
import com.cstav.genshinstrument.client.gui.screens.instrument.GenshinConsentScreen;
Expand All @@ -17,7 +18,7 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
Expand All @@ -34,11 +35,11 @@ public abstract class AbstractInstrumentScreen extends Screen {
/**
* The set pitch of all note buttons in this screen
*/
private float pitch = ModClientConfigs.PITCH.get().floatValue();
public float getPitch() {
private int pitch = ModClientConfigs.PITCH.get().intValue();
public int getPitch() {
return pitch;
}
public void setPitch(float pitch) {
public void setPitch(int pitch) {
this.pitch = NoteSound.clampPitch(pitch);
}

Expand Down Expand Up @@ -146,14 +147,13 @@ public ResourceLocation getResourceFromRoot(final String path) {
}


protected final AbstractInstrumentOptionsScreen optionsScreen = initInstrumentOptionsScreen();
public final AbstractInstrumentOptionsScreen optionsScreen = initInstrumentOptionsScreen();

public final InteractionHand interactionHand;
public AbstractInstrumentScreen(final InteractionHand hand) {
super(CommonComponents.EMPTY);

interactionHand = hand;
optionsScreen.setOnCloseRunnable(this::onOptionsClose);
}


Expand Down Expand Up @@ -194,8 +194,7 @@ public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
return true;
}

return ioa() ? optionsScreen.keyPressed(pKeyCode, pScanCode, pModifiers)
: super.keyPressed(pKeyCode, pScanCode, pModifiers);
return super.keyPressed(pKeyCode, pScanCode, pModifiers);
}
@Override
public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) {
Expand All @@ -205,15 +204,11 @@ public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) {
if (note != null)
note.locked = false;

return ioa() ? optionsScreen.keyReleased(pKeyCode, pScanCode, pModifiers)
: super.keyReleased(pKeyCode, pScanCode, pModifiers);
return super.keyReleased(pKeyCode, pScanCode, pModifiers);
}

@Override
public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) {
if (ioa())
return optionsScreen.mouseReleased(pMouseX, pMouseY, pButton);

unlockFocused();

return super.mouseReleased(pMouseX, pMouseY, pButton);
Expand All @@ -232,66 +227,38 @@ private void unlockFocused() {
((NoteButton)getFocused()).locked = false;
}


//#region Making the options screen function
private boolean isOptionsActive = false;

@Override
public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) {
super.render(gui, pMouseX, pMouseY, pPartialTick);
if (ioa())
optionsScreen.render(gui, pMouseX, pMouseY, pPartialTick);
}

protected void onOptionsOpen() {
isOptionsActive = true;
public void onOptionsOpen() {
setFocused(null);
minecraft.setScreen(optionsScreen);
}
protected void onOptionsClose() {
isOptionsActive = false;
public void onOptionsClose() {
minecraft.setScreen(this);
}


@Override
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) {
return ioa() ? optionsScreen.mouseClicked(pMouseX, pMouseY, pButton)
: super.mouseClicked(pMouseX, pMouseY, pButton);
}
@Override
public boolean mouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY) {
return ioa() ? optionsScreen.mouseDragged(pMouseX, pMouseY, pButton, pDragX, pDragY)
: super.mouseDragged(pMouseX, pMouseY, pButton, pDragX, pDragY);
}
@Override
public void mouseMoved(double pMouseX, double pMouseY) {
if (ioa())
optionsScreen.mouseMoved(pMouseX, pMouseY);
else
super.mouseMoved(pMouseX, pMouseY);
}
@Override
public boolean mouseScrolled(double pMouseX, double pMouseY, double pDelta) {
return ioa() ? optionsScreen.mouseScrolled(pMouseX, pMouseY, pDelta)
: super.mouseScrolled(pMouseX, pMouseY, pDelta);
public void onClose() {
ModEntityData.setInstrumentOpen(minecraft.player, false);
ModPacketHandler.sendToServer(new CloseInstrumentPacket());

super.onClose();
}


/**
* Shorthand for {@link AbstractInstrumentScreen#isOptionsActive isOptionsActive}.
* @return The current instrument screen, if present
*/
private boolean ioa() {
return isOptionsActive;
}

//#endregion


@Override
public void onClose() {
ModEntityData.setInstrumentOpen(minecraft.player, false);
ModPacketHandler.sendToServer(new CloseInstrumentPacket());
public static Optional<AbstractInstrumentScreen> getCurrentScreen(final Minecraft minecraft) {
if (minecraft.screen instanceof AbstractInstrumentScreen)
return Optional.of((AbstractInstrumentScreen)minecraft.screen);

if (minecraft.screen instanceof AbstractInstrumentOptionsScreen) {
final AbstractInstrumentOptionsScreen instrumentOptionsScreen = (AbstractInstrumentOptionsScreen)minecraft.screen;
if (instrumentOptionsScreen.isOverlay)
return Optional.of(instrumentOptionsScreen.instrumentScreen);
}

super.onClose();
return Optional.empty();
}


Expand Down
Loading

0 comments on commit 95e228f

Please sign in to comment.