Skip to content

Commit

Permalink
feat: Add Trash Item tooltip to trash slot #150
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 27, 2024
1 parent d08ed09 commit 4bbb836
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ private static boolean runKeyBindings(Screen screen, int keyCode, int scanCode,
hintMessage.withStyle(ChatFormatting.GOLD);
showHint(Hints.LOCKED, hintMessage, 5000, true);
} else {
var hintMessage = Component.translatable("trashslot.hint.unlocked", ModKeyMappings.keyBindToggleSlotLock.getBinding().key().getDisplayName());
var hintMessage = Component.translatable("trashslot.hint.unlocked",
ModKeyMappings.keyBindToggleSlotLock.getBinding().key().getDisplayName());
hintMessage.withStyle(ChatFormatting.GOLD);
showHint(Hints.UNLOCKED, hintMessage, 5000, true);
}
Expand Down Expand Up @@ -305,8 +306,24 @@ public static void onBackgroundDrawn(ContainerScreenDrawEvent.Background event)
}

boolean isMouseSlot = screenAccessor.callIsHovering(trashSlot, event.getMouseX(), event.getMouseY());
if (isMouseSlot && screen.getMenu().getCarried().isEmpty() && trashSlot.hasItem()) {
event.getGuiGraphics().renderTooltip(Minecraft.getInstance().font, trashSlot.getItem(), event.getMouseX(), event.getMouseY());
if (isMouseSlot) {
if (screen.getMenu().getCarried().isEmpty() && trashSlot.hasItem()) {
event.getGuiGraphics().renderTooltip(Minecraft.getInstance().font, trashSlot.getItem(), event.getMouseX(), event.getMouseY());
} else {
if (TrashSlotConfig.getActive().instantDeletion) {
event.getGuiGraphics()
.renderTooltip(Minecraft.getInstance().font,
Component.translatable("tooltip.trashslot.destroy_item"),
event.getMouseX(),
event.getMouseY());
} else {
event.getGuiGraphics()
.renderTooltip(Minecraft.getInstance().font,
Component.translatable("tooltip.trashslot.trash_item"),
event.getMouseX(),
event.getMouseY());
}
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion common/src/main/resources/assets/trashslot/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
"trashslot.hint.deletedWhileHidden": "Item trashed!",
"trashslot.hint.deletionDenied": "Item cannot be trashed!",
"trashslot.hint.locked": "Trash slot locked. Press %s to unlock it.",
"trashslot.hint.unlocked": "Trash slot unlocked. Press %s to lock it."
"trashslot.hint.unlocked": "Trash slot unlocked. Press %s to lock it.",
"tooltip.trashslot.destroy_item": "Destroy Item",
"tooltip.trashslot.trash_item": "Trash Item"
}

0 comments on commit 4bbb836

Please sign in to comment.