Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed May 9, 2023
2 parents 1053a23 + 90797f4 commit 6238adf
Show file tree
Hide file tree
Showing 26 changed files with 225 additions and 124 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}

version = '2.4'
version = '2.4.1'
group = 'com.cstav.genshinstrument' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'genshinstrument-1.19.3'

Expand Down
11 changes: 6 additions & 5 deletions public/updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@

"1.19.3": {
"1.0": "Initial release",
"1.0.1": "Fixed resources folder and package names being incorrect, implemented Forge's updates mechanism",
"1.0.1": "- Fixed resources folder and package names being incorrect\n- implemented Forge's updates mechanism",

"2.0": "- New instrument: Arataki's Great and Glorious Drum!\n- Russian language support",
"2.2": "- New recipes\n- New advancements",

"2.2.1": "Texture fixes",
"2.2.1": "- Texture fixes",

"2.3": "- More texture fixes\n- Better API implementation",

"2.4": "- Minor techincal fixes"
"2.4": "- Minor techincal fixes",
"2.4.1": "- Fixed instrument screen being present after item removal\n- API tweaks & fixes"
},

"promos": {
"1.19.3-latest": "2.4",
"1.19.3-recommended": "2.4"
"1.19.3-latest": "2.4.1",
"1.19.3-recommended": "2.4.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package com.cstav.genshinstrument.capability.instrumentOpen;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.capabilities.AutoRegisterCapability;
import net.minecraftforge.common.util.LazyOptional;

@AutoRegisterCapability
public class InstrumentOpen {
public static final String NBT_KEY = "instrumentOpen";
private boolean isOpen = false;

public static boolean isOpen(final Player player) {
final LazyOptional<InstrumentOpen> oIsOpen = player.getCapability(InstrumentOpenProvider.INSTRUMENT_OPEN);
return oIsOpen.isPresent() && oIsOpen.resolve().get().isOpen;
}


public boolean isOpen() {
return isOpen;
}

public void setOpen(final boolean isOpen) {
this.isOpen = isOpen;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.client.gui.components.LinearLayoutWidget;
import net.minecraft.client.gui.components.LinearLayoutWidget.Orientation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionHand;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
Expand All @@ -28,8 +28,8 @@
public class AratakisGreatAndGloriousDrumScreen extends AbstractInstrumentScreen {
public static final String INSTRUMENT_ID = "glorious_drum";

public AratakisGreatAndGloriousDrumScreen(ItemStack instrument) {
super(instrument);
public AratakisGreatAndGloriousDrumScreen(InteractionHand hand) {
super(hand);
}

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ private LinearLayoutWidget createRow(DrumButtonType type, float widthPercent) {
return layout;
}
private NoteButton createButton(DrumButtonType btnType, LinearLayoutWidget container, Key key, boolean isRight) {
final NoteButton btn = new DrumNoteButton(instrument, btnType, isRight, this);
final NoteButton btn = new DrumNoteButton(btnType, isRight, this);

container.addChild(btn);
notes.put(key.getValue(), btn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.cstav.genshinstrument.client.config.ModClientConfigs;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton;

import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -13,9 +12,9 @@ public class DrumNoteButton extends NoteButton {
public final DrumButtonType btnType;
public final boolean isRight;

public DrumNoteButton(ItemStack drum, DrumButtonType btnType, boolean isLeft, AratakisGreatAndGloriousDrumScreen drumScreen) {
public DrumNoteButton(DrumButtonType btnType, boolean isLeft, AratakisGreatAndGloriousDrumScreen drumScreen) {
super(
drum, btnType.getSound(),
btnType.getSound(),
ModClientConfigs.DRUM_LABEL_TYPE.get().getLabelSupplier(),
btnType.getIndex(), 2,
drumScreen, 13, .34f, 1.01f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.cstav.genshinstrument.sound.NoteSound;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionHand;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
Expand All @@ -22,8 +22,8 @@
public class FloralZitherScreen extends AbstractGridInstrumentScreen {
public static final String INSTRUMENT_ID = "floral_zither";

public FloralZitherScreen(ItemStack instrument) {
super(instrument);
public FloralZitherScreen(InteractionHand hand) {
super(hand);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import com.cstav.genshinstrument.client.keyMaps.KeyMappings;

import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionHand;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public abstract class AbstractGridInstrumentScreen extends AbstractInstrumentScreen {
public static final int DEF_ROWS = 7, DEF_COLUMNS = 3;
public AbstractGridInstrumentScreen(ItemStack instrument) {
super(instrument);
public AbstractGridInstrumentScreen(InteractionHand hand) {
super(hand);
}

public int columns() {
Expand All @@ -33,7 +33,7 @@ public int rows() {
*/
public NoteGrid initNoteGrid() {
return new NoteGrid(
instrument, rows(), columns(), getSounds(), this
rows(), columns(), getSounds(), this
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionHand;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand Down Expand Up @@ -84,11 +84,11 @@ public ResourceLocation getResourceFromRoot(final String path) {

protected final AbstractInstrumentOptionsScreen optionsScreen = initInstrumentOptionsScreen();

public final ItemStack instrument;
public AbstractInstrumentScreen(final ItemStack instrument) {
public final InteractionHand interactionHand;
public AbstractInstrumentScreen(final InteractionHand hand) {
super(Component.empty());

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
Expand Down Expand Up @@ -55,7 +54,7 @@ public static int getSize() {
protected final Minecraft minecraft = Minecraft.getInstance();

public NoteSound sound;
public final ItemStack instrument;
public final AbstractInstrumentScreen instrumentScreen;

protected final int noteTextureRow, rowsInNoteTexture;
protected final Color colorTheme, pressedColorTheme;
Expand All @@ -66,7 +65,7 @@ public static int getSize() {
//FIXME Actually figure out a formula instead of guessing
private float randomAssMultiplier1 = .9f, randomAssMultiplier2 = 1.025f;

public NoteButton(ItemStack instrument, NoteSound sound,
public NoteButton(NoteSound sound,
NoteLabelSupplier labelSupplier, int noteTextureRow, int rowsInNoteTexture,
AbstractInstrumentScreen instrumentScreen) {
super(Button.builder(null, (iAmADissapointmentAndAFailureToMyParents) -> {})
Expand All @@ -75,9 +74,10 @@ public NoteButton(ItemStack instrument, NoteSound sound,


this.sound = sound;
this.instrument = instrument;

this.labelSupplier = labelSupplier;

this.instrumentScreen = instrumentScreen;
colorTheme = instrumentScreen.getThemeLoader().getNoteTheme();
pressedColorTheme = instrumentScreen.getThemeLoader().getPressedNoteTheme();

Expand All @@ -89,10 +89,10 @@ public NoteButton(ItemStack instrument, NoteSound sound,
this.noteBgLocation = getResourceFromRoot(NOTE_BG_FILENAME);

}
public NoteButton(ItemStack instrument, NoteSound sound,
public NoteButton(NoteSound sound,
NoteLabelSupplier labelSupplier, int noteTextureRow, int rowsInNoteTexture,
AbstractInstrumentScreen instrumentScreen, int noteTextureWidth, float randomAssMultiplier1, float randomAssMultiplier2) {
this(instrument, sound, labelSupplier, noteTextureRow, rowsInNoteTexture, instrumentScreen);
this(sound, labelSupplier, noteTextureRow, rowsInNoteTexture, instrumentScreen);

this.noteTextureWidth = noteTextureWidth;
this.randomAssMultiplier1 = randomAssMultiplier1;
Expand Down Expand Up @@ -247,7 +247,7 @@ public void play(final boolean playLocally) {
if (playLocally)
playDownSound(minecraft.getSoundManager());

ModPacketHandler.sendToServer(new InstrumentPacket(sound, instrument));
ModPacketHandler.sendToServer(new InstrumentPacket(sound, instrumentScreen.interactionHand));

locked = true;

Expand All @@ -272,7 +272,7 @@ public void playDownSound(SoundManager pHandler) {
* A method for packets to use for playing this note on the client's end.
* If {@link Minecraft#player this player} is the same as the gives player,
* the method will only stop the client's background music per preference.
* @param playerUUID The UUID of the player who initiated the sound
* @param playerUUID The UUID of the player who initiated the sound. Null for when it wasn't a player.
* @param pos The position at which the sound was fired from
*/
public static void playNoteAtPos(final NoteSound sound, final UUID playerUUID, final BlockPos pos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.client.gui.components.FrameWidget;
import net.minecraft.client.gui.components.GridWidget;
import net.minecraft.client.gui.components.GridWidget.RowHelper;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -30,13 +29,11 @@ public class NoteGrid implements Iterable<NoteButton> {
private NoteSound[] noteSounds;

public final int rows, columns;
public final ItemStack instrument;

public NoteGrid(ItemStack instrument, int rows, int columns, NoteSound[] noteSounds, AbstractInstrumentScreen instrumentScreen) {
public NoteGrid(int rows, int columns, NoteSound[] noteSounds, AbstractInstrumentScreen instrumentScreen) {
this.rows = rows;
this.columns = columns;
this.noteSounds = noteSounds;
this.instrument = instrument;

// Construct the note grid
notes = new NoteButton[columns][rows];
Expand All @@ -62,7 +59,7 @@ public void updatePitch() {
}

protected NoteButton createNote(int row, int column, AbstractInstrumentScreen instrumentScreen) {
return new NoteGridButton(instrument, row, column,
return new NoteGridButton(row, column,
getSoundAt(noteSounds, row, column), getLabelSupplier(), rows
, instrumentScreen);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier;
import com.cstav.genshinstrument.sound.NoteSound;

import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -14,9 +13,9 @@ public class NoteGridButton extends NoteButton {
public final int row, column,
maxRows;

public NoteGridButton(ItemStack instrument, int row, int column, NoteSound sound, NoteLabelSupplier labelSupplier, int maxRows,
public NoteGridButton(int row, int column, NoteSound sound, NoteLabelSupplier labelSupplier, int maxRows,
AbstractInstrumentScreen instrumentScreen) {
super(instrument, sound, labelSupplier, row, maxRows, instrumentScreen);
super(sound, labelSupplier, row, maxRows, instrumentScreen);


this.row = row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.cstav.genshinstrument.sound.NoteSound;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionHand;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
Expand All @@ -22,8 +22,8 @@
public class VintageLyreScreen extends AbstractGridInstrumentScreen {
public static final String INSTRUMENT_ID = "vintage_lyre";

public VintageLyreScreen(ItemStack instrument) {
super(instrument);
public VintageLyreScreen(InteractionHand hand) {
super(hand);
}


Expand Down Expand Up @@ -51,7 +51,7 @@ public NoteSound[] getSounds() {
@Override
public NoteGrid initNoteGrid() {
return new VintageNoteGrid(
instrument, rows(), columns(), getSounds(), this
rows(), columns(), getSounds(), this
);
}

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

import net.minecraft.client.gui.GuiComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand All @@ -19,10 +18,10 @@ public class VintageNoteButton extends NoteGridButton {

private final ResourceLocation thingyLocation = getResourceFromRoot("thing.png");

public VintageNoteButton(final ItemStack instrument,
int row, int column, NoteSound sound, NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen) {
public VintageNoteButton(int row, int column,
NoteSound sound, NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen) {
// We know for sure that the lyre is a 7x3
super(instrument, row, column, sound, labelSupplier, AbstractGridInstrumentScreen.DEF_ROWS, instrumentScreen);
super(row, column, sound, labelSupplier, AbstractGridInstrumentScreen.DEF_ROWS, instrumentScreen);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteGrid;
import com.cstav.genshinstrument.sound.NoteSound;

import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class VintageNoteGrid extends NoteGrid {

public VintageNoteGrid(final ItemStack vintageLyre, int rows, int columns, NoteSound[] sounds, VintageLyreScreen instrumentScreen) {
super(vintageLyre, rows, columns, sounds, instrumentScreen);
public VintageNoteGrid(int rows, int columns, NoteSound[] sounds, VintageLyreScreen instrumentScreen) {
super(rows, columns, sounds, instrumentScreen);
}

@Override
protected NoteButton createNote(int row, int column, AbstractInstrumentScreen screen) {
return new VintageNoteButton(instrument, row, column,
return new VintageNoteButton(row, column,
getSoundAt(getNoteSounds(), row, column), getLabelSupplier(), screen
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.cstav.genshinstrument.sound.NoteSound;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionHand;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
Expand All @@ -21,8 +21,8 @@
public class WindsongLyreScreen extends AbstractGridInstrumentScreen {
public static final String INSTRUMENT_ID = "windsong_lyre";

public WindsongLyreScreen(ItemStack instrument) {
super(instrument);
public WindsongLyreScreen(InteractionHand hand) {
super(hand);
}


Expand Down
Loading

0 comments on commit 6238adf

Please sign in to comment.