Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #290

Merged
merged 8 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public String getRefMapperConfig() {
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
//OptiFabric Compatibility
if (mixinClassName.endsWith("WorldRendererMixin") && OPTIFABRIC_LOADED) return false;

return true;
}

Expand All @@ -41,7 +41,7 @@ public List<String> getMixins() {
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
//Do nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static class General {
@ConfigEntry.Category("itemTooltip")
@ConfigEntry.Gui.CollapsibleObject()
public ItemTooltip itemTooltip = new ItemTooltip();

@ConfigEntry.Category("itemInfoDisplay")
@ConfigEntry.Gui.CollapsibleObject
public ItemInfoDisplay itemInfoDisplay = new ItemInfoDisplay();
Expand Down Expand Up @@ -401,7 +401,7 @@ public static class ItemTooltip {
public boolean enableBazaarPrice = true;
public boolean enableMuseumDate = true;
}

public static class ItemInfoDisplay {
@ConfigEntry.Gui.Tooltip
public boolean attributeShardInfo = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.entity.passive.BatEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;

@Mixin(BatEntity.class)
public abstract class BatEntityMixin extends AmbientEntity {
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/me/xmrvizzy/skyblocker/mixin/DrawContextMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class DrawContextMixin {

@Shadow
public abstract void fill(RenderLayer layer, int x1, int x2, int y1, int y2, int color);

@Shadow
public abstract int drawText(TextRenderer textRenderer, @Nullable String text, int x, int y, int color, boolean shadow);

Expand Down Expand Up @@ -96,35 +96,35 @@ public abstract class DrawContextMixin {
matrices.pop();
RenderSystem.enableDepthTest();
}

@Inject(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At("HEAD"))
private void skyblocker$renderAttributeShardDisplay(@Arg TextRenderer textRenderer, @Arg ItemStack stack, @Arg(ordinal = 0) int x, @Arg(ordinal = 1) int y, @Local(argsOnly = true) LocalRef<String> countOverride) {
if (!SkyblockerConfig.get().general.itemInfoDisplay.attributeShardInfo) return;

NbtCompound nbt = stack.getNbt();

if (Utils.isOnSkyblock() && nbt != null && nbt.contains("ExtraAttributes")) {
NbtCompound extraAttributes = nbt.getCompound("ExtraAttributes");

if (extraAttributes.getString("id").equals("ATTRIBUTE_SHARD")) {
NbtCompound attributesTag = extraAttributes.getCompound("attributes");
String[] attributes = attributesTag.getKeys().toArray(String[]::new);

if (attributes.length != 0) {
String attributeId = attributes[0];
int attributeLevel = attributesTag.getInt(attributeId);

//Set item count
countOverride.set(Integer.toString(attributeLevel));

//Draw the attribute name
this.matrices.push();
this.matrices.translate(0f, 0f, 200f);

String attributeInitials = AttributeShards.getShortName(attributeId);

this.drawText(textRenderer, attributeInitials, x, y, Formatting.AQUA.getColorValue(), true);

this.matrices.pop();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

@Mixin(WorldRenderer.class)
public class WorldRendererMixin {

@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z"))
private boolean skyblocker$shouldStarredMobGlow(boolean original, @Local Entity entity, @Share("isGlowingStarredMob") LocalBooleanRef isGlowingStarredMob) {
boolean isAStarredMobThatShouldGlow = SkyblockerConfig.get().locations.dungeons.starredMobGlow && StarredMobGlow.shouldMobGlow(entity);

isGlowingStarredMob.set(isAStarredMobThatShouldGlow);

return original || isAStarredMobThatShouldGlow;
}

@ModifyVariable(method = "render", at = @At("STORE"), ordinal = 0)
private int skyblocker$modifyGlowColor(int color, @Local Entity entity, @Share("isGlowingStarredMob") LocalBooleanRef isGlowingStarredMob) {
return isGlowingStarredMob.get() ? StarredMobGlow.getGlowColor(entity) : color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
Expand Down Expand Up @@ -156,7 +155,6 @@ public static boolean renderPreview(DrawContext context, int index, int mouseX,
RenderSystem.enableDepthTest();

MatrixStack matrices = context.getMatrices();
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
for (int i = 9; i < storage[index].size(); ++i) {
int itemX = x + (i - 9) % 9 * 18 + 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class AttributeShards {
private static final Object2ObjectOpenHashMap<String, String> ID_2_SHORT_NAME = new Object2ObjectOpenHashMap<>();

static {
//Weapons
ID_2_SHORT_NAME.put("arachno", "A");
Expand All @@ -18,11 +18,11 @@ public class AttributeShards {
ID_2_SHORT_NAME.put("mana_steal", "MS");
ID_2_SHORT_NAME.put("midas_touch", "MT");
ID_2_SHORT_NAME.put("undead", "U");

//Swords & Bows
ID_2_SHORT_NAME.put("warrior", "W");
ID_2_SHORT_NAME.put("deadeye", "DE");

//Armor or Equipment
ID_2_SHORT_NAME.put("arachno_resistance", "AR");
ID_2_SHORT_NAME.put("blazing_resistance", "BR");
Expand All @@ -40,7 +40,7 @@ public class AttributeShards {
ID_2_SHORT_NAME.put("speed", "S");
ID_2_SHORT_NAME.put("undead_resistance", "UR");
ID_2_SHORT_NAME.put("veteran", "V");

//Fishing Gear
ID_2_SHORT_NAME.put("blazing_fortune", "BF");
ID_2_SHORT_NAME.put("fishing_experience", "FE");
Expand All @@ -50,9 +50,9 @@ public class AttributeShards {
ID_2_SHORT_NAME.put("fishing_speed", "FS");
ID_2_SHORT_NAME.put("hunter", "H");
ID_2_SHORT_NAME.put("trophy_hunter", "TH");

}

public static String getShortName(String id) {
return ID_2_SHORT_NAME.getOrDefault(id, "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ private static int renameItem(FabricClientCommandSource source, Text text) {
}
} else {
//If the text is provided then set the item's custom name to it

//Set italic to false if it hasn't been changed (or was already false)
Style currentStyle = text.getStyle();
((MutableText) text).setStyle(currentStyle.withItalic((currentStyle.isItalic() ? true : false)));

customItemNames.put(itemUuid, text);
SkyblockerConfig.save();
source.sendFeedback(Text.translatable("skyblocker.customItemNames.added"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ private static Text getCoinsMessage(double price, int count) {
return message;
}


private static Text getMotesMessage(int price, int count) {
float motesMultiplier = SkyblockerConfig.get().locations.rift.mcGrubberStacks * 0.05f + 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
Expand All @@ -16,7 +14,7 @@
import net.minecraft.util.Formatting;

@Environment(value = EnvType.CLIENT)
public class ItemListWidget extends RecipeBookWidget implements Drawable, Selectable {
public class ItemListWidget extends RecipeBookWidget {
private int parentWidth;
private int parentHeight;
private int leftOffset;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package me.xmrvizzy.skyblocker.skyblock.itemlist;

import java.util.List;
import java.util.function.Function;
import java.util.ArrayList;

import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.OrderedText;
Expand Down Expand Up @@ -55,17 +49,17 @@ public void renderTooltip(DrawContext context, int mouseX, int mouseY) {
MinecraftClient client = MinecraftClient.getInstance();
List<Text> tooltip = Screen.getTooltipFromItem(client, this.itemStack);
List<OrderedText> orderedTooltip = new ArrayList<>();

for(int i = 0; i < tooltip.size(); i++) {
orderedTooltip.add(tooltip.get(i).asOrderedText());
}

client.currentScreen.setTooltip(orderedTooltip);
}

@Override
protected void appendClickableNarrations(NarrationMessageBuilder builder) {
// TODO Auto-generated method stub

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
craftText = textRenderer.trimToWidth(craftText, MAX_TEXT_WIDTH) + ELLIPSIS;
}
context.drawTextWithShadow(textRenderer, craftText, this.parentX + 11, this.parentY + 31, 0xffffffff);

//Item name
Text resultText = this.recipeResults.get(this.currentPage).result.getName();
if (textRenderer.getWidth(Formatting.strip(resultText.getString())) > MAX_TEXT_WIDTH) {
drawTooltip(textRenderer, context, resultText, this.parentX + 11, this.parentY + 43, mouseX, mouseY);
resultText = Text.literal(getLegacyFormatting(resultText.getString()) + textRenderer.trimToWidth(Formatting.strip(resultText.getString()), MAX_TEXT_WIDTH) + ELLIPSIS).setStyle(resultText.getStyle());
}
context.drawTextWithShadow(textRenderer, resultText, this.parentX + 11, this.parentY + 43, 0xffffffff);

//Arrow pointing to result item from the recipe
context.drawTextWithShadow(textRenderer, "▶", this.parentX + 96, this.parentY + 90, 0xaaffffff);
}
Expand All @@ -149,7 +149,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
if (this.nextPageButton.active) this.nextPageButton.render(context, mouseX, mouseY, delta);
RenderSystem.enableDepthTest();
}

/**
* Used for drawing tooltips over truncated text
*/
Expand All @@ -160,7 +160,7 @@ private void drawTooltip(TextRenderer textRenderer, DrawContext context, Text te
}
RenderSystem.enableDepthTest();
}

/**
* @see #drawTooltip(TextRenderer, DrawContext, Text, int, int, int, int)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class QuickNav {
private static final String dungeonHubIconNbt = "{id:\"minecraft:player_head\",Count:1,tag:{SkullOwner:{Id:[I;1605800870,415127827,-1236127084,15358548],Properties:{textures:[{Value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MWQ1YjI3M2ZmMGJjNTBjOTYwYjJjZDg2ZWVmMWM0MGExYjk0MDMyYWU3MWU3NTQ3NWE1NjhhODI1NzQyMSJ9fX0=\"}]}}}}";

public static void init() {
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
if (Utils.isOnSkyblock() && SkyblockerConfig.get().quickNav.enableQuickNav && screen instanceof HandledScreen<?> && client.player != null && !client.player.isCreative()) {
String screenTitle = screen.getTitle().getString().trim();
List<QuickNavButton> buttons = QuickNav.init(screenTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ public void renderButton(DrawContext context, int mouseX, int mouseY, float delt
@Override
protected void appendClickableNarrations(NarrationMessageBuilder builder) {
// TODO Auto-generated method stub

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public Widget instanceFrom(String name, JsonObject widget) {
}

// reflect something together for the "normal" ones.
// TODO don't get package list for every widget; do it once and cache.
// fine for now, as this would only shorten the load time anyways

// list all packages that might contain widget classes
// using Package isn't reliable, as some classes might not be loaded yet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public void stackWidgetsVert(int screenH) {
}

public void stackWidgetsHoriz(int screenW) {
// TODO not centered (?)
int compWidth = -ScreenConst.WIDGET_PAD;
for (Widget wid : primary) {
compWidth += wid.getWidth() + ScreenConst.WIDGET_PAD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Comparator;

// this widget shows a list of obtained dungeon buffs
// TODO: could be more pretty, can't be arsed atm

public class DungeonBuffWidget extends Widget {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void updateContent() {
PlainTextComponent ptc = new PlainTextComponent(entry);
this.addComponent(ptc);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class PlayerComponent extends Component {
private final Identifier tex;

public PlayerComponent(PlayerListEntry ple) {

boolean plainNames = SkyblockerConfig.get().general.tabHud.plainPlayerNames;
Team team = ple.getScoreboardTeam();
String username = ple.getProfile().getName();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ public static void updateFromScoreboard(MinecraftClient client) {
leaveSkyblock();
}
}

private static boolean isConnectedToHypixel(MinecraftClient client) {
String serverAddress = (client.getCurrentServerEntry() != null) ? client.getCurrentServerEntry().address.toLowerCase() : "";
String serverBrand = (client.player != null && client.player.getServerBrand() != null) ? client.player.getServerBrand() : "";
boolean isOnHypixel = (serverAddress.equalsIgnoreCase(ALTERNATE_HYPIXEL_ADDRESS) || serverAddress.contains("hypixel.net") || serverAddress.contains("hypixel.io") || serverBrand.contains("Hypixel BungeeCord"));

return isOnHypixel;
}

Expand Down