Skip to content

Commit

Permalink
Update to 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
waffle-stomper committed Dec 9, 2022
1 parent 8a92685 commit eeeb375
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 66 deletions.
12 changes: 5 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.+'
id 'net.minecraftforge.gradle' version '5.1.+'
}

version = '2.4.0'
version = '2.4.1'
group = 'wafflestomper'
archivesBaseName = '1.19.2-Ghostwriter'
archivesBaseName = '1.19.#-Ghostwriter'

// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
Expand All @@ -26,7 +26,7 @@ minecraft {
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.19.2'
mappings channel: 'official', version: '1.19.3'

accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

Expand Down Expand Up @@ -129,11 +129,9 @@ dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.19.2-43.1.43'
minecraft 'net.minecraftforge:forge:1.19.3-44.0.1'

// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency

// Examples using mod jars from ./libs
Expand Down
48 changes: 24 additions & 24 deletions src/main/java/wafflestomper/ghostwriter/gui/GhostLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.List;


/**
* Generic Ghostwriter functions to supplement the vanilla book screens
*/
Expand Down Expand Up @@ -404,8 +405,7 @@ public void updateButtons() {
private Button addPageButton(int x, int y, String label, Button.OnPress action, boolean hideInReadOnlyMode){
int width = SharedConstants.LARGE_BUTTON_WIDTH;
int height = SharedConstants.BUTTON_HEIGHT;
Component buttonText = Component.translatable(label);
Button b = this.parent.addGhostButton(new Button(x, y, width, height, buttonText, action));
Button b = this.parent.addGhostButton(GuiUtils.buttonFactory(x, y, width, height, label, action));
this.buttonsHideWhileSigning.add(b);
if (hideInReadOnlyMode) this.buttonsEditOnly.add(b);
return b;
Expand Down Expand Up @@ -476,31 +476,31 @@ public void init() {
/////////////////////////////////////// Underside buttons ///////////////////////////////////////////
this.colorFormatButtonX = this.screen.width / 2 - (SharedConstants.COLOR_FORMAT_BUTTON_WIDTH * 8);
int colorButY = this.screen.height - 40;
this.addColorFormatButton(colorButY, "\u00a70A", "\u00a70"); // BLACK
this.addColorFormatButton(colorButY, "\u00a71A", "\u00a71"); // DARK_BLUE
this.addColorFormatButton(colorButY, "\u00a72A", "\u00a72"); // DARK_GREEN
this.addColorFormatButton(colorButY, "\u00a73A", "\u00a73"); // DARK_AQUA
this.addColorFormatButton(colorButY, "\u00a74A", "\u00a74"); // DARK_RED
this.addColorFormatButton(colorButY, "\u00a75A", "\u00a75"); // DARK_PURPLE
this.addColorFormatButton(colorButY, "\u00a76A", "\u00a76"); // GOLD
this.addColorFormatButton(colorButY, "\u00a77A", "\u00a77"); // GRAY
this.addColorFormatButton(colorButY, "\u00a78A", "\u00a78"); // DARK_GRAY
this.addColorFormatButton(colorButY, "\u00a79A", "\u00a79"); // BLUE
this.addColorFormatButton(colorButY, "\u00a7aA", "\u00a7a"); // GREEN
this.addColorFormatButton(colorButY, "\u00a7bA", "\u00a7b"); // AQUA
this.addColorFormatButton(colorButY, "\u00a7cA", "\u00a7c"); // RED
this.addColorFormatButton(colorButY, "\u00a7dA", "\u00a7d"); // LIGHT_PURPLE
this.addColorFormatButton(colorButY, "\u00a7eA", "\u00a7e"); // YELLOW
this.addColorFormatButton(colorButY, "\u00a7fA", "\u00a7f"); // WHITE
this.addColorFormatButton(colorButY, "§0A", "§0"); // BLACK
this.addColorFormatButton(colorButY, "§1A", "§1"); // DARK_BLUE
this.addColorFormatButton(colorButY, "§2A", "§2"); // DARK_GREEN
this.addColorFormatButton(colorButY, "§3A", "§3"); // DARK_AQUA
this.addColorFormatButton(colorButY, "§4A", "§4"); // DARK_RED
this.addColorFormatButton(colorButY, "§5A", "§5"); // DARK_PURPLE
this.addColorFormatButton(colorButY, "§6A", "§6"); // GOLD
this.addColorFormatButton(colorButY, "§7A", "§7"); // GRAY
this.addColorFormatButton(colorButY, "§8A", "§8"); // DARK_GRAY
this.addColorFormatButton(colorButY, "§9A", "§9"); // BLUE
this.addColorFormatButton(colorButY, "§aA", "§a"); // GREEN
this.addColorFormatButton(colorButY, "§bA", "§b"); // AQUA
this.addColorFormatButton(colorButY, "§cA", "§c"); // RED
this.addColorFormatButton(colorButY, "§dA", "§d"); // LIGHT_PURPLE
this.addColorFormatButton(colorButY, "§eA", "§e"); // YELLOW
this.addColorFormatButton(colorButY, "§fA", "§f"); // WHITE

this.colorFormatButtonX = this.screen.width / 2 - (SharedConstants.COLOR_FORMAT_BUTTON_WIDTH * 5);
int formatButY = this.screen.height - 20;
this.addColorFormatButton(formatButY, "\u00a7kA", "\u00a7k"); // OBFUSCATED
this.addColorFormatButton(formatButY, "\u00a7lA", "\u00a7l"); // BOLD
this.addColorFormatButton(formatButY, "\u00a7mA", "\u00a7m"); // STRIKETHROUGH
this.addColorFormatButton(formatButY, "\u00a7nA", "\u00a7n"); // UNDERLINE
this.addColorFormatButton(formatButY, "\u00a7oA", "\u00a7o"); // ITALIC
this.addColorFormatButton(formatButY, "Reset Formatting", "\u00a7r").setWidth(100);
this.addColorFormatButton(formatButY, "§kA", "§k"); // OBFUSCATED
this.addColorFormatButton(formatButY, "§lA", "§l"); // BOLD
this.addColorFormatButton(formatButY, "§mA", "§m"); // STRIKETHROUGH
this.addColorFormatButton(formatButY, "§nA", "§n"); // UNDERLINE
this.addColorFormatButton(formatButY, "§oA", "§o"); // ITALIC
this.addColorFormatButton(formatButY, "Reset Formatting", "§r").setWidth(100);

this.buttonsInitialized = true;
this.updateButtons();
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/wafflestomper/ghostwriter/gui/GuiUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package wafflestomper.ghostwriter.gui;

import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;

public class GuiUtils {

// Helper function so that we don't have to update the code in a million places every time they change buttons
public static Button buttonFactory(int x, int y, int width, int height, String text, Button.OnPress onPress) {
return Button.builder(
Component.translatable(text),
onPress
).bounds(
x, y, width, height
).build();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package wafflestomper.ghostwriter.gui.screen;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.screens.ConfirmScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import wafflestomper.ghostwriter.*;
import wafflestomper.ghostwriter.gui.GuiUtils;
import wafflestomper.ghostwriter.gui.widget.FileSelectionList;
import wafflestomper.ghostwriter.gui.GhostLayer;
import wafflestomper.ghostwriter.gui.widget.SelectableFilenameField;
Expand Down Expand Up @@ -124,7 +126,10 @@ private void saveClicked() {

public void init() {
super.init();
if (this.minecraft != null) this.minecraft.keyboardHandler.setSendRepeatsToGui(true);
if (this.minecraft == null) return;

// I can't remember what this did but setSendRepeatsToGui() is no longer a valid function...
// this.minecraft.keyboardHandler.setSendRepeatsToGui(true);

if (!this.initialized) {
this.fileSelectionList = new FileSelectionList(this, this.minecraft, this.width, this.height, 32, this.height - 64, SLOT_HEIGHT);
Expand Down Expand Up @@ -153,29 +158,48 @@ public void init() {
// For some reason the button list is cleared when the window is resized
int mainButtonsY = this.height - BORDER_HEIGHT - BUTTON_HEIGHT;
int loadX = this.width / 2 - 127;
this.btnLoad = this.addRenderableWidget(new Button(loadX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT,
Component.translatable("Load"), (pressedButton) -> this.loadClicked(false)));

this.btnLoad = this.addRenderableWidget(
GuiUtils.buttonFactory(
loadX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT, "Load",
(pressedButton) -> this.loadClicked(false)
)
);

int autoReloadX = loadX + BUTTON_WIDTH;
this.btnAutoReload = this.addRenderableWidget(new Button(autoReloadX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT,
Component.translatable("AutoReload"), (pressedButton) -> this.loadClicked(true)));
this.btnAutoReload = this.addRenderableWidget(
GuiUtils.buttonFactory(
autoReloadX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT, "AutoReload",
(pressedButton) -> this.loadClicked(true)
)
);

int saveX = autoReloadX + BUTTON_WIDTH + 7;
this.btnSave = this.addRenderableWidget(new Button(saveX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT,
Component.translatable("Save"), (pressedButton) -> this.saveClicked()));
this.btnSave = this.addRenderableWidget(
GuiUtils.buttonFactory(
saveX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT, "Save",
(pressedButton) -> this.saveClicked()
)
);

int cancelX = this.width / 2 + 127 - BUTTON_WIDTH;
this.addRenderableWidget(new Button(cancelX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT,
Component.translatable("Cancel"), (pressedButton) -> goBackToParentGui()));
this.addRenderableWidget(
GuiUtils.buttonFactory(
cancelX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT, "Cancel",
(pressedButton) -> goBackToParentGui()
)
);

//Add buttons for each non-empty drive letter
int rootNum = 100;
List<File> roots = this.FILE_HANDLER.getValidRoots();
for (File root : roots) {
this.addRenderableWidget(new Button(5, 35 + 21 * (rootNum - 100), 50, 20,
Component.translatable(root.getAbsolutePath()), (pressedButton) ->
this.driveButtonClicked(root)
));
this.addRenderableWidget(
GuiUtils.buttonFactory(
5, 35 + 21 * (rootNum - 100), 50, 20, root.getAbsolutePath(),
(pressedButton) -> this.driveButtonClicked(root)
)
);
rootNum++;
}

Expand All @@ -188,12 +212,19 @@ public void init() {
this.filenameField.y = this.height - BORDER_HEIGHT * 2 - BUTTON_HEIGHT * 2;

// Add button for enabling file extension editing
this.btnEditExtension = this.addRenderableWidget(new Button(this.filenameField.x + this.filenameField.getWidth() + 3,
this.filenameField.y, 25, this.filenameField.getHeight(), Component.translatable("EXT"),
(pressedButton) -> {
this.filenameField.toggleExtensionModifications();
this.updateButtons();
}));
this.btnEditExtension = this.addRenderableWidget(
GuiUtils.buttonFactory(
this.filenameField.x + this.filenameField.getWidth() + 3,
this.filenameField.y,
25,
this.filenameField.getHeight(),
"EXT",
(pressedButton) -> {
this.filenameField.toggleExtensionModifications();
this.updateButtons();
}
)
);

this.updateButtons();
}
Expand Down Expand Up @@ -232,9 +263,9 @@ public void render(PoseStack PoseStack, int mouseX, int mouseY, float partialTic
String reversed = new StringBuilder(displayPath).reverse().toString();
// func_238361_b_() is trimStringToWidth()
reversed = this.font.getSplitter().plainHeadByWidth(reversed, allowedSize, Style.EMPTY);
displayPath = "..." + new StringBuilder(reversed).reverse().toString();
displayPath = "..." + new StringBuilder(reversed).reverse();
}
this.drawCenteredString(PoseStack, this.font, displayPath, this.width / 2, 20, 0xDDDDDD);
GuiComponent.drawCenteredString(PoseStack, this.font, displayPath, this.width / 2, 20, 0xDDDDDD);

this.filenameField.render(PoseStack, mouseX, mouseY, partialTicks);

Expand All @@ -251,8 +282,7 @@ else if (this.hoveringText != null) {

public void setSelectedSlot(FileSelectionList.Entry entry) {
this.fileSelectionList.setSelected(entry);
if (this.enableLoading && entry instanceof FileSelectionList.PathItemEntry) {
FileSelectionList.PathItemEntry p = (FileSelectionList.PathItemEntry) entry;
if (this.enableLoading && entry instanceof FileSelectionList.PathItemEntry p) {
if (p.path == this.selectedFile) {
return;
} else if (p.path.isFile()) {
Expand Down Expand Up @@ -316,7 +346,7 @@ public void updateButtons() {
if (this.filenameField.allowExtensionModifications) {
this.btnEditExtension.setMessage(Component.translatable("EXT"));
} else {
this.btnEditExtension.setMessage(Component.translatable("\u00a7mEXT"));
this.btnEditExtension.setMessage(Component.translatable("§mEXT"));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package wafflestomper.ghostwriter.gui.screen;

import net.minecraft.client.gui.screens.inventory.BookViewScreen;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
import wafflestomper.ghostwriter.gui.GuiUtils;
import wafflestomper.ghostwriter.utilities.SharedConstants;

public class GhostwriterSignedPreviewScreen extends BookViewScreen {
Expand All @@ -17,11 +17,15 @@ public GhostwriterSignedPreviewScreen(GhostwriterEditBookScreen parent) {

@Override
public void createMenuControls() {
this.addRenderableWidget(new Button(this.width / 2 - 100, 196, 200, 20,
Component.translatable("Back to editor"), (p_214161_1_) -> {
if (this.minecraft == null) return;
this.minecraft.setScreen(this.parent);
}));
this.addRenderableWidget(
GuiUtils.buttonFactory(
this.width / 2 - 100, 196, 200, 20, "Back to editor",
(p_214161_1_) -> {
if (this.minecraft == null) return;
this.minecraft.setScreen(this.parent);
}
)
);
}

@Override
Expand Down Expand Up @@ -61,7 +65,7 @@ public int getPageCount() {
}

// TODO: I have no idea if this is right
public FormattedText getPageRaw(int pageNum) {
public @NotNull FormattedText getPageRaw(int pageNum) {
return FormattedText.of(this.PARENT.pages.get(pageNum));
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,21 @@ public net.minecraft.client.gui.screens.Screen f_96543_ # width
public net.minecraft.client.gui.screens.Screen f_96544_ # height
public net.minecraft.client.gui.screens.Screen f_96546_ # passEvents
public net.minecraft.client.gui.screens.Screen f_96547_ # font


# We need to make the x and y properties public so we can modify the positions of the vanilla book buttons
# public net.minecraft.client.gui.components.AbstractWidget f_256816_ # tooltip
# public net.minecraft.client.gui.components.AbstractWidget f_256916_ # wasHoveredOrFocused
# public net.minecraft.client.gui.components.AbstractWidget f_256936_ # tooltipMsDelay
# public net.minecraft.client.gui.components.AbstractWidget f_256960_ # hoverOrFocusedStartTime
# public net.minecraft.client.gui.components.AbstractWidget f_93614_ # message
# public net.minecraft.client.gui.components.AbstractWidget f_93616_ # focused
# public net.minecraft.client.gui.components.AbstractWidget f_93617_ # WIDGETS_LOCATION
# public net.minecraft.client.gui.components.AbstractWidget f_93618_ # width
# public net.minecraft.client.gui.components.AbstractWidget f_93619_ # height
public net.minecraft.client.gui.components.AbstractWidget f_93620_ # x
public net.minecraft.client.gui.components.AbstractWidget f_93621_ # y
# public net.minecraft.client.gui.components.AbstractWidget f_93622_ # isHovered
# public net.minecraft.client.gui.components.AbstractWidget f_93623_ # active
# public net.minecraft.client.gui.components.AbstractWidget f_93624_ # visible
# public net.minecraft.client.gui.components.AbstractWidget f_93625_ # alpha
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
modLoader="javafml"

# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[43,)" # 43 = 1.19.2
loaderVersion="[44,)" # 44 = 1.19.3

# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
license="GNU GPL v3"
Expand All @@ -27,12 +27,12 @@ issueTrackerURL="https://github.com/waffle-stomper/Ghostwriter/issues"
[[dependencies.ghostwriter]]
modId="forge"
mandatory=true
versionRange="[43,)"
versionRange="[44,)"
ordering="NONE"
side="CLIENT"
[[dependencies.ghostwriter]]
modId="minecraft"
mandatory=true
versionRange="[1.19.2,1.20)"
versionRange="[1.19.3,1.20)"
ordering="NONE"
side="CLIENT"
4 changes: 4 additions & 0 deletions update.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"homepage": "https://github.com/waffle-stomper/Ghostwriter/releases",
"promos":{
"1.19.3-recommended": "2.4.1",
"1.19.2-recommended": "2.4.0",
"1.19.1-recommended": "2.3.9",
"1.19-recommended": "2.3.8",
Expand All @@ -22,6 +23,9 @@
"1.11-recommended": "1.8.7",
"1.10-recommended": "1.8.5"
},
"1.19.3": {
"2.4.1": "Update to 1.19.3"
},
"1.19.2": {
"2.4.0": "Update to 1.19.2"
},
Expand Down

0 comments on commit eeeb375

Please sign in to comment.