Skip to content

Commit 48497cb

Browse files
committed
Add hotkey 'refillListClear' to clear refill and ran out items
Fix refill list to immediately refresh in UI when there are changes to it
1 parent a6e7628 commit 48497cb

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Features:
5555
* If new config 'highlightRefillInInventory' is not disabled, lacking item in containers will be highlighted
5656
* Color may be controlled by new config 'highlightRefillInInventoryColor'
5757
* If config 'blockInfoLinesEnabled' is not disabled, lacking items will be shown as an Info Overlay
58+
* If hotkey 'refillListClear' is pressed, the list of lacking items will be cleared
5859
* EasyPlace: Addition of config 'easyPlacePickBlockHalt'
5960
* Reduces player speed if Pick Block fails or picks a Shulker Box
6061
* EasyPlace and Material List: Addition of configs 'easyPlaceAvoidBeacons' and 'materialListAvoidBeacons', and hotkeys 'beaconRegister', 'beaconUnregister' and 'beaconUnregisterAll'

src/main/java/fi/dy/masa/litematica/config/Hotkeys.java

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class Hotkeys
5151
public static final ConfigHotkey PICK_BLOCK_FIRST = new ConfigHotkey("pickBlockFirst", "BUTTON_3", KeybindSettings.PRESS_ALLOWEXTRA).apply(HOTKEYS_KEY);
5252
public static final ConfigHotkey PICK_BLOCK_LAST = new ConfigHotkey("pickBlockLast", "", KeybindSettings.MODIFIER_INGAME).apply(HOTKEYS_KEY);
5353
public static final ConfigHotkey PICK_BLOCK_TOGGLE = new ConfigHotkey("pickBlockToggle", "M,BUTTON_3").apply(HOTKEYS_KEY);
54+
public static final ConfigHotkey REFILL_LIST_CLEAR = new ConfigHotkey("refillListClear", "", "Clear list of items to refill and restock");
5455
public static final ConfigHotkey RENDER_INFO_OVERLAY = new ConfigHotkey("renderInfoOverlay", "I", KeybindSettings.PRESS_ALLOWEXTRA).apply(HOTKEYS_KEY);
5556
public static final ConfigHotkey RENDER_OVERLAY_THROUGH_BLOCKS = new ConfigHotkey("renderOverlayThroughBlocks", "RIGHT_CONTROL", KeybindSettings.PRESS_ALLOWEXTRA).apply(HOTKEYS_KEY);
5657
public static final ConfigHotkey RERENDER_SCHEMATIC = new ConfigHotkey("rerenderSchematic", "F3,M").apply(HOTKEYS_KEY);
@@ -141,6 +142,7 @@ public class Hotkeys
141142
PICK_BLOCK_FIRST,
142143
PICK_BLOCK_LAST,
143144
PICK_BLOCK_TOGGLE,
145+
REFILL_LIST_CLEAR,
144146
RENDER_INFO_OVERLAY,
145147
RENDER_OVERLAY_THROUGH_BLOCKS,
146148
RERENDER_SCHEMATIC,

src/main/java/fi/dy/masa/litematica/event/KeyCallbacks.java

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public static void init(MinecraftClient mc)
8484
Hotkeys.PICK_BLOCK_FIRST.getKeybind().setCallback(callbackHotkeys);
8585
Hotkeys.PICK_BLOCK_LAST.getKeybind().setCallback(callbackHotkeys);
8686
Hotkeys.PICK_BLOCK_TOGGLE.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(Configs.Generic.PICK_BLOCK_ENABLED));
87+
Hotkeys.REFILL_LIST_CLEAR.getKeybind().setCallback(callbackHotkeys);
8788
Hotkeys.RERENDER_SCHEMATIC.getKeybind().setCallback(callbackHotkeys);
8889
Hotkeys.SAVE_AREA_AS_IN_MEMORY_SCHEMATIC.getKeybind().setCallback(callbackHotkeys);
8990
Hotkeys.SAVE_AREA_AS_SCHEMATIC_TO_FILE.getKeybind().setCallback(callbackHotkeys);
@@ -516,6 +517,12 @@ else if (key == Hotkeys.PICK_BLOCK_LAST.getKeybind())
516517

517518
return false;
518519
}
520+
else if (key == Hotkeys.REFILL_LIST_CLEAR.getKeybind())
521+
{
522+
AddonUtils.clearRefillItems();
523+
AddonUtils.clearRanOutItems();
524+
return true;
525+
}
519526
else if (key == Hotkeys.SAVE_AREA_AS_SCHEMATIC_TO_FILE.getKeybind())
520527
{
521528
return SchematicUtils.saveSchematic(false);

src/main/java/fi/dy/masa/litematica/util/AddonUtils.java

+15
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,20 @@ public static void addRanOutItem(ItemStack stack) {
464464
}
465465

466466
ranOutItems.add(stack.copy());
467+
468+
lastRefillTimeCheck = 0;
467469
}
468470

469471
public static List<ItemStack> getRanOutItems() {
470472
return ranOutItems;
471473
}
472474

475+
public static void clearRanOutItems() {
476+
ranOutItems.clear();
477+
478+
lastRefillTimeCheck = 0;
479+
}
480+
473481
public static void addRefillItem(ItemStack stack) {
474482
for (var item : refillItems) {
475483
if (InventoryUtils.areStacksEqualIgnoreNbt(item, stack)) {
@@ -478,12 +486,19 @@ public static void addRefillItem(ItemStack stack) {
478486
}
479487

480488
refillItems.add(stack.copy());
489+
490+
lastRefillTimeCheck = 0;
481491
}
482492

483493
public static List<ItemStack> getRefillItems() {
484494
return refillItems;
485495
}
486496

497+
public static void clearRefillItems() {
498+
refillItems.clear();
499+
500+
lastRefillTimeCheck = 0;
501+
}
487502

488503
public static void checkClearLastItems() {
489504
if (!Configs.Generic.HIGHLIGHT_REFILL_IN_INV.getBooleanValue()) return;

0 commit comments

Comments
 (0)