Skip to content

Commit eeeb375

Browse files
Update to 1.19.3
1 parent 8a92685 commit eeeb375

File tree

8 files changed

+137
-66
lines changed

8 files changed

+137
-66
lines changed

build.gradle

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
plugins {
22
id 'eclipse'
33
id 'maven-publish'
4-
id 'net.minecraftforge.gradle' version '5.+'
4+
id 'net.minecraftforge.gradle' version '5.1.+'
55
}
66

7-
version = '2.4.0'
7+
version = '2.4.1'
88
group = 'wafflestomper'
9-
archivesBaseName = '1.19.2-Ghostwriter'
9+
archivesBaseName = '1.19.#-Ghostwriter'
1010

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

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

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

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

139137
// Examples using mod jars from ./libs

src/main/java/wafflestomper/ghostwriter/gui/GhostLayer.java

+24-24
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

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

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

505505
this.buttonsInitialized = true;
506506
this.updateButtons();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package wafflestomper.ghostwriter.gui;
2+
3+
import net.minecraft.client.gui.components.Button;
4+
import net.minecraft.network.chat.Component;
5+
6+
public class GuiUtils {
7+
8+
// Helper function so that we don't have to update the code in a million places every time they change buttons
9+
public static Button buttonFactory(int x, int y, int width, int height, String text, Button.OnPress onPress) {
10+
return Button.builder(
11+
Component.translatable(text),
12+
onPress
13+
).bounds(
14+
x, y, width, height
15+
).build();
16+
}
17+
}

src/main/java/wafflestomper/ghostwriter/gui/screen/GhostwriterFileBrowserScreen.java

+54-24
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package wafflestomper.ghostwriter.gui.screen;
22

33
import com.mojang.blaze3d.vertex.PoseStack;
4+
import net.minecraft.client.gui.GuiComponent;
45
import net.minecraft.client.gui.screens.ConfirmScreen;
56
import net.minecraft.client.gui.screens.Screen;
67
import net.minecraft.client.gui.components.Button;
78
import net.minecraft.network.chat.Component;
89
import net.minecraft.network.chat.Style;
910
import wafflestomper.ghostwriter.*;
11+
import wafflestomper.ghostwriter.gui.GuiUtils;
1012
import wafflestomper.ghostwriter.gui.widget.FileSelectionList;
1113
import wafflestomper.ghostwriter.gui.GhostLayer;
1214
import wafflestomper.ghostwriter.gui.widget.SelectableFilenameField;
@@ -124,7 +126,10 @@ private void saveClicked() {
124126

125127
public void init() {
126128
super.init();
127-
if (this.minecraft != null) this.minecraft.keyboardHandler.setSendRepeatsToGui(true);
129+
if (this.minecraft == null) return;
130+
131+
// I can't remember what this did but setSendRepeatsToGui() is no longer a valid function...
132+
// this.minecraft.keyboardHandler.setSendRepeatsToGui(true);
128133

129134
if (!this.initialized) {
130135
this.fileSelectionList = new FileSelectionList(this, this.minecraft, this.width, this.height, 32, this.height - 64, SLOT_HEIGHT);
@@ -153,29 +158,48 @@ public void init() {
153158
// For some reason the button list is cleared when the window is resized
154159
int mainButtonsY = this.height - BORDER_HEIGHT - BUTTON_HEIGHT;
155160
int loadX = this.width / 2 - 127;
156-
this.btnLoad = this.addRenderableWidget(new Button(loadX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT,
157-
Component.translatable("Load"), (pressedButton) -> this.loadClicked(false)));
161+
162+
this.btnLoad = this.addRenderableWidget(
163+
GuiUtils.buttonFactory(
164+
loadX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT, "Load",
165+
(pressedButton) -> this.loadClicked(false)
166+
)
167+
);
158168

159169
int autoReloadX = loadX + BUTTON_WIDTH;
160-
this.btnAutoReload = this.addRenderableWidget(new Button(autoReloadX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT,
161-
Component.translatable("AutoReload"), (pressedButton) -> this.loadClicked(true)));
170+
this.btnAutoReload = this.addRenderableWidget(
171+
GuiUtils.buttonFactory(
172+
autoReloadX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT, "AutoReload",
173+
(pressedButton) -> this.loadClicked(true)
174+
)
175+
);
162176

163177
int saveX = autoReloadX + BUTTON_WIDTH + 7;
164-
this.btnSave = this.addRenderableWidget(new Button(saveX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT,
165-
Component.translatable("Save"), (pressedButton) -> this.saveClicked()));
178+
this.btnSave = this.addRenderableWidget(
179+
GuiUtils.buttonFactory(
180+
saveX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT, "Save",
181+
(pressedButton) -> this.saveClicked()
182+
)
183+
);
166184

167185
int cancelX = this.width / 2 + 127 - BUTTON_WIDTH;
168-
this.addRenderableWidget(new Button(cancelX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT,
169-
Component.translatable("Cancel"), (pressedButton) -> goBackToParentGui()));
186+
this.addRenderableWidget(
187+
GuiUtils.buttonFactory(
188+
cancelX, mainButtonsY, BUTTON_WIDTH, BUTTON_HEIGHT, "Cancel",
189+
(pressedButton) -> goBackToParentGui()
190+
)
191+
);
170192

171193
//Add buttons for each non-empty drive letter
172194
int rootNum = 100;
173195
List<File> roots = this.FILE_HANDLER.getValidRoots();
174196
for (File root : roots) {
175-
this.addRenderableWidget(new Button(5, 35 + 21 * (rootNum - 100), 50, 20,
176-
Component.translatable(root.getAbsolutePath()), (pressedButton) ->
177-
this.driveButtonClicked(root)
178-
));
197+
this.addRenderableWidget(
198+
GuiUtils.buttonFactory(
199+
5, 35 + 21 * (rootNum - 100), 50, 20, root.getAbsolutePath(),
200+
(pressedButton) -> this.driveButtonClicked(root)
201+
)
202+
);
179203
rootNum++;
180204
}
181205

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

190214
// Add button for enabling file extension editing
191-
this.btnEditExtension = this.addRenderableWidget(new Button(this.filenameField.x + this.filenameField.getWidth() + 3,
192-
this.filenameField.y, 25, this.filenameField.getHeight(), Component.translatable("EXT"),
193-
(pressedButton) -> {
194-
this.filenameField.toggleExtensionModifications();
195-
this.updateButtons();
196-
}));
215+
this.btnEditExtension = this.addRenderableWidget(
216+
GuiUtils.buttonFactory(
217+
this.filenameField.x + this.filenameField.getWidth() + 3,
218+
this.filenameField.y,
219+
25,
220+
this.filenameField.getHeight(),
221+
"EXT",
222+
(pressedButton) -> {
223+
this.filenameField.toggleExtensionModifications();
224+
this.updateButtons();
225+
}
226+
)
227+
);
197228

198229
this.updateButtons();
199230
}
@@ -232,9 +263,9 @@ public void render(PoseStack PoseStack, int mouseX, int mouseY, float partialTic
232263
String reversed = new StringBuilder(displayPath).reverse().toString();
233264
// func_238361_b_() is trimStringToWidth()
234265
reversed = this.font.getSplitter().plainHeadByWidth(reversed, allowedSize, Style.EMPTY);
235-
displayPath = "..." + new StringBuilder(reversed).reverse().toString();
266+
displayPath = "..." + new StringBuilder(reversed).reverse();
236267
}
237-
this.drawCenteredString(PoseStack, this.font, displayPath, this.width / 2, 20, 0xDDDDDD);
268+
GuiComponent.drawCenteredString(PoseStack, this.font, displayPath, this.width / 2, 20, 0xDDDDDD);
238269

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

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

252283
public void setSelectedSlot(FileSelectionList.Entry entry) {
253284
this.fileSelectionList.setSelected(entry);
254-
if (this.enableLoading && entry instanceof FileSelectionList.PathItemEntry) {
255-
FileSelectionList.PathItemEntry p = (FileSelectionList.PathItemEntry) entry;
285+
if (this.enableLoading && entry instanceof FileSelectionList.PathItemEntry p) {
256286
if (p.path == this.selectedFile) {
257287
return;
258288
} else if (p.path.isFile()) {
@@ -316,7 +346,7 @@ public void updateButtons() {
316346
if (this.filenameField.allowExtensionModifications) {
317347
this.btnEditExtension.setMessage(Component.translatable("EXT"));
318348
} else {
319-
this.btnEditExtension.setMessage(Component.translatable("\u00a7mEXT"));
349+
this.btnEditExtension.setMessage(Component.translatable("§mEXT"));
320350
}
321351
}
322352

src/main/java/wafflestomper/ghostwriter/gui/screen/GhostwriterSignedPreviewScreen.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package wafflestomper.ghostwriter.gui.screen;
22

33
import net.minecraft.client.gui.screens.inventory.BookViewScreen;
4-
import net.minecraft.client.gui.components.Button;
54
import net.minecraft.network.chat.FormattedText;
6-
import net.minecraft.network.chat.Component;
5+
import org.jetbrains.annotations.NotNull;
6+
import wafflestomper.ghostwriter.gui.GuiUtils;
77
import wafflestomper.ghostwriter.utilities.SharedConstants;
88

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

1818
@Override
1919
public void createMenuControls() {
20-
this.addRenderableWidget(new Button(this.width / 2 - 100, 196, 200, 20,
21-
Component.translatable("Back to editor"), (p_214161_1_) -> {
22-
if (this.minecraft == null) return;
23-
this.minecraft.setScreen(this.parent);
24-
}));
20+
this.addRenderableWidget(
21+
GuiUtils.buttonFactory(
22+
this.width / 2 - 100, 196, 200, 20, "Back to editor",
23+
(p_214161_1_) -> {
24+
if (this.minecraft == null) return;
25+
this.minecraft.setScreen(this.parent);
26+
}
27+
)
28+
);
2529
}
2630

2731
@Override
@@ -61,7 +65,7 @@ public int getPageCount() {
6165
}
6266

6367
// TODO: I have no idea if this is right
64-
public FormattedText getPageRaw(int pageNum) {
68+
public @NotNull FormattedText getPageRaw(int pageNum) {
6569
return FormattedText.of(this.PARENT.pages.get(pageNum));
6670
}
6771
}

src/main/resources/META-INF/accesstransformer.cfg

+18
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,21 @@ public net.minecraft.client.gui.screens.Screen f_96543_ # width
265265
public net.minecraft.client.gui.screens.Screen f_96544_ # height
266266
public net.minecraft.client.gui.screens.Screen f_96546_ # passEvents
267267
public net.minecraft.client.gui.screens.Screen f_96547_ # font
268+
269+
270+
# We need to make the x and y properties public so we can modify the positions of the vanilla book buttons
271+
# public net.minecraft.client.gui.components.AbstractWidget f_256816_ # tooltip
272+
# public net.minecraft.client.gui.components.AbstractWidget f_256916_ # wasHoveredOrFocused
273+
# public net.minecraft.client.gui.components.AbstractWidget f_256936_ # tooltipMsDelay
274+
# public net.minecraft.client.gui.components.AbstractWidget f_256960_ # hoverOrFocusedStartTime
275+
# public net.minecraft.client.gui.components.AbstractWidget f_93614_ # message
276+
# public net.minecraft.client.gui.components.AbstractWidget f_93616_ # focused
277+
# public net.minecraft.client.gui.components.AbstractWidget f_93617_ # WIDGETS_LOCATION
278+
# public net.minecraft.client.gui.components.AbstractWidget f_93618_ # width
279+
# public net.minecraft.client.gui.components.AbstractWidget f_93619_ # height
280+
public net.minecraft.client.gui.components.AbstractWidget f_93620_ # x
281+
public net.minecraft.client.gui.components.AbstractWidget f_93621_ # y
282+
# public net.minecraft.client.gui.components.AbstractWidget f_93622_ # isHovered
283+
# public net.minecraft.client.gui.components.AbstractWidget f_93623_ # active
284+
# public net.minecraft.client.gui.components.AbstractWidget f_93624_ # visible
285+
# public net.minecraft.client.gui.components.AbstractWidget f_93625_ # alpha

src/main/resources/META-INF/mods.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
modLoader="javafml"
33

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

77
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
88
license="GNU GPL v3"
@@ -27,12 +27,12 @@ issueTrackerURL="https://github.com/waffle-stomper/Ghostwriter/issues"
2727
[[dependencies.ghostwriter]]
2828
modId="forge"
2929
mandatory=true
30-
versionRange="[43,)"
30+
versionRange="[44,)"
3131
ordering="NONE"
3232
side="CLIENT"
3333
[[dependencies.ghostwriter]]
3434
modId="minecraft"
3535
mandatory=true
36-
versionRange="[1.19.2,1.20)"
36+
versionRange="[1.19.3,1.20)"
3737
ordering="NONE"
3838
side="CLIENT"

update.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"homepage": "https://github.com/waffle-stomper/Ghostwriter/releases",
33
"promos":{
4+
"1.19.3-recommended": "2.4.1",
45
"1.19.2-recommended": "2.4.0",
56
"1.19.1-recommended": "2.3.9",
67
"1.19-recommended": "2.3.8",
@@ -22,6 +23,9 @@
2223
"1.11-recommended": "1.8.7",
2324
"1.10-recommended": "1.8.5"
2425
},
26+
"1.19.3": {
27+
"2.4.1": "Update to 1.19.3"
28+
},
2529
"1.19.2": {
2630
"2.4.0": "Update to 1.19.2"
2731
},

0 commit comments

Comments
 (0)