aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav
diff options
context:
space:
mode:
authorTrương Hoàng Long <longtruong2411@gmail.com>2023-03-29 04:01:16 +0200
committerGitHub <noreply@github.com>2023-03-29 04:01:16 +0200
commit71d1c240fbde9372afa8e2a2388218fff33eb04b (patch)
treee203e0dd40aecdf90ca659660902035805b73f51 /src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav
parent78215e4d9cf83635d7ab5a6474170ac673cae525 (diff)
parentb6c8fee9891d39c8d2af690757852a123c8ad4c2 (diff)
downloadSkyblocker-71d1c240fbde9372afa8e2a2388218fff33eb04b.tar.gz
Skyblocker-71d1c240fbde9372afa8e2a2388218fff33eb04b.tar.bz2
Skyblocker-71d1c240fbde9372afa8e2a2388218fff33eb04b.zip
Merge pull request #109 from Julienraptor01/1.19.3
Update to 1.19.3
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNav.java5
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java53
2 files changed, 40 insertions, 18 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNav.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNav.java
index 4ea7fb99..85ebd3a6 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNav.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNav.java
@@ -1,7 +1,12 @@
package me.xmrvizzy.skyblocker.skyblock.quicknav;
+import java.util.ArrayList;
+import java.util.List;
+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
+
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.StringNbtReader;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java
index ac381240..f35e60b2 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java
@@ -1,6 +1,7 @@
package me.xmrvizzy.skyblocker.skyblock.quicknav;
import com.mojang.blaze3d.systems.RenderSystem;
+
import me.xmrvizzy.skyblocker.mixin.HandledScreenAccessor;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -11,7 +12,6 @@ import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
-import net.minecraft.text.LiteralTextContent;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
@@ -20,11 +20,6 @@ public class QuickNavButton extends ClickableWidget {
private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
private static final Identifier BUTTON_TEXTURE = new Identifier("textures/gui/container/creative_inventory/tabs.png");
- @Override
- public void appendNarrations(NarrationMessageBuilder builder) {
-
- }
-
private int index;
private boolean toggled;
private int u;
@@ -33,7 +28,7 @@ public class QuickNavButton extends ClickableWidget {
private final ItemStack icon;
public QuickNavButton(int index, boolean toggled, String command, ItemStack icon) {
- super(0, 0, 28, 32, Text.empty());
+ super(0, 0, 26, 32, Text.empty());
this.index = index;
this.toggled = toggled;
this.command = command;
@@ -49,9 +44,11 @@ public class QuickNavButton extends ClickableWidget {
int w = ((HandledScreenAccessor)handledScreen).getBackgroundWidth();
int h = ((HandledScreenAccessor)handledScreen).getBackgroundHeight();
if (h > 166) --h; // why is this even a thing
- this.x = x + this.index % 6 * 28 + 4;
- this.y = this.index < 6 ? y - 28 : y + h - 4;
- this.u = 28;
+ // this.x = x + this.index % 6 * 28 + 4;
+ this.setX(x + this.index % 6 * 26 + 4);
+ // this.y = this.index < 6 ? y - 28 : y + h - 4;
+ this.setY(this.index < 6 ? y - 26 : y + h - 4);
+ this.u = 26;
this.v = (index < 6 ? 0 : 64) + (toggled ? 32 : 0);
}
}
@@ -60,7 +57,8 @@ public class QuickNavButton extends ClickableWidget {
public void onClick(double mouseX, double mouseY) {
if (!this.toggled) {
this.toggled = true;
- CLIENT.player.sendChatMessage(command, Text.of(command));
+ CLIENT.player.networkHandler.sendCommand(command.replace("/", ""));
+ // TODO : add null check with log error
}
}
@@ -72,22 +70,41 @@ public class QuickNavButton extends ClickableWidget {
// render button background
if (!this.toggled) {
if (this.index >= 6)
- this.drawTexture(matrices, this.x, this.y + 4, this.u, this.v + 4, this.width, this.height - 4);
+ // this.drawTexture(matrices, this.x, this.y + 4, this.u, this.v + 4, this.width, this.height - 4);
+ this.drawTexture(matrices, this.getX(), this.getY() + 4, this.u, this.v + 4, this.width, this.height - 4);
else
- this.drawTexture(matrices, this.x, this.y, this.u, this.v, this.width, this.height - 4);
- } else this.drawTexture(matrices, this.x, this.y, this.u, this.v, this.width, this.height);
+ // this.drawTexture(matrices, this.x, this.y, this.u, this.v, this.width, this.height - 4);
+ this.drawTexture(matrices, this.getX(), this.getY() - 2, this.u, this.v, this.width, this.height - 4);
+ // } else this.drawTexture(matrices, this.x, this.y, this.u, this.v, this.width, this.height);
+ } else {
+ matrices.push();
+ //Move the top buttons 2 pixels up if they're selected
+ if (this.index < 6) matrices.translate(0f, -2f, 0f);
+ this.drawTexture(matrices, this.getX(), this.getY(), this.u, this.v, this.width, this.height);
+ matrices.pop();
+ }
// render button icon
if (!this.toggled) {
if (this.index >= 6)
- CLIENT.getItemRenderer().renderInGui(this.icon,this.x + 6, this.y + 6);
+ // CLIENT.getItemRenderer().renderInGui(this.icon,this.x + 6, this.y + 6);
+ CLIENT.getItemRenderer().renderInGui(this.icon,this.getX() + 5, this.getY() + 6);
else
- CLIENT.getItemRenderer().renderInGui(this.icon,this.x + 6, this.y + 9);
+ // CLIENT.getItemRenderer().renderInGui(this.icon,this.x + 6, this.y + 9);
+ CLIENT.getItemRenderer().renderInGui(this.icon,this.getX() + 5, this.getY() + 7);
} else {
if (this.index >= 6)
- CLIENT.getItemRenderer().renderInGui(this.icon,this.x + 6, this.y + 9);
+ // CLIENT.getItemRenderer().renderInGui(this.icon,this.x + 6, this.y + 9);
+ CLIENT.getItemRenderer().renderInGui(this.icon,this.getX() + 5, this.getY() + 9);
else
- CLIENT.getItemRenderer().renderInGui(this.icon,this.x + 6, this.y + 6);
+ // CLIENT.getItemRenderer().renderInGui(this.icon,this.x + 6, this.y + 6);
+ CLIENT.getItemRenderer().renderInGui(this.icon,this.getX() + 5, this.getY() + 6);
}
RenderSystem.enableDepthTest();
}
+
+ @Override
+ protected void appendClickableNarrations(NarrationMessageBuilder builder) {
+ // TODO Auto-generated method stub
+
+ }
}