Skip to content

Commit

Permalink
Backport to Minecraft version 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed Jul 11, 2023
1 parent 9b97194 commit 409d7b9
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 73 deletions.
11 changes: 8 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = project.mod_version
group = project.maven_group

base {
archivesName = project.archives_base_name+"-fabric"
archivesName = project.archives_base_name+"-fabric-"+project.minecraft_version
}

repositories {
Expand All @@ -26,6 +26,11 @@ repositories {
url "https://cursemaven.com"
}
maven { url 'https://maven.terraformersmc.com/releases/' }

maven {
name = "Fuzs Mod Resources"
url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/"
}
}
}

Expand All @@ -38,11 +43,11 @@ dependencies {
}
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modApi "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:${project.forge_config_api_port_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "curse.maven:forge-config-api-port-fabric-547434:${project.forge_config_api_port_version}"

modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"

// Uncomment the following line to enable the deprecated Fabric API modules.
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20
parchment_mappings=1.20.1:2023.07.02
minecraft_version=1.19.4
parchment_mappings=1.19.4:2023.06.26
loader_version=0.14.21

# Mod Properties
Expand All @@ -14,6 +14,6 @@ maven_group=com.cstav.genshinstrument
archives_base_name=genshinstrument

# Dependencies
fabric_version=0.83.0+1.20
modmenu_version=7.0.1
forge_config_api_port_version=4576917
fabric_version=0.85.0+1.19.4
modmenu_version=6.2.3
forge_config_api_port_version=6.0.2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public void onInitialize() {

ModSounds.regsiter();

ModCreativeModeTabs.regsiter();
ModItems.register();
}

Expand Down
17 changes: 6 additions & 11 deletions src/main/java/com/cstav/genshinstrument/ModCreativeModeTabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@
import com.cstav.genshinstrument.item.ModItems;

import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;

public class ModCreativeModeTabs {

public static final CreativeModeTab INSTRUMENTS = FabricItemGroup.builder()
.icon(() -> new ItemStack(ModItems.FLORAL_ZITHER))
.title(Component.translatable("genshinstrument.itemGroup.instruments"))
.build();

public static void regsiter() {
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, new ResourceLocation(GInstrumentMod.MODID, "instruments_group"), INSTRUMENTS);

}
public static final CreativeModeTab
INSTRUMENTS = FabricItemGroup.builder(new ResourceLocation(GInstrumentMod.MODID, "instruments_group"))
.icon(() -> new ItemStack(ModItems.FLORAL_ZITHER))
.title(Component.translatable("genshinstrument.itemGroup.instruments"))
.build()
;

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

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.resources.ResourceLocation;

@Environment(EnvType.CLIENT)
public class ClientUtil {
Expand Down Expand Up @@ -36,4 +38,10 @@ public static void resetShaderColor() {
setShaderColor(Color.WHITE);
}


public static void displaySprite(final ResourceLocation location) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, location);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
import com.cstav.genshinstrument.client.keyMaps.KeyMappings;
import com.mojang.blaze3d.platform.InputConstants.Key;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.layouts.AbstractLayout;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
Expand Down Expand Up @@ -82,17 +83,17 @@ protected void init() {


@Override
public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) {
public void render(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) {
if (ModClientConfigs.RENDER_BACKGROUND.get()) {
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();

ClientUtil.setShaderColor(Color.WHITE, .6f);
renderInstrumentBackground(gui);
renderInstrumentBackground(poseStack);
ClientUtil.resetShaderColor();
}

super.render(gui, pMouseX, pMouseY, pPartialTick);
super.render(poseStack, pMouseX, pMouseY, pPartialTick);
}


Expand All @@ -101,29 +102,33 @@ public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick
* This render method will only work for a 3-column instrument. Overwrite it
* to customize the background.
*/
protected void renderInstrumentBackground(final GuiGraphics gui) {
protected void renderInstrumentBackground(final PoseStack poseStack) {
if (columns() != 3)
return;

final int clefX = grid.getX() - NoteButton.getSize() + 8;

for (int i = 0; i < columns(); i++) {
renderClef(gui, i, clefX);
renderStaff(gui, i);
renderClef(poseStack, i, clefX);
renderStaff(poseStack, i);
}
}

protected void renderClef(final GuiGraphics gui, final int index, final int x) {
gui.blit(getResourceFromGlob("background/clefs.png"),
protected void renderClef(final PoseStack poseStack, final int index, final int x) {
ClientUtil.displaySprite(getResourceFromGlob("background/clefs.png"));

GuiComponent.blit(poseStack,
x, grid.getY() + (NoteButton.getSize() + 16) * index,
index * CLEF_WIDTH, 0,
CLEF_WIDTH, CLEF_HEIGHT,
CLEF_WIDTH*3, CLEF_HEIGHT
);
}

protected void renderStaff(final GuiGraphics gui, final int index) {
gui.blit(getResourceFromGlob("background/staff.png"),
protected void renderStaff(final PoseStack poseStack, final int index) {
ClientUtil.displaySprite(getResourceFromGlob("background/staff.png"));

GuiComponent.blit(poseStack,
grid.getX() + 2, grid.getY() + 8 + ((NoteButton.getSize() + NoteGrid.PADDING_VERT + 6) * index),
0, 0,
grid.getWidth() - 5, NoteButton.getSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import com.cstav.genshinstrument.util.ModEntityData;
import com.mojang.blaze3d.platform.InputConstants.Key;
import com.mojang.blaze3d.platform.InputConstants.Type;
import com.mojang.blaze3d.vertex.PoseStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
Expand Down Expand Up @@ -197,10 +197,10 @@ private void unlockFocused() {
private boolean isOptionsActive = false;

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

protected void onOptionsOpen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
import com.cstav.genshinstrument.sound.NoteSound;
import com.cstav.genshinstrument.util.CommonUtil;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.narration.NarratedElementType;
import net.minecraft.client.gui.narration.NarrationElementOutput;
Expand Down Expand Up @@ -155,13 +156,15 @@ public boolean isPlaying() {
}



@Override
public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialTick) {
public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTick) {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.enableDepthTest();

rings.removeIf((ring) -> !ring.isPlaying());
rings.forEach((ring) -> ring.render(gui));
rings.forEach((ring) -> ring.render(poseStack));

final InstrumentThemeLoader theme = instrumentScreen.getThemeLoader();
final Color
Expand All @@ -172,6 +175,7 @@ public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialT


// Button
ClientUtil.displaySprite(noteBgLocation);

// width = full color, width * 2 = border, 0 = normal
int blitOffset =
Expand All @@ -183,18 +187,20 @@ public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialT
(width * 2)
: 0;

gui.blit(noteBgLocation,
GuiComponent.blit(poseStack,
this.getX(), this.getY(),
blitOffset, 0,
width, height,
width*3, height
);

// Note
ClientUtil.displaySprite(noteLocation);

final int noteWidth = width/2, noteHeight = height/2;
ClientUtil.setShaderColor((isPlaying() && !foreignPlaying) ? pressedNoteTheme : labelTheme);

gui.blit(noteLocation,
GuiComponent.blit(poseStack,
this.getX() + noteWidth/2, this.getY() + noteHeight/2,
//NOTE: I have no clue whatsoever how on earth these 1.025 and .9 multipliers actually work.
// Like seriously wtf why fkuaherjgaeorg i hate maths
Expand All @@ -209,8 +215,8 @@ public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialT
// Label
//FIXME: All text rendered this way are making their way to the top of
// the render stack, for some reason
gui.drawCenteredString(
minecraft.font, getMessage(),
drawCenteredString(
poseStack, minecraft.font, getMessage(),
textX, textY,
((isPlaying() && !foreignPlaying) ? pressedNoteTheme : noteTheme).getRGB()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import com.cstav.genshinstrument.client.ClientUtil;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractInstrumentScreen;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.animation.RingAnimationController;
import com.mojang.blaze3d.vertex.PoseStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.resources.ResourceLocation;

@Environment(EnvType.CLIENT)
Expand All @@ -32,7 +33,7 @@ public NoteRing(final NoteButton note, final boolean isForeign) {
}


public void render(final GuiGraphics gui) {
public void render(final PoseStack poseStack) {
if (!ringAnimation.isPlaying())
return;

Expand All @@ -41,10 +42,12 @@ public void render(final GuiGraphics gui) {
final Point ringCenter = ClientUtil.getInitCenter(note.getInitX(), note.getInitY(), NoteButton.getSize(), size);


ClientUtil.displaySprite(
new ResourceLocation(GInstrumentMod.MODID, AbstractInstrumentScreen.getGlobalRootPath() + RING_GLOB_FILENAME)
);
ClientUtil.setShaderColor(note.instrumentScreen.getThemeLoader().getNoteTheme(), alpha);

gui.blit(
new ResourceLocation(GInstrumentMod.MODID, AbstractInstrumentScreen.getGlobalRootPath() + RING_GLOB_FILENAME),
GuiComponent.blit(poseStack,
ringCenter.x, ringCenter.y,
0, 0,
size, size,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.cstav.genshinstrument.client.gui.screens.instrument.vintagelyre;

import com.cstav.genshinstrument.client.ClientUtil;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractGridInstrumentScreen;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteGridButton;
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier;
import com.cstav.genshinstrument.sound.NoteSound;
import com.mojang.blaze3d.vertex.PoseStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.resources.ResourceLocation;

@Environment(EnvType.CLIENT)
Expand All @@ -28,16 +30,19 @@ private boolean shouldRenderThingy() {
}

@Override
public void renderWidget(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) {
super.renderWidget(gui, pMouseX, pMouseY, pPartialTick);
public void renderWidget(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) {
super.renderWidget(poseStack, pMouseX, pMouseY, pPartialTick);

if (!shouldRenderThingy())
return;

final int textureWidth = (int)(width * TEXTURE_MULTIPLIER),
textureHeight = (int)(height * TEXTURE_MULTIPLIER);

gui.blit(thingyLocation,

ClientUtil.displaySprite(thingyLocation);

GuiComponent.blit(poseStack,
getX() - 1, getY() - 5,
isPlaying() ? textureWidth/2 : 0, 0,
textureWidth/2, textureHeight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel;
import com.cstav.genshinstrument.sound.NoteSound;
import com.ibm.icu.text.DecimalFormat;
import com.mojang.blaze3d.vertex.PoseStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractSliderButton;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.CycleButton;
Expand Down Expand Up @@ -289,12 +289,12 @@ protected void onSharedInstrumentChanged(final CycleButton<Boolean> button, fina


@Override
public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) {
renderBackground(gui);
public void render(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) {
renderBackground(poseStack);

gui.drawCenteredString(font, title, width/2, 20, Color.WHITE.getRGB());
drawCenteredString(poseStack, font, title, width/2, 20, Color.WHITE.getRGB());

super.render(gui, pMouseX, pMouseY, pPartialTick);
super.render(poseStack, pMouseX, pMouseY, pPartialTick);
}


Expand Down
Loading

0 comments on commit 409d7b9

Please sign in to comment.