Skip to content

Commit 5eb4f21

Browse files
fix: port to 1.21.9
1 parent 9037268 commit 5eb4f21

File tree

17 files changed

+122
-60
lines changed

17 files changed

+122
-60
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [21.9.0]
2+
3+
### Changed
4+
5+
- Updated to Minecraft 1.21.9
6+
17
## [21.8.4]
28

39
### Added

build.gradle

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'fabric-loom' version '1.11-SNAPSHOT' apply(false)
4-
id 'net.neoforged.moddev' version '2.0.105' apply(false)
4+
id 'net.neoforged.moddev' version '2.0.112' apply(false)
55
id "me.modmuss50.mod-publish-plugin" version "0.8.4"
66
}
77

@@ -77,15 +77,6 @@ subprojects {
7777
filesMatching(["META-INF/neoforge.mods.toml", "fabric.mod.json", "META-INF/mods.toml"]) {
7878
expand replaceProperties
7979
}
80-
81-
// This is less than ideal, we'll need to look into this.
82-
// if (project.name == "fabric" || project.name == "neoforge") {
83-
// tasks.named('processResources') {
84-
// from(project(":common").file("src/main/resources")) {
85-
// into "."
86-
// }
87-
// }
88-
// }
8980
}
9081

9182
publishing {
@@ -121,7 +112,6 @@ publishMods {
121112
def curseForgeOptions = curseforgeOptions {
122113
accessToken = providers.environmentVariable("CURSE_DEPLOY_TOKEN")
123114
minecraftVersions.add("${minecraft_version}")
124-
minecraftVersions.add("1.21.7")
125115
javaVersions.add(JavaVersion.VERSION_21)
126116
}
127117

common/src/main/java/pro/mikey/xray/XRay.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public enum XRay {
2121

2222
public static final XPlatShim XPLAT = ServiceLoader.load(XPlatShim.class).findFirst().orElseThrow();
2323

24-
public static final KeyMapping TOGGLE_KEY = new KeyMapping(I18n.get("xray.config.toggle"), GLFW.GLFW_KEY_BACKSLASH, "xray.mod_name");
25-
public static final KeyMapping OPEN_GUI_KEY = new KeyMapping(I18n.get("xray.config.open"), GLFW.GLFW_KEY_G, "xray.mod_name");
24+
private static final KeyMapping.Category CATEGORY = KeyMapping.Category.register(XRay.id("category"));
25+
public static final KeyMapping TOGGLE_KEY = new KeyMapping(I18n.get("xray.config.toggle"), GLFW.GLFW_KEY_BACKSLASH, CATEGORY);
26+
public static final KeyMapping OPEN_GUI_KEY = new KeyMapping(I18n.get("xray.config.open"), GLFW.GLFW_KEY_G, CATEGORY);
2627

2728
public void init() {
2829
}

common/src/main/java/pro/mikey/xray/core/OutlineRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static void renderBlocks(PoseStack poseStack) {
101101
// Use the alpha from the color, or default to 1.0 if alpha is 0
102102
final float opacity = alpha > 0 ? alpha : 1.0f;
103103

104-
ShapeRenderer.renderLineBox(poseStack, bufferBuilder, x, y, z, x + size, y + size, z + size, red, green, blue, opacity);
104+
ShapeRenderer.renderLineBox(poseStack.last(), bufferBuilder, x, y, z, x + size, y + size, z + size, red, green, blue, opacity);
105105
}
106106

107107
try (MeshData meshData = bufferBuilder.buildOrThrow()) {

common/src/main/java/pro/mikey/xray/screens/FindBlockScreen.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.client.gui.components.Button;
77
import net.minecraft.client.gui.components.EditBox;
88
import net.minecraft.client.gui.components.ObjectSelectionList;
9+
import net.minecraft.client.input.MouseButtonEvent;
910
import net.minecraft.core.registries.BuiltInRegistries;
1011
import net.minecraft.network.chat.Component;
1112
import net.minecraft.world.item.ItemStack;
@@ -80,11 +81,11 @@ public void renderExtra(GuiGraphics graphics, int x, int y, float partialTicks)
8081
}
8182

8283
@Override
83-
public boolean mouseClicked(double x, double y, int button) {
84-
if( this.search.mouseClicked (x, y, button) )
84+
public boolean mouseClicked(MouseButtonEvent mouseButtonEvent, boolean bl) {
85+
if( this.search.mouseClicked(mouseButtonEvent, bl) )
8586
this.setFocused(this.search);
8687

87-
return super.mouseClicked(x, y, button);
88+
return super.mouseClicked(mouseButtonEvent, bl);
8889
}
8990

9091
@Override
@@ -146,15 +147,15 @@ public Block getBlock() {
146147
}
147148

148149
@Override
149-
public void render(GuiGraphics graphics, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) {
150+
public void renderContent(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean hovering, float partialTicks) {
150151
Font font = this.parent.minecraft.font;
151152

152153
var registryName = BuiltInRegistries.BLOCK.getKey(this.block);
153154

154-
graphics.drawString(font, this.block.getName().getString(), left + 25, top + 7, Color.WHITE.getRGB());
155-
graphics.drawString(font, registryName.getNamespace(), left + 25, top + 17, Color.GRAY.getRGB());
155+
guiGraphics.drawString(font, this.block.getName().getString(), this.getContentX() + 25, this.getContentY() + 7, Color.WHITE.getRGB());
156+
guiGraphics.drawString(font, registryName.getNamespace(), this.getContentX() + 25, this.getContentY() + 17, Color.GRAY.getRGB());
156157

157-
graphics.renderItem(this.stack, left, top + 7);
158+
guiGraphics.renderItem(this.stack, this.getContentX(), this.getContentY() + 7);
158159
}
159160

160161
@Override
@@ -163,7 +164,7 @@ public Component getNarration() {
163164
}
164165

165166
@Override
166-
public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) {
167+
public boolean mouseClicked(MouseButtonEvent event, boolean bl) {
167168
this.parent.setSelected(this);
168169
return false;
169170
}

common/src/main/java/pro/mikey/xray/screens/ScanConfigureScreen.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.client.gui.components.SpriteIconButton;
88
import net.minecraft.client.gui.layouts.GridLayout;
99
import net.minecraft.client.gui.layouts.Layout;
10+
import net.minecraft.client.input.MouseButtonEvent;
1011
import net.minecraft.client.renderer.RenderPipelines;
1112
import net.minecraft.client.resources.language.I18n;
1213
import net.minecraft.network.chat.Component;
@@ -197,8 +198,8 @@ public void renderExtra(GuiGraphics graphics, int x, int y, float partialTicks)
197198
}
198199

199200
@Override
200-
public boolean mouseClicked(double x, double y, int mouse) {
201-
if (oreName.mouseClicked(x, y, mouse))
201+
public boolean mouseClicked(MouseButtonEvent mouseButtonEvent, boolean bl) {
202+
if (oreName.mouseClicked(mouseButtonEvent, bl))
202203
this.setFocused(oreName);
203204

204205
if (oreName.isFocused() && !oreNameCleared) {
@@ -211,7 +212,7 @@ public boolean mouseClicked(double x, double y, int mouse) {
211212
oreName.setValue(this.selectBlock.getName().getString());
212213
}
213214

214-
return super.mouseClicked(x, y, mouse);
215+
return super.mouseClicked(mouseButtonEvent, bl);
215216
}
216217

217218
@Override

common/src/main/java/pro/mikey/xray/screens/ScanManageScreen.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import net.minecraft.client.gui.components.Button;
77
import net.minecraft.client.gui.components.EditBox;
88
import net.minecraft.client.gui.components.ObjectSelectionList;
9+
import net.minecraft.client.input.KeyEvent;
10+
import net.minecraft.client.input.MouseButtonEvent;
911
import net.minecraft.client.renderer.RenderPipelines;
1012
import net.minecraft.client.renderer.entity.ItemRenderer;
1113
import net.minecraft.client.resources.language.I18n;
@@ -152,13 +154,13 @@ public void init() {
152154
}
153155

154156
@Override
155-
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
156-
if (!search.isFocused() && keyCode == XRay.OPEN_GUI_KEY.key.getValue()) {
157+
public boolean keyPressed(KeyEvent keyEvent) {
158+
if (!search.isFocused() && keyEvent.key() == XRay.OPEN_GUI_KEY.key.getValue()) {
157159
this.onClose();
158160
return true;
159161
}
160162

161-
return super.keyPressed(keyCode, scanCode, modifiers);
163+
return super.keyPressed(keyEvent);
162164
}
163165

164166
private void updateSearch() {
@@ -178,17 +180,17 @@ public void tick() {
178180
}
179181

180182
@Override
181-
public boolean mouseClicked(double x, double y, int mouse) {
182-
if (search.mouseClicked(x, y, mouse))
183+
public boolean mouseClicked(MouseButtonEvent event, boolean bl) {
184+
if (search.mouseClicked(event, bl))
183185
this.setFocused(search);
184186

185-
if (mouse == 1 && distButtons.isMouseOver(x, y)) {
187+
if (event.button() == 1 && distButtons.isMouseOver(event.x(), event.y())) {
186188
ScanController.INSTANCE.decrementCurrentDist();
187189
distButtons.setMessage(Component.translatable("xray.input.distance", ScanController.INSTANCE.getVisualRadius()));
188190
distButtons.playDownSound(Minecraft.getInstance().getSoundManager());
189191
}
190192

191-
return super.mouseClicked(x, y, mouse);
193+
return super.mouseClicked(event, bl);
192194
}
193195

194196
@Override
@@ -226,8 +228,8 @@ class ScanEntryScroller extends ObjectSelectionList<ScanEntryScroller.ScanSlot>
226228
ScanEntryScroller(int x, int y, int width, int height, ScanManageScreen parent) {
227229
super(ScanManageScreen.this.minecraft, width - 2, height, (ScanManageScreen.this.height / 2) - (height / 2) + 10, SLOT_HEIGHT);
228230
this.parent = parent;
231+
this.setX((parent.getWidth() / 2) - (width / 2) - 36);
229232
this.updateEntries();
230-
this.setX(x + 2);
231233
}
232234

233235
@Override
@@ -240,11 +242,11 @@ protected int scrollBarX() {
240242
return this.getX() + this.getRowWidth() + 6;
241243
}
242244

243-
public void setSelected(@Nullable ScanManageScreen.ScanEntryScroller.ScanSlot entry, int mouse) {
245+
public void setSelected(@Nullable ScanManageScreen.ScanEntryScroller.ScanSlot entry, MouseButtonEvent mouse) {
244246
if (entry == null)
245247
return;
246248

247-
if (ScanManageScreen.hasShiftDown()) {
249+
if (mouse.hasShiftDown()) {
248250
Minecraft.getInstance().setScreen(new ScanConfigureScreen(entry.entry, ScanManageScreen::new));
249251
return;
250252
}
@@ -293,25 +295,25 @@ public static class ScanSlot extends ObjectSelectionList.Entry<ScanSlot> {
293295
}
294296

295297
@Override
296-
public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) {
298+
public void renderContent(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean hovering, float partialTicks) {
297299
Font font = Minecraft.getInstance().font;
298300

299-
guiGraphics.drawString(font, this.entry.name(), left + 25, top + 7, 0xFFFFFFFF);
300-
guiGraphics.drawString(font, this.entry.enabled() ? "Enabled" : "Disabled", left + 25, top + 17, this.entry.enabled() ? Color.GREEN.getRGB() : Color.RED.getRGB());
301+
guiGraphics.drawString(font, this.entry.name(), this.getContentX() + 25, this.getContentY() + 7, 0xFFFFFFFF);
302+
guiGraphics.drawString(font, this.entry.enabled() ? "Enabled" : "Disabled", this.getContentX() + 25, this.getContentY() + 17, this.entry.enabled() ? Color.GREEN.getRGB() : Color.RED.getRGB());
301303

302-
guiGraphics.renderItem(this.icon, left, top + 7);
304+
guiGraphics.renderItem(this.icon, this.getContentX(), this.getContentY() + 7);
303305

304306
var stack = guiGraphics.pose();
305307
stack.pushMatrix();
306308

307-
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, ScanManageScreen.CIRCLE, (left + entryWidth) - 23, (int) (top + (entryHeight / 2f) - 9), 0, 0, 14, 14, 14, 14, 0x7F000000);
308-
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, ScanManageScreen.CIRCLE, (left + entryWidth) - 21, (int) (top + (entryHeight / 2f) - 7), 0, 0, 10, 10, 10, 10, 0xFF000000 | this.entry.colorInt());
309+
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, ScanManageScreen.CIRCLE, (this.getContentX() + this.getWidth()) - 23, (int) (this.getContentY() + (this.getHeight() / 2f) - 9), 0, 0, 14, 14, 14, 14, 0x7F000000);
310+
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, ScanManageScreen.CIRCLE, (this.getContentX() + this.getWidth()) - 21, (int) (this.getContentY() + (this.getHeight() / 2f) - 7), 0, 0, 10, 10, 10, 10, 0xFF000000 | this.entry.colorInt());
309311

310312
stack.popMatrix();
311313
}
312314

313315
@Override
314-
public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int mouse) {
316+
public boolean mouseClicked(MouseButtonEvent mouse, boolean bl) {
315317
this.parent.setSelected(this, mouse);
316318
return false;
317319
}

common/src/main/java/pro/mikey/xray/screens/helpers/GuiBase.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.client.gui.screens.Screen;
77
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
88
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
9+
import net.minecraft.client.input.CharacterEvent;
910
import net.minecraft.client.renderer.RenderPipelines;
1011
import net.minecraft.locale.Language;
1112
import net.minecraft.network.chat.Component;
@@ -33,10 +34,10 @@ public GuiBase(boolean hasSide) {
3334
public abstract void renderExtra(GuiGraphics guiGraphics, int x, int y, float partialTicks);
3435

3536
@Override
36-
public boolean charTyped(char keyTyped, int __unknown) {
37-
super.charTyped(keyTyped, __unknown);
37+
public boolean charTyped(CharacterEvent characterEvent) {
38+
super.charTyped(characterEvent);
3839

39-
if (keyTyped == 1 && minecraft.player != null) {
40+
if (characterEvent.codepoint() == 1 && minecraft.player != null) {
4041
minecraft.player.closeContainer();
4142
}
4243

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
accessWidener v1 named
22
accessible field net/minecraft/client/renderer/RenderPipelines MATRICES_FOG_SNIPPET Lcom/mojang/blaze3d/pipeline/RenderPipeline$Snippet;
33
accessible field net/minecraft/client/renderer/RenderPipelines GLOBALS_SNIPPET Lcom/mojang/blaze3d/pipeline/RenderPipeline$Snippet;
4-
accessible field net/minecraft/client/KeyMapping key Lcom/mojang/blaze3d/platform/InputConstants$Key;
4+
accessible field net/minecraft/client/KeyMapping key Lcom/mojang/blaze3d/platform/InputConstants$Key;
5+
accessible field net/minecraft/client/renderer/LevelRenderer targets Lnet/minecraft/client/renderer/LevelTargetBundle;

fabric/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ loom {
1616
mods {
1717
"xray" {
1818
sourceSet sourceSets.main
19+
sourceSet("main", project(":common"))
1920
}
2021
}
2122

0 commit comments

Comments
 (0)