Skip to content

Commit a4206d3

Browse files
committed
Optimize the logic of deduplication
Remove some comments and unused codes
1 parent 1bf285c commit a4206d3

4 files changed

Lines changed: 5 additions & 72 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ parchment_mappings_version=2025.12.20
2626
mod_id=emi_patternizer
2727
mod_name=EMI Patternizer
2828
mod_license=GNU LGPL 3.0
29-
mod_version=0.2.0
29+
mod_version=0.2.1
3030
mod_group_id=io.github.linkfgfgui
3131
mod_authors=link-fgfgui
3232
mod_description=Automatically Encoding Patterns from the EMI Recipe Tree.

src/main/java/io/github/linkfgfgui/emi_patternizer/Patternize.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,12 @@ public static boolean containsAllItems(List<EmiStack> stackList) {
4848
public static void Encode(long initDelay, Minecraft minecraft, EmiRecipe recipe, PatternEncodingTermScreen<?> screen, PatternEncodingTermMenu menu, LocalPlayer player, MultiPlayerGameMode gameMode, int encodedPatternSlot) {
4949
CompletableFuture.delayedExecutor(initDelay, TimeUnit.MILLISECONDS).execute(() -> {
5050
minecraft.execute(() -> {
51-
// if (containsAllItems(recipe)) {
52-
// return;
53-
// }
5451
EmiRecipeFiller.performFill(recipe, screen, EmiCraftContext.Type.FILL_BUTTON, EmiCraftContext.Destination.NONE, 1);
5552
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f));
5653
});
5754
CompletableFuture.delayedExecutor(per, TimeUnit.MILLISECONDS).execute(() -> {
5855
minecraft.execute(() -> {
59-
if (containsAllItems(recipe)) {
60-
return;
61-
}
6256
menu.encode();
63-
recipe.getOutputs().forEach(emiStack -> EncodedItems.add(emiStack.getId().toString()));
6457
LOGGER.debug("Operating: {}, EncodedItems: {}", operating, EncodedItems);
6558
});
6659
CompletableFuture.delayedExecutor(per, TimeUnit.MILLISECONDS).execute(() ->
@@ -84,6 +77,7 @@ public static long CreateTasks(long delay, Minecraft minecraft, @Nullable List<M
8477
for (MaterialNode node : nodes) {
8578
if (node.recipe != null && node.recipe.getId() != null && !containsAllItems(node.recipe)) {
8679
Encode(delay, minecraft, node.recipe, screen, menu, player, gameMode, encodedPatternSlot);
80+
node.recipe.getOutputs().forEach(emiStack -> EncodedItems.add(emiStack.getId().toString()));
8781
delay += (3 * per + 20);
8882
}
8983
if (node.children != null) {
@@ -98,7 +92,7 @@ public static void onKeyPressed(ScreenEvent.KeyPressed.Post event) {
9892
if (event.getScreen() instanceof PatternEncodingTermScreen<?> screen) {
9993
LOGGER.debug("Catched");
10094
PatternEncodingTermMenu menu = screen.getMenu();
101-
int blankPatternSlot = ((AEBaseMenuAccessor) menu).getSlotsBySemantic().get(SlotSemantics.BLANK_PATTERN).getFirst().index;
95+
// int blankPatternSlot = ((AEBaseMenuAccessor) menu).getSlotsBySemantic().get(SlotSemantics.BLANK_PATTERN).getFirst().index;
10296
int encodedPatternSlot = ((AEBaseMenuAccessor) menu).getSlotsBySemantic().get(SlotSemantics.ENCODED_PATTERN).getFirst().index;
10397
if (BoM.craftingMode) {
10498
LOGGER.debug("BoM crafting");
@@ -109,12 +103,12 @@ public static void onKeyPressed(ScreenEvent.KeyPressed.Post event) {
109103

110104
MaterialNode goal = BoM.tree.goal;
111105
operating = true;
112-
LOGGER.debug(String.valueOf(operating));
106+
LOGGER.debug("operating started");
113107
long maxDelay = CreateTasks(0, minecraft, List.of(goal), screen, menu, player, gameMode, encodedPatternSlot);
114108
CompletableFuture.delayedExecutor(maxDelay + per, TimeUnit.MILLISECONDS).execute(() -> {
115109
operating = false;
116110
BoM.craftingMode=false;
117-
LOGGER.debug(String.valueOf(operating));
111+
LOGGER.debug("operating finished");
118112
});
119113
}
120114
} else {

src/main/java/io/github/linkfgfgui/emi_patternizer/ReloadMemory.java

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -59,62 +59,6 @@ public static void onScreenOpening(ScreenEvent.Opening event) {
5959
}
6060
});
6161
});
62-
63-
64-
//
65-
// ((PatternAccessTermScreenAccessor) menu).getPinnedHosts().forEach(patternContainer ->
66-
// {
67-
//
68-
// patternContainer.getGrid().getNodes().forEach(node ->
69-
// {
70-
// if (node instanceof IPatternAccessTermMenuHost) {
71-
// node.
72-
// }
73-
// }
74-
// );
75-
// });
76-
77-
78-
//
79-
// CompletableFuture.delayedExecutor(1000, TimeUnit.MILLISECONDS).execute(() -> minecraft.execute(() -> {
80-
// IPatternAccessTermMenuHost node = ((PatternAccessTermMenuAccessor) menu).getHost();
81-
// if (node == null) {
82-
// LOGGER.error("PatternAccessTermMenu node is null");
83-
// return;
84-
// }
85-
// LOGGER.info(node.toString());
86-
// }));
87-
88-
// IGridNode node = ((PatternAccessTermMenuAccessor) menu).getHost().getGridNode();
89-
// if (node == null) {
90-
// LOGGER.error("PatternAccessTermMenu node is null");
91-
// return;
92-
// }
93-
// IGrid grid = node.getGrid();
94-
// ICraftingService craftingService = grid.getService(ICraftingService.class);
95-
// if (craftingService == null) {
96-
//
97-
//
98-
// LOGGER.error("craftingService is null");
99-
// return;
100-
// }
101-
// craftingService.getCraftables(AEKeyFilter.none()).forEach(
102-
// key -> {
103-
// LOGGER.info(key.getId().toString());
104-
// }
105-
// );
106-
107-
108-
// // 获取所有提供样板的“提供者”
109-
// for (ICraftingProvider provider : craftingService.getCraftables()) {
110-
// // 在 1.21 中,直接获取该提供者当前可用的所有样板详情
111-
// for (IPatternDetails pattern : provider.getAvailablePatterns()) {
112-
// // pattern 就是具体的样板信息(输入、输出等)
113-
// System.out.println("输出物品: " + pattern.getPrimaryOutput());
114-
// }
115-
// }
116-
117-
11862
}
11963
}
12064
}

src/main/java/io/github/linkfgfgui/emi_patternizer/mixin/AbstractContainerScreenMixin.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@
1414

1515
@Mixin(AbstractContainerScreen.class)
1616
public class AbstractContainerScreenMixin {
17-
private static final Logger LOGGER = LogUtils.getLogger();
1817
@Inject(method = "onClose", at = @At("HEAD"), cancellable = true)
1918
private void preventScreenClose(CallbackInfo ci) {
2019
Screen currentScreen = (Screen) (Object) this;
2120
if (currentScreen instanceof PatternEncodingTermScreen<?> && Patternize.operating) {
2221
ci.cancel();
23-
LOGGER.debug("try to cancel");
24-
25-
}else{
26-
LOGGER.debug(currentScreen.toString());
2722
}
2823
}
2924
}

0 commit comments

Comments
 (0)