Skip to content

Commit e68688f

Browse files
committed
add: "Render Item on Item Pickup Log" setting
1 parent 784d8b0 commit e68688f

File tree

4 files changed

+51
-22
lines changed

4 files changed

+51
-22
lines changed

src/main/java/codes/biscuit/skyblockaddons/core/feature/FeatureSetting.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public enum FeatureSetting {
126126
CLASS_COLORED_TEAMMATE("settings.classColoredTeammate", Feature.SHOW_DUNGEON_TEAMMATE_NAME_OVERLAY),
127127
DRAW_LOCK_ONLY_WHEN_HOVERED("settings.drawLockOnlyWhenHovered", Feature.LOCK_SLOTS),
128128
FARMING_TOOLS_PREVIEW("settings.showFarmingToolsPreview", Feature.SHOW_BACKPACK_PREVIEW),
129+
RENDER_ITEM_ON_LOG("settings.renderItemOnLog", Feature.ITEM_PICKUP_LOG),
129130

130131
DISCORD_RP_DETAILS("messages.firstStatus", Feature.DISCORD_RPC),
131132
DISCORD_RP_STATE("messages.secondStatus", Feature.DISCORD_RPC),

src/main/java/codes/biscuit/skyblockaddons/listeners/RenderListener.java

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ public class RenderListener {
149149
new SlayerArmorProgress(new ItemStack(Items.leather_helmet))
150150
};
151151

152+
private static final List<ItemDiff> DUMMY_PICKUP_LOG = Collections.unmodifiableList(Arrays.asList(
153+
new ItemDiff(ColorCode.DARK_PURPLE + "Forceful Ember Chestplate", 1, new ItemStack(Items.chainmail_chestplate)),
154+
new ItemDiff("Boat", -1, new ItemStack(Items.boat)),
155+
new ItemDiff(ColorCode.BLUE + "Aspect of the End", 1, new ItemStack(Items.diamond_sword))
156+
));
157+
152158
private static final Pattern DUNGEON_STAR_PATTERN = Pattern.compile("(?:(?:§[a-f0-9])?✪)+(?:§[a-f0-9]?[➊-➒])?");
153159

154160
private static EntityZombie revenant;
@@ -2521,7 +2527,7 @@ public static void renderItem(ItemStack item, float x, float y, float scale) {
25212527
RenderHelper.enableGUIStandardItemLighting();
25222528

25232529
GlStateManager.pushMatrix();
2524-
if (scale > 1) {
2530+
if (scale != 1) {
25252531
GlStateManager.scale(scale, scale, 1F);
25262532
}
25272533
GlStateManager.translate(x / scale, y / scale, 0);
@@ -2551,24 +2557,31 @@ public static void renderItemAndOverlay(ItemStack item, String name, float x, fl
25512557
GlStateManager.disableDepth();
25522558
}
25532559

2554-
private static final List<ItemDiff> DUMMY_PICKUP_LOG = Collections.unmodifiableList(Arrays.asList(
2555-
new ItemDiff(ColorCode.DARK_PURPLE + "Forceful Ember Chestplate", 1, new ItemStack(Items.chainmail_chestplate)),
2556-
new ItemDiff("Boat", -1, new ItemStack(Items.boat)),
2557-
new ItemDiff(ColorCode.BLUE + "Aspect of the End", 1, new ItemStack(Items.diamond_sword))
2558-
));
2559-
2560+
@SuppressWarnings("IntegerDivisionInFloatingPointContext")
25602561
public void drawItemPickupLog(float scale, ButtonLocation buttonLocation) {
2561-
float x = main.getConfigValuesManager().getActualX(Feature.ITEM_PICKUP_LOG);
2562-
float y = main.getConfigValuesManager().getActualY(Feature.ITEM_PICKUP_LOG);
2562+
Feature feature = Feature.ITEM_PICKUP_LOG;
2563+
float x = main.getConfigValuesManager().getActualX(feature);
2564+
float y = main.getConfigValuesManager().getActualY(feature);
25632565

2564-
boolean downwards = Feature.ITEM_PICKUP_LOG.getAnchorPoint().isOnTop();
2566+
boolean downwards = feature.getAnchorPoint().isOnTop();
2567+
boolean renderItemStack = feature.isEnabled(FeatureSetting.RENDER_ITEM_ON_LOG);
25652568

2566-
int lineHeight = 8 + 1; // 1 pixel spacer
2567-
int height = lineHeight * 3 - 1;
2569+
int heightSpacer = renderItemStack ? 6 : 1;
2570+
int lineHeight = MC.fontRendererObj.FONT_HEIGHT + heightSpacer; // + pixel spacer
2571+
int height = lineHeight * DUMMY_PICKUP_LOG.size();
25682572
int width = MC.fontRendererObj.getStringWidth("+ 1x Forceful Ember Chestplate");
25692573

2574+
if (renderItemStack) {
2575+
width += 18;
2576+
}
2577+
25702578
x = transformX(x, width, scale, false);
25712579
y = transformY(y, height, scale);
2580+
// X/Y Alignment
2581+
if (renderItemStack) {
2582+
x += 9;
2583+
y += (heightSpacer / 2) * DUMMY_PICKUP_LOG.size();
2584+
}
25722585

25732586
if (buttonLocation != null) {
25742587
buttonLocation.checkHoveredAndDrawBox(x, x + width, y, y + height, scale);
@@ -2582,18 +2595,29 @@ public void drawItemPickupLog(float scale, ButtonLocation buttonLocation) {
25822595
if (buttonLocation != null) {
25832596
log = DUMMY_PICKUP_LOG;
25842597
}
2598+
String spacing = renderItemStack ? " " : " "; // space width is 4
25852599
for (ItemDiff itemDiff : log) {
2586-
String text = String.format(
2587-
"%s %sx §r%s",
2588-
itemDiff.getAmount() > 0 ? "§a+" : "§c-",
2589-
Math.abs(itemDiff.getAmount()), itemDiff.getDisplayName()
2590-
);
2591-
float stringY = y + (i * lineHeight);
2592-
if (!downwards) {
2593-
stringY = y + height - (i * lineHeight) - 8;
2600+
float stringY;
2601+
if (downwards) {
2602+
stringY = y + (i * lineHeight) + heightSpacer / 2;
2603+
} else {
2604+
stringY = y + height - (i * lineHeight) - 9 - heightSpacer / 2;
25942605
}
25952606

2607+
String countText = String.format(
2608+
"%s %sx",
2609+
itemDiff.getAmount() > 0 ? "§a+" : "§c-",
2610+
Math.abs(itemDiff.getAmount())
2611+
);
2612+
String text = countText + spacing + "§r" + itemDiff.getDisplayName();
25962613
DrawUtils.drawText(text, x, stringY, 0xFFFFFFFF);
2614+
if (renderItemStack) {
2615+
renderItem(
2616+
itemDiff.getItemStack(),
2617+
x + MC.fontRendererObj.getStringWidth(countText) + 2,
2618+
stringY - heightSpacer / 2 - 1
2619+
);
2620+
}
25972621
i++;
25982622
}
25992623

src/main/resources/defaults.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@
169169
"coords": [
170170
84.5,
171171
17.0
172-
]
172+
],
173+
"settings": {
174+
"RENDER_ITEM_ON_LOG": true
175+
}
173176
},
174177
"DONT_RESET_CURSOR_INVENTORY": {
175178
"value": true

src/main/resources/lang/en_US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@
258258
"xAllignment": "X Allignment",
259259
"classColoredTeammate": "Class Colored Outline",
260260
"drawLockOnlyWhenHovered": "Draw Lock Icon only when hovered with mouse",
261-
"showFarmingToolsPreview": "Show Preview for Farming Tools"
261+
"showFarmingToolsPreview": "Show Preview for Farming Tools",
262+
"renderItemOnLog": "Render Item on Item Pickup Log"
262263
},
263264
"messages": {
264265
"enchants": "Enchants",

0 commit comments

Comments
 (0)