aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gradle.properties2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java10
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/config/modmenu/ModMenuEntry.java2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/ChatHudListenerMixin.java21
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/ChatScreenMixin.java29
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java33
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/ClientPlayerEntityMixin.java34
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java141
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java60
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/mixin/MinecraftClientMixin.java12
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/HotbarSlotLock.java41
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java11
-rw-r--r--src/main/resources/assets/skyblocker/lang/en_us.json7
-rw-r--r--src/main/resources/assets/skyblocker/lang/ru_ru.json7
-rw-r--r--src/main/resources/assets/skyblocker/textures/gui/bars.pngbin0 -> 1212 bytes
-rw-r--r--src/main/resources/assets/skyblocker/textures/gui/icons.pngbin1350 -> 0 bytes
-rw-r--r--src/main/resources/assets/skyblocker/textures/gui/slot_lock.pngbin0 -> 1187 bytes
-rw-r--r--src/main/resources/skyblocker.mixins.json3
19 files changed, 300 insertions, 115 deletions
diff --git a/gradle.properties b/gradle.properties
index 9afdefff..652f7d18 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,6 +7,6 @@ loader_version=0.11.1
fabric_api_version=0.29.3+1.16
# Mod Properties
-mod_version = 1.0.2
+mod_version = 1.0.4
maven_group = me.xmrvizzy
archives_base_name = skyblocker
diff --git a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
index 7116aa78..efd746e7 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
@@ -1,6 +1,7 @@
package me.xmrvizzy.skyblocker;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import me.xmrvizzy.skyblocker.skyblock.HotbarSlotLock;
import me.xmrvizzy.skyblocker.utils.Utils;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.MinecraftClient;
@@ -11,6 +12,7 @@ public class SkyblockerMod implements ClientModInitializer {
@Override
public void onInitializeClient() {
+ HotbarSlotLock.init();
SkyblockerConfig.init();
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
index 8b48fc8f..1e451ea2 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
@@ -6,6 +6,9 @@ import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
+import java.util.ArrayList;
+import java.util.List;
+
@Config(name = "skyblocker")
public class SkyblockerConfig implements ConfigData {
@@ -27,14 +30,13 @@ public class SkyblockerConfig implements ConfigData {
@ConfigEntry.Category("bars")
@ConfigEntry.Gui.CollapsibleObject(startExpanded = true)
public Bars bars = new Bars();
+
+ @ConfigEntry.Gui.Excluded
+ public List<Integer> lockedSlots = new ArrayList<>();
}
public static class Bars {
public boolean enableBars = true;
- @ConfigEntry.ColorPicker()
- public int healthColor = 0xff5555;
- @ConfigEntry.ColorPicker()
- public int manaColor = 0x55ffff;
}
public static class Locations {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/modmenu/ModMenuEntry.java b/src/main/java/me/xmrvizzy/skyblocker/config/modmenu/ModMenuEntry.java
index 80949a21..cd0c7ad2 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/config/modmenu/ModMenuEntry.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/config/modmenu/ModMenuEntry.java
@@ -3,9 +3,9 @@ package me.xmrvizzy.skyblocker.config.modmenu;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
+import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
@Environment(EnvType.CLIENT)
public class ModMenuEntry implements ModMenuApi {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatHudListenerMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatHudListenerMixin.java
index 28058b0b..159fbcee 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatHudListenerMixin.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatHudListenerMixin.java
@@ -27,22 +27,31 @@ public class ChatHudListenerMixin {
}
if (Utils.isSkyblock) {
- if (SkyblockerConfig.get().locations.dwarvenMines.solvePuzzler && msg.contains("[NPC]") && msg.contains("Puzzler"))
+ if (SkyblockerConfig.get().locations.dwarvenMines.solvePuzzler &&
+ msg.contains("[NPC]") && msg.contains("Puzzler"))
Puzzler.puzzler(msg);
- if (SkyblockerConfig.get().messages.hideAbility && msg.contains("This ability is currently on cooldown for ") || msg.contains("No more charges, next one in "))
+ if (SkyblockerConfig.get().messages.hideAbility &&
+ msg.contains("This ability is currently on cooldown for ") ||
+ msg.contains("No more charges, next one in ") ||
+ msg.contains("This ability is on cooldown for "))
ci.cancel();
- if (SkyblockerConfig.get().messages.hideHeal && msg.contains("You healed ") && msg.contains(" health!") || msg.contains(" healed you for "))
+ if (SkyblockerConfig.get().messages.hideHeal &&
+ msg.contains("You healed ") &&
+ msg.contains(" health!") || msg.contains(" healed you for "))
ci.cancel();
- if (SkyblockerConfig.get().messages.hideAOTE && msg.contains("There are blocks in the way!"))
+ if (SkyblockerConfig.get().messages.hideAOTE &&
+ msg.contains("There are blocks in the way!"))
ci.cancel();
- if (SkyblockerConfig.get().messages.hideImplosion && msg.contains("Your Implosion hit "))
+ if (SkyblockerConfig.get().messages.hideImplosion &&
+ msg.contains("Your Implosion hit "))
ci.cancel();
- if (SkyblockerConfig.get().messages.hideMoltenWave && msg.contains("Your Molten Wave hit "))
+ if (SkyblockerConfig.get().messages.hideMoltenWave &&
+ msg.contains("Your Molten Wave hit "))
ci.cancel();
}
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatScreenMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatScreenMixin.java
new file mode 100644
index 00000000..e85a64fc
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatScreenMixin.java
@@ -0,0 +1,29 @@
+package me.xmrvizzy.skyblocker.mixin;
+
+import net.minecraft.client.gui.screen.ChatScreen;
+import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.widget.TextFieldWidget;
+import net.minecraft.text.Text;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(ChatScreen.class)
+public class ChatScreenMixin extends Screen {
+
+ @Shadow protected TextFieldWidget chatField;
+
+ protected ChatScreenMixin(Text title) {
+ super(title);
+ }
+
+ @Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;openScreen(Lnet/minecraft/client/gui/screen/Screen;)V", ordinal = 1), cancellable = true)
+ public void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
+ String[] split = this.chatField.getText().trim().toLowerCase().split(" ");
+ if (split.length > 0 && split[0].contentEquals("/skb")) {
+ cir.setReturnValue(true);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java
new file mode 100644
index 00000000..26012b21
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java
@@ -0,0 +1,33 @@
+package me.xmrvizzy.skyblocker.mixin;
+
+import com.mojang.authlib.GameProfile;
+import com.mojang.brigadier.CommandDispatcher;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.network.ClientPlayNetworkHandler;
+import net.minecraft.command.CommandSource;
+import net.minecraft.network.ClientConnection;
+import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal;
+
+@Mixin(ClientPlayNetworkHandler.class)
+public class ClientPlayNetworkHandlerMixin {
+
+ @Shadow private CommandDispatcher<CommandSource> commandDispatcher;
+
+ @Inject(method = "<init>", at = @At("RETURN"))
+ private void init(MinecraftClient client, Screen screen, ClientConnection connection, GameProfile profile, CallbackInfo ci) {
+ commandDispatcher.register(literal("skb"));
+ }
+
+ @Inject(method = "onCommandTree", at = @At("RETURN"))
+ private void onCommandTree(CommandTreeS2CPacket packet, CallbackInfo ci) {
+ commandDispatcher.register(literal("skb"));
+ }
+} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/ClientPlayerEntityMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/ClientPlayerEntityMixin.java
new file mode 100644
index 00000000..343794b1
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/ClientPlayerEntityMixin.java
@@ -0,0 +1,34 @@
+package me.xmrvizzy.skyblocker.mixin;
+
+import com.mojang.authlib.GameProfile;
+import me.xmrvizzy.skyblocker.skyblock.HotbarSlotLock;
+import me.xmrvizzy.skyblocker.utils.Utils;
+import net.minecraft.client.network.AbstractClientPlayerEntity;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.client.world.ClientWorld;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(ClientPlayerEntity.class)
+public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity {
+
+ public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
+ super(world, profile);
+ }
+
+ @Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
+ public void sendChatMessage(String message, CallbackInfo ci) {
+ String[] split = message.toLowerCase().split(" ");
+ if (split.length > 0 && split[0].contentEquals("/skb")) {
+ ci.cancel();
+ }
+ }
+
+ @Inject(method = "dropSelectedItem", at = @At("HEAD"), cancellable = true)
+ public void dropSelectedItem(boolean dropEntireStack, CallbackInfoReturnable<Boolean> cir) {
+ if (Utils.isSkyblock) HotbarSlotLock.handleDropSelectedItem(this.inventory.selectedSlot, cir);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java
index 01c9f0a6..eba58fd0 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java
@@ -1,9 +1,9 @@
package me.xmrvizzy.skyblocker.mixin;
-import com.mojang.blaze3d.systems.RenderSystem;
import me.xmrvizzy.skyblocker.SkyblockerMod;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.skyblock.Attribute;
+import me.xmrvizzy.skyblocker.skyblock.HotbarSlotLock;
import me.xmrvizzy.skyblocker.skyblock.dungeon.DungeonMap;
import me.xmrvizzy.skyblocker.utils.Utils;
import net.fabricmc.api.EnvType;
@@ -13,6 +13,8 @@ import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Final;
@@ -23,12 +25,14 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import java.awt.*;
-
@Environment(EnvType.CLIENT)
@Mixin(InGameHud.class)
public abstract class InGameHudMixin extends DrawableHelper {
- private static final Identifier ICONS = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/icons.png");
+ private static final Identifier SLOT_LOCK = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/slot_lock.png");
+ private static final Identifier BARS = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/bars.png");
+
+ private MatrixStack hotbarMatrices;
+ private int hotbarSlotIndex;
@Shadow
@Final
@@ -48,6 +52,31 @@ public abstract class InGameHudMixin extends DrawableHelper {
return Text.of(msg);
}
+ @Inject(method = "renderHotbar", at = @At("HEAD"))
+ public void renderHotbar(float f, MatrixStack matrices, CallbackInfo ci) {
+ if (Utils.isSkyblock) {
+ hotbarMatrices = matrices;
+ hotbarSlotIndex = 0;
+ }
+ }
+
+ @Inject(method = "renderHotbarItem", at = @At("HEAD"))
+ public void renderHotbarItem(int i, int j, float f, PlayerEntity player, ItemStack item, CallbackInfo ci) {
+ if (Utils.isSkyblock) {
+ if (HotbarSlotLock.isLocked(hotbarSlotIndex)) {
+ this.client.getTextureManager().bindTexture(SLOT_LOCK);
+ this.drawTexture(hotbarMatrices, i, j, 0, 0,16, 16);
+ }
+ hotbarSlotIndex++;
+ }
+ }
+
+ @Inject(method = "renderExperienceBar", at = @At("HEAD"), cancellable = true)
+ private void renderExperienceBar(MatrixStack matrices, int x, CallbackInfo ci) {
+ if (Utils.isSkyblock && SkyblockerConfig.get().general.bars.enableBars)
+ ci.cancel();
+ }
+
@Inject(method = "renderStatusBars", at = @At("HEAD"), cancellable = true)
private void renderStatusBars(MatrixStack matrices, CallbackInfo ci) {
if (Utils.isDungeons && SkyblockerConfig.get().locations.dungeons.enableMap)
@@ -58,7 +87,6 @@ public abstract class InGameHudMixin extends DrawableHelper {
ci.cancel();
renderBars(matrices);
}
-
this.client.getTextureManager().bindTexture(DrawableHelper.GUI_ICONS_TEXTURE);
}
}
@@ -69,70 +97,51 @@ public abstract class InGameHudMixin extends DrawableHelper {
ci.cancel();
}
-
private void renderBars(MatrixStack matrices) {
- this.client.getTextureManager().bindTexture(ICONS);
- this.client.getProfiler().push("skyblockBars");
- {
- int left = this.scaledWidth / 2 - 91;
- int hpWidth = getWidth(Attribute.HEALTH.get(), Attribute.MAX_HEALTH.get());
- int manaWidth = getWidth(Attribute.MANA.get(), Attribute.MAX_MANA.get());
-
- renderBar(matrices, left, hpWidth, SkyblockerConfig.get().general.bars.healthColor);
- renderBar(matrices, left + 71 + 40, manaWidth, SkyblockerConfig.get().general.bars.manaColor);
- }
- this.client.getProfiler().pop();
-
- this.client.getProfiler().push("skyblockTexts");
- {
- int left = this.scaledWidth / 2 - 90;
- String hpText = Attribute.HEALTH.get() + "/" + Attribute.MAX_HEALTH.get();
- String manaText = Attribute.MANA.get() + "/" + Attribute.MAX_MANA.get();
- int hpOffset = (71 - this.getFontRenderer().getWidth(hpText)) / 2;
- int manaOffset = (71 - this.getFontRenderer().getWidth(manaText)) / 2;
-
- renderText(matrices, hpText, left + hpOffset, SkyblockerConfig.get().general.bars.healthColor);
- renderText(matrices, manaText, left + 71 + 40 + manaOffset, SkyblockerConfig.get().general.bars.manaColor);
- }
- this.client.getProfiler().pop();
- }
-
- private void renderBar(MatrixStack matrices, int left, int filled, int color) {
- Color co = new Color(color);
- int top = this.scaledHeight - 36;
-
- RenderSystem.enableBlend();
- RenderSystem.color4f((float) co.getRed() / 255, (float) co.getGreen() / 255, (float) co.getBlue() / 255, 1.0F);
- this.drawTexture(matrices, left, top, 0, 0, 71, 5);
-
- if (filled > 0) {
- this.drawTexture(matrices, left, top, 0, 5, filled, 5);
- }
-
- RenderSystem.disableBlend();
- RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ int left = this.scaledWidth / 2 - 91;
+ int top = this.scaledHeight - 35;
+
+ int health = (int) ((float)Attribute.HEALTH.get()/(float)Attribute.MAX_HEALTH.get() * 33.0F);
+ if (health > 33) health = 33;
+ int mana = (int) ((float)Attribute.MANA.get()/(float)Attribute.MAX_MANA.get() * 33.0F);
+ if (mana > 33) mana = 33;
+ int xp = (int) (this.client.player.experienceProgress * 33.0F);
+
+ // Icons
+ this.client.getTextureManager().bindTexture(BARS);
+ this.drawTexture(matrices, left, top, 0, 0, 9, 9);
+ this.drawTexture(matrices, left + 47, top, 9, 0, 7, 9);
+ this.drawTexture(matrices, left + 92, top, 16, 0, 9, 9);
+ this.drawTexture(matrices, left + 139, top, 25, 0, 9, 9);
+
+ // Empty Bars
+ this.drawTexture(matrices, left + 10, top + 1, 0, 9, 33, 7);
+ this.drawTexture(matrices, left + 55, top + 1, 0, 9, 33, 7);
+ this.drawTexture(matrices, left + 102, top + 1, 0, 9, 33, 7);
+ this.drawTexture(matrices, left + 149, top + 1, 0, 9, 33, 7);
+
+ // Progress Bars
+ this.drawTexture(matrices, left + 10, top + 1, 0, 16, health, 7);
+ this.drawTexture(matrices, left + 55, top + 1, 0, 23, mana, 7);
+ this.drawTexture(matrices, left + 102, top + 1, 0, 30, 33, 7);
+ this.drawTexture(matrices, left + 149, top + 1, 0, 37, xp, 7);
+
+ // Progress Texts
+ renderText(matrices, Attribute.HEALTH.get(), left + 11, top, 16733525);
+ renderText(matrices, Attribute.MANA.get(), left + 56, top, 5636095);
+ renderText(matrices, Attribute.DEFENCE.get(), left + 103, top, 12106180);
+ renderText(matrices, this.client.player.experienceLevel, left + 150, top, 8453920);
}
- private void renderText(MatrixStack matrices, String str, int left, int color) {
- int top = this.scaledHeight - 42;
- this.getFontRenderer().draw(matrices, str, (float) (left + 1), (float) top, 0);
- this.getFontRenderer().draw(matrices, str, (float) (left - 1), (float) top, 0);
- this.getFontRenderer().draw(matrices, str, (float) left, (float) (top + 1), 0);
- this.getFontRenderer().draw(matrices, str, (float) left, (float) (top - 1), 0);
- this.getFontRenderer().draw(matrices, str, (float) left, (float) top, color);
- }
+ private void renderText(MatrixStack matrices, int value, int left, int top, int color) {
+ String text = Integer.toString(value);
+ int x = left + (33 - this.getFontRenderer().getWidth(text)) / 2;
+ int y = top - 3;
- private int getWidth(int current, int max) {
- int width = 0;
- if (current != 0) {
- if (current > max) {
- width = 71;
- } else {
- width = current * 71 / max;
- }
- } else {
- width = 0;
- }
- return width;
+ this.getFontRenderer().draw(matrices, text, (float) (x + 1), (float) y, 0);
+ this.getFontRenderer().draw(matrices, text, (float) (x - 1), (float) y, 0);
+ this.getFontRenderer().draw(matrices, text, (float) x, (float) (y + 1), 0);
+ this.getFontRenderer().draw(matrices, text, (float) x, (float) (y - 1), 0);
+ this.getFontRenderer().draw(matrices, text, (float) x, (float) y, color);
}
} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java
index 97e7b08d..41a8fd8a 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/ItemRendererMixin.java
@@ -2,7 +2,6 @@ package me.xmrvizzy.skyblocker.mixin;
import com.mojang.blaze3d.systems.RenderSystem;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
-import me.xmrvizzy.skyblocker.skyblock.Attribute;
import me.xmrvizzy.skyblocker.utils.ItemUtils;
import me.xmrvizzy.skyblocker.utils.Utils;
import net.minecraft.client.font.TextRenderer;
@@ -28,38 +27,41 @@ public abstract class ItemRendererMixin {
@Inject(method = "renderGuiItemOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At("HEAD"))
public void renderItemBar(TextRenderer renderer, ItemStack stack, int x, int y, @Nullable String countLabel, CallbackInfo ci) {
- if (Utils.isSkyblock && SkyblockerConfig.get().locations.dwarvenMines.enableDrillFuel && !stack.isEmpty()) {
- if (!stack.hasTag() && !stack.getTag().contains("ExtraAttributes")) return;
- CompoundTag attributes = stack.getTag().getCompound("ExtraAttributes");
- if (!attributes.contains("drill_fuel")) return;
+ if (Utils.isSkyblock && SkyblockerConfig.get().locations.dwarvenMines.enableDrillFuel) {
+ if (!stack.isEmpty()) {
+ CompoundTag tag = stack.getTag();
+ if (tag != null && tag.contains("ExtraAttributes")) {
+ if (tag.getCompound("ExtraAttributes").contains("drill_fuel")) {
+ float current = 3000.0F;
+ float max = 3000.0F;
- float current = 3000.0F;
- float max = 3000.0F;
+ for (String line : ItemUtils.getLore(stack)) {
+ if (line.contains("Fuel: ")) {
+ String clear = Pattern.compile("[^0-9 /]").matcher(line).replaceAll("").trim();
+ String[] split = clear.split("/");
+ current = Integer.parseInt(split[0]);
+ max = Integer.parseInt(split[1]) * 1000;
+ }
+ }
- for (String line : ItemUtils.getLore(stack)) {
- if (line.contains("Fuel: ")) {
- String clear = Pattern.compile("[^0-9 /]").matcher(line).replaceAll("").trim();
- String[] split = clear.split("/");
- current = Integer.parseInt(split[0]);
- max = Integer.parseInt(split[1]) * 1000;
+ RenderSystem.disableDepthTest();
+ RenderSystem.disableTexture();
+ RenderSystem.disableAlphaTest();
+ RenderSystem.disableBlend();
+ Tessellator tessellator = Tessellator.getInstance();
+ BufferBuilder buffer = tessellator.getBuffer();
+ float hue = Math.max(0.0F, 1.0F - (max - current) / max);
+ int width = Math.round(current / max * 13.0F);
+ int rgb = MathHelper.hsvToRgb(hue / 3.0F, 1.0F, 1.0F);
+ this.renderGuiQuad(buffer, x + 2, y + 13, 13, 2, 0,0,0,255);
+ this.renderGuiQuad(buffer, x + 2, y + 13, width, 1, rgb >> 16 & 255, rgb >> 8 & 255, rgb & 255, 255);
+ RenderSystem.enableBlend();
+ RenderSystem.enableAlphaTest();
+ RenderSystem.enableTexture();
+ RenderSystem.enableDepthTest();
+ }
}
}
-
- RenderSystem.disableDepthTest();
- RenderSystem.disableTexture();
- RenderSystem.disableAlphaTest();
- RenderSystem.disableBlend();
- Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder buffer = tessellator.getBuffer();
- float hue = Math.max(0.0F, 1.0F - (max - current) / max);
- int width = Math.round(current / max * 13.0F);
- int rgb = MathHelper.hsvToRgb(hue / 3.0F, 1.0F, 1.0F);
- this.renderGuiQuad(buffer, x + 2, y + 13, 13, 2, 0,0,0,255);
- this.renderGuiQuad(buffer, x + 2, y + 13, width, 1, rgb >> 16 & 255, rgb >> 8 & 255, rgb & 255, 255);
- RenderSystem.enableBlend();
- RenderSystem.enableAlphaTest();
- RenderSystem.enableTexture();
- RenderSystem.enableDepthTest();
}
}
} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/MinecraftClientMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/MinecraftClientMixin.java
index 20443eb3..5ef5b0b4 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/mixin/MinecraftClientMixin.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/MinecraftClientMixin.java
@@ -1,8 +1,13 @@
package me.xmrvizzy.skyblocker.mixin;
import me.xmrvizzy.skyblocker.SkyblockerMod;
+import me.xmrvizzy.skyblocker.skyblock.HotbarSlotLock;
+import me.xmrvizzy.skyblocker.utils.Utils;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.network.ClientPlayerEntity;
+import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -10,8 +15,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {
+ @Shadow @Nullable public ClientPlayerEntity player;
+
@Inject(method = "tick", at = @At("HEAD"))
public void tick(CallbackInfo ci) {
SkyblockerMod.onTick();
}
+
+ @Inject(method = "handleInputEvents", at = @At("HEAD"))
+ public void handleInputEvents(CallbackInfo ci) {
+ if (Utils.isSkyblock) HotbarSlotLock.handleInputEvents(player);
+ }
} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/HotbarSlotLock.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/HotbarSlotLock.java
new file mode 100644
index 00000000..42b9db1d
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/HotbarSlotLock.java
@@ -0,0 +1,41 @@
+package me.xmrvizzy.skyblocker.skyblock;
+
+import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
+import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.client.options.KeyBinding;
+import org.lwjgl.glfw.GLFW;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import java.util.List;
+
+public class HotbarSlotLock {
+ public static KeyBinding hotbarSlotLock;
+
+ public static void init() {
+ hotbarSlotLock = KeyBindingHelper.registerKeyBinding(new KeyBinding(
+ "key.hotbarSlotLock",
+ GLFW.GLFW_KEY_H,
+ "key.categories.skyblocker"
+ ));
+ }
+
+ public static boolean isLocked(int slot) {
+ return SkyblockerConfig.get().general.lockedSlots.contains(slot);
+ }
+
+ public static void handleDropSelectedItem(int slot, CallbackInfoReturnable<Boolean> cir) {
+ if (isLocked(slot)) cir.setReturnValue(false);
+ }
+
+ public static void handleInputEvents(ClientPlayerEntity player) {
+ while (hotbarSlotLock.wasPressed()) {
+ List<Integer> lockedSlots = SkyblockerConfig.get().general.lockedSlots;
+ int selected = player.inventory.selectedSlot;
+ if (!isLocked(player.inventory.selectedSlot)) lockedSlots.add(selected);
+ else lockedSlots.remove(Integer.valueOf(selected));
+ AutoConfig.getConfigHolder(SkyblockerConfig.class).save();
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java
index 7318bc3f..d9c20fde 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java
@@ -9,6 +9,7 @@ import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.scoreboard.ScoreboardObjective;
import net.minecraft.scoreboard.ScoreboardPlayerScore;
import net.minecraft.scoreboard.Team;
+import org.w3c.dom.Attr;
import java.util.ArrayList;
import java.util.Collection;
@@ -25,6 +26,10 @@ public class Utils {
String[] sections = msg.split(" {3,}");
List<String> unused = new ArrayList<String>();
+ if (msg.contains("❤") && !msg.contains("❈") && sections.length == 2) {
+ Attribute.DEFENCE.set(0);
+ }
+
for (String section : sections) {
String clear = Pattern.compile("[^0-9 /]").matcher(section).replaceAll("").trim();
String[] split = clear.split("/");
@@ -35,7 +40,6 @@ public class Utils {
Attribute.MAX_HEALTH.set(Integer.parseInt(split[1]));
} else if (section.contains("❈")) {
Attribute.DEFENCE.set(Integer.parseInt(clear));
- unused.add(section);
} else if (section.contains("✎")) {
Attribute.MANA.set(Integer.parseInt(split[0]));
Attribute.MAX_MANA.set(Integer.parseInt(split[1]));
@@ -54,11 +58,14 @@ public class Utils {
if (sidebar.isEmpty()) return;
if (sidebar.get(sidebar.size() - 1).equals("www.hypixel.net")) {
- if (sidebar.get(0).equals("SKYBLOCK")) isSkyblock = true;
+ if (sidebar.get(0).contains("SKYBLOCK")) isSkyblock = true;
else isSkyblock = false;
if (isSkyblock && string.contains("The Catacombs")) isDungeons = true;
else isDungeons = false;
+ } else {
+ isSkyblock = false;
+ isDungeons = false;
}
}
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index 1d5a8367..590057a2 100644
--- a/src/main/resources/assets/skyblocker/lang/en_us.json
+++ b/src/main/resources/assets/skyblocker/lang/en_us.json
@@ -1,12 +1,13 @@
{
+ "key.categories.skyblocker": "Skyblocker",
+ "key.hotbarSlotLock": "Slot Lock (Hotbar)",
+
"text.autoconfig.skyblocker.title": "Skyblocker Settings",
"text.autoconfig.skyblocker.category.general": "General",
"text.autoconfig.skyblocker.option.general.apiKey": "Hypixel API Key (WIP)",
- "text.autoconfig.skyblocker.option.general.bars": "Health & Mana Bars",
+ "text.autoconfig.skyblocker.option.general.bars": "Health, Mana, Defence & XP Bars",
"text.autoconfig.skyblocker.option.general.bars.enableBars": "Enable Bars",
- "text.autoconfig.skyblocker.option.general.bars.healthColor": "Health Color",
- "text.autoconfig.skyblocker.option.general.bars.manaColor": "Mana Color",
"text.autoconfig.skyblocker.category.locations": "Locations",
"text.autoconfig.skyblocker.option.locations.dungeons": "Dungeons",
diff --git a/src/main/resources/assets/skyblocker/lang/ru_ru.json b/src/main/resources/assets/skyblocker/lang/ru_ru.json
index c3bed00e..0564ed32 100644
--- a/src/main/resources/assets/skyblocker/lang/ru_ru.json
+++ b/src/main/resources/assets/skyblocker/lang/ru_ru.json
@@ -1,12 +1,13 @@
{
+ "key.categories.skyblocker": "Skyblocker",
+ "key.hotbarSlotLock": "Блокировка слота (хотбар)",
+
"text.autoconfig.skyblocker.title": "Настройки Skyblocker",
"text.autoconfig.skyblocker.category.general": "Основные",
"text.autoconfig.skyblocker.option.general.apiKey": "Hypixel API-ключ (В РАЗРАБОТКЕ)",
- "text.autoconfig.skyblocker.option.general.bars": "Бары здоровья и маны",
+ "text.autoconfig.skyblocker.option.general.bars": "Бары здоровья, маны, защиты, опыта",
"text.autoconfig.skyblocker.option.general.bars.enableBars": "Включить бары",
- "text.autoconfig.skyblocker.option.general.bars.healthColor": "Цвет здоровья",
- "text.autoconfig.skyblocker.option.general.bars.manaColor": "Цвет маны",
"text.autoconfig.skyblocker.category.locations": "Локации",
"text.autoconfig.skyblocker.option.locations.dungeons": "Подземелья",
diff --git a/src/main/resources/assets/skyblocker/textures/gui/bars.png b/src/main/resources/assets/skyblocker/textures/gui/bars.png
new file mode 100644
index 00000000..0b700024
--- /dev/null
+++ b/src/main/resources/assets/skyblocker/textures/gui/bars.png
Binary files differ
diff --git a/src/main/resources/assets/skyblocker/textures/gui/icons.png b/src/main/resources/assets/skyblocker/textures/gui/icons.png
deleted file mode 100644
index 5eb23b84..00000000
--- a/src/main/resources/assets/skyblocker/textures/gui/icons.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/skyblocker/textures/gui/slot_lock.png b/src/main/resources/assets/skyblocker/textures/gui/slot_lock.png
new file mode 100644
index 00000000..98b4c65a
--- /dev/null
+++ b/src/main/resources/assets/skyblocker/textures/gui/slot_lock.png
Binary files differ
diff --git a/src/main/resources/skyblocker.mixins.json b/src/main/resources/skyblocker.mixins.json
index 8b6d3cbd..3e904f73 100644
--- a/src/main/resources/skyblocker.mixins.json
+++ b/src/main/resources/skyblocker.mixins.json
@@ -4,6 +4,9 @@
"compatibilityLevel": "JAVA_8",
"client": [
"ChatHudListenerMixin",
+ "ChatScreenMixin",
+ "ClientPlayerEntityMixin",
+ "ClientPlayNetworkHandlerMixin",
"InGameHudMixin",
"ItemRendererMixin",
"MinecraftClientMixin"