Skip to content
Open
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 @@ -53,9 +53,10 @@ protected void craft(Block b, BlockMenu menu, Player p) {
if (menu.fits(recipe.output, layout.outputSlots())) {
ItemStack output = recipe.output.clone();
onSuccessfulCraft(menu, output);
p.sendMessage(ChatColor.GREEN + "已合成: " + ItemUtils.getItemName(output));
menu.pushItem(output, layout.outputSlots());
recipe.consume(input);
Comment on lines +56 to 58

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The success message is now sent before the actual crafting operations (menu.pushItem() and recipe.consume()) complete. While this may not cause functional issues due to the prior menu.fits() check, it's semantically incorrect to notify the player of success before the operation is fully completed. Consider keeping the message after recipe.consume(input) to ensure it's sent only after all crafting operations have successfully completed.

Suggested change
p.sendMessage(ChatColor.GREEN + "已合成: " + ItemUtils.getItemName(output));
menu.pushItem(output, layout.outputSlots());
recipe.consume(input);
menu.pushItem(output, layout.outputSlots());
recipe.consume(input);
p.sendMessage(ChatColor.GREEN + "已合成: " + ItemUtils.getItemName(output));

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

显然这一定会complete 而且pushItem会修改output导致最终输出的内容不正确

p.sendMessage(ChatColor.GREEN + "已合成: " + ItemUtils.getItemName(output));

} else {
p.sendMessage(ChatColor.GOLD + "空间不足!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ public MachineRecipeType(String key, ItemStack item) {
public void register(ItemStack[] recipe, ItemStack result) {
callbacks.forEach(c -> c.accept(recipe, result));
recipes.put(recipe, result);
super.register(recipe, result);
}

public void sendRecipesTo(BiConsumer<ItemStack[], ItemStack> callback) {
recipes.forEach(callback);
callbacks.add(callback);
}

Comment thread
ybw0014 marked this conversation as resolved.
public void unregister(ItemStack[] recipe, ItemStack result) {
recipes.remove(recipe, result);

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unregister method is incomplete. It only removes the recipe from the local recipes map but doesn't notify the registered callbacks or call super.unregister() (if such a method exists in the parent class). This is inconsistent with the register method which calls both callbacks and super.register(). Consider whether callbacks should be notified of unregistrations, and check if the parent class has an unregister method that should be called.

Suggested change
recipes.remove(recipe, result);
recipes.remove(recipe, result);
callbacks.forEach(c -> c.accept(recipe, result));
super.unregister(recipe, result);

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

旧api没有unregister

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@ParametersAreNonnullByDefault
public abstract class TickingMenuBlock extends MenuBlock {
private int tickCount = 0;
Comment thread
ybw0014 marked this conversation as resolved.
Comment thread
ybw0014 marked this conversation as resolved.

public TickingMenuBlock(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
Expand All @@ -35,11 +36,27 @@ public void tick(Block b, SlimefunItem item, Config data) {
}
}

@Override
public void uniqueTick() {
TickingMenuBlock.this.updateMachineTickCount();
TickingMenuBlock.this.uniqueTick();
}
});
}

protected abstract void tick(Block b, BlockMenu menu);

private void updateMachineTickCount(){
++this.tickCount;
}

Comment thread
ybw0014 marked this conversation as resolved.
protected int machineTickCount(){
return this.tickCount;
}

Comment thread
ybw0014 marked this conversation as resolved.
protected void uniqueTick(){

}
protected boolean synchronous() {
return false;
}
Expand Down
Loading