Skip to content

Commit

Permalink
Merge branch 'dev' into 1.20-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed Aug 6, 2023
2 parents 3d7dfff + e444e29 commit 89567cd
Show file tree
Hide file tree
Showing 23 changed files with 128 additions and 228 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mod_name=Genshin Instruments
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=CC-BY-NC 4.0
# The mod version. See https://semver.org/
mod_version=3.2.1
mod_version=3.2.3
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public static void register(final IEventBus bus) {
BETS.register(bus);
}

// //TODO remove after tests
// public static final RegistryObject<BlockEntityType<InstrumentBlockEntity>> INSTRUMENT_BE = BETS.register("instrument_be", () ->
// BlockEntityType.Builder.of((pos, state) -> new InstrumentBlockEntity(pos, state), ModBlocks.LYRE_BLOCK.get())
// .build(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.cstav.genshinstrument.client.ModArmPose;
import com.cstav.genshinstrument.networking.ModPacketHandler;
import com.cstav.genshinstrument.networking.OpenInstrumentPacketSender;
import com.cstav.genshinstrument.networking.packet.instrument.NotifyInstrumentClosedPacket;
import com.cstav.genshinstrument.networking.packet.instrument.NotifyInstrumentOpenPacket;
import com.cstav.genshinstrument.util.ServerUtil;

import net.minecraft.client.model.HumanoidModel.ArmPose;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState
for (final Player player : pLevel.players()) {
ibe.users.forEach((user) -> {
InstrumentOpenProvider.setClosed(pLevel.getPlayerByUUID(user));
ModPacketHandler.sendToClient(new NotifyInstrumentClosedPacket(user), (ServerPlayer)player);
ModPacketHandler.sendToClient(new NotifyInstrumentOpenPacket(user, false), (ServerPlayer)player);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ModClientConfigs {


PITCH = configBuilder.defineInRange("instrument_pitch",
1, NoteSound.MIN_PITCH, NoteSound.MAX_PITCH
0, 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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum NoteGridLabel implements INoteLabel {
).append(LabelUtil.getCutNoteName(ng(note)).substring(1))
),
ABC_1((note) -> Component.literal(
LabelUtil.ABC[ng(note).row]+"" + (gs(note).columns() - ng(note).column)
String.valueOf(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 @@ -11,7 +11,6 @@
import com.cstav.genshinstrument.client.gui.screens.instrument.GenshinConsentScreen;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton;
import com.cstav.genshinstrument.client.gui.screens.options.instrument.AbstractInstrumentOptionsScreen;
import com.cstav.genshinstrument.item.InstrumentItem;
import com.cstav.genshinstrument.networking.ModPacketHandler;
import com.cstav.genshinstrument.networking.buttonidentifier.NoteButtonIdentifier;
import com.cstav.genshinstrument.networking.packet.instrument.CloseInstrumentPacket;
Expand All @@ -27,7 +26,6 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -37,15 +35,15 @@ public abstract class AbstractInstrumentScreen extends Screen {

@SuppressWarnings("resource")
public int getNoteSize() {
final int guiScale = Minecraft.getInstance().options.guiScale().get();

return switch (guiScale) {
case 0 -> 40;
case 1 -> 35;
return switch (Minecraft.getInstance().options.guiScale().get()) {
case 1 -> 36;
case 2 -> 46;
case 3 -> 48;
case 4 -> 41;
default -> guiScale * 18;
case 4 -> 40;
case 5 -> 35;
case 6 -> 30;

default -> 35;
};
}

Expand Down Expand Up @@ -114,25 +112,9 @@ public boolean isGenshinInstrument() {
* or, if it is an item, if the item has been ripped out of the player's hands.
* @return Whether the instrument has closed as a result of this method
*/
public boolean handleAbruptClosing() {
final Player player = minecraft.player;

if (!InstrumentOpenProvider.isOpen(player)) {
public void handleAbruptClosing() {
if (!InstrumentOpenProvider.isOpen(minecraft.player))
onClose(false);
return true;
}

// Handle item not in hand seperately
// This is done like so because there is no event (that I know of) for when an item is moved/removed
if (
(InstrumentOpenProvider.isItem(player) && interactionHand.isPresent())
&& !(player.getItemInHand(interactionHand.get()).getItem() instanceof InstrumentItem)
) {
onClose(true);
return true;
}

return false;
}


Expand Down Expand Up @@ -168,7 +150,9 @@ public static ResourceLocation getInternalResourceFromGlob(final String path) {
return new ResourceLocation(GInstrumentMod.MODID, getGlobalRootPath() + path);
}
/**
* Shorthand for {@code getRootPath() + getInstrumentId()}
* Gets the resource path under this instrument.
* It will usually be {@code textures/gui/instrument/<instrument>/}.
* {@code instrument} is as specified by {@link AbstractInstrumentScreen#getSourcePath getSourcePath}.
*/
protected String getPath() {
return getGlobalRootPath() + getSourcePath().getPath() + "/";
Expand All @@ -177,7 +161,7 @@ protected String getPath() {
/**
* Override this method if you want to reference another directory for resources
*/
protected ResourceLocation getSourcePath() {
public ResourceLocation getSourcePath() {
return getInstrumentId();
}

Expand Down Expand Up @@ -300,6 +284,7 @@ public void onClose() {
onClose(true);
}
public void onClose(final boolean notify) {
// This should always be false after the above move to server todo is implemented
if (notify) {
InstrumentOpenProvider.setClosed(minecraft.player);
ModPacketHandler.sendToServer(new CloseInstrumentPacket());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public NoteButtonIdentifier getIdentifier() {
protected abstract NoteButtonRenderer initNoteRenderer();


public NoteButton(NoteSound sound,
NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen, int pitch) {
public NoteButton(NoteSound sound, NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen,
int pitch) {

super(0, 0, 42, 42, Component.empty());

Expand All @@ -62,9 +62,7 @@ public NoteButton(NoteSound sound,
this.instrumentScreen = instrumentScreen;
this.pitch = pitch;
}
public NoteButton(NoteSound sound,
NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen) {

public NoteButton(NoteSound sound, NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen) {
this(sound, labelSupplier, instrumentScreen, instrumentScreen.getPitch());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public NoteGrid(NoteSound[] noteSounds, AbstractGridInstrumentScreen instrumentS
}

/**
* Creates a note with for a singular sound type instrument
* Creates a note for a singular sound type instrument
*/
protected NoteButton createNote(int row, int column, int pitch) {
return new NoteGridButton(row, column,
Expand Down

This file was deleted.

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

import com.cstav.genshinstrument.client.config.ModClientConfigs;
import com.cstav.genshinstrument.client.config.enumType.InstrumentChannelType;
import com.cstav.genshinstrument.client.config.enumType.label.NoteGridLabel;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractInstrumentScreen;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel;
Expand Down Expand Up @@ -83,7 +82,7 @@ protected int getButtonHeight() {
public final boolean isOverlay;

protected final @Nullable INoteLabel[] labels;
protected final @Nullable INoteLabel currLabel;
protected @Nullable INoteLabel currLabel;

/**
* Override to {@code false} tp disable the pitch slider from the options.
Expand All @@ -104,7 +103,6 @@ public AbstractInstrumentOptionsScreen(@Nullable AbstractInstrumentScreen screen
lastScreen = null;

labels = getLabels();
currLabel = getCurrentLabel();
}
public AbstractInstrumentOptionsScreen(final Screen lastScreen) {
super(Component.translatable("button.genshinstrument.instrumentOptions"));
Expand All @@ -113,13 +111,12 @@ public AbstractInstrumentOptionsScreen(final Screen lastScreen) {
this.instrumentScreen = null;
this.lastScreen = lastScreen;

// Default to NoteGridLabel's values
labels = NoteGridLabel.values();
currLabel = ModClientConfigs.GRID_LABEL_TYPE.get();
labels = getLabels();
}

@Override
protected void init() {
currLabel = getCurrentLabel();

final GridLayout grid = new GridLayout();
grid.defaultCellSetting()
Expand Down Expand Up @@ -224,14 +221,14 @@ protected void initVisualsSection(final GridLayout grid, final RowHelper rowHelp
);
rowHelper.addChild(sharedInstrument);

final CycleButton<Boolean> accurateAccidentals = CycleButton.booleanBuilder(CommonComponents.OPTION_ON, CommonComponents.OPTION_OFF)
final CycleButton<Boolean> accurateNotes = CycleButton.booleanBuilder(CommonComponents.OPTION_ON, CommonComponents.OPTION_OFF)
.withInitialValue(ModClientConfigs.ACCURATE_NOTES.get())
.withTooltip((value) -> Tooltip.create(Component.translatable("button.genshinstrument.accurate_notes.tooltip")))
.create(0, 0,
getSmallButtonWidth(), getButtonHeight(),
Component.translatable("button.genshinstrument.accurate_notes"), this::onAccurateAccidentalsChanged
Component.translatable("button.genshinstrument.accurate_notes"), this::onAccurateNotesChanged
);
rowHelper.addChild(accurateAccidentals);
rowHelper.addChild(accurateNotes);


if (labels != null) {
Expand Down Expand Up @@ -300,7 +297,7 @@ protected void onEmitRingChanged(final CycleButton<Boolean> button, final boolea
protected void onSharedInstrumentChanged(final CycleButton<Boolean> button, final boolean value) {
ModClientConfigs.SHARED_INSTRUMENT.set(value);
}
protected void onAccurateAccidentalsChanged(final CycleButton<Boolean> button, final boolean value) {
protected void onAccurateNotesChanged(final CycleButton<Boolean> button, final boolean value) {
ModClientConfigs.ACCURATE_NOTES.set(value);

if (isOverlay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ protected void saveLabel(final INoteLabel newLabel) {

@Override
public boolean isPitchSliderEnabled() {
return !((AbstractGridInstrumentScreen)instrumentScreen).isSSTI();
return (instrumentScreen == null) ||
!((AbstractGridInstrumentScreen)instrumentScreen).isSSTI();
}


Expand Down
Loading

0 comments on commit 89567cd

Please sign in to comment.