Skip to content

Fix: 修复历史遗留问题#14

Open
m1919810 wants to merge 1 commit into
SlimefunGuguProject:masterfrom
m1919810:master
Open

Fix: 修复历史遗留问题#14
m1919810 wants to merge 1 commit into
SlimefunGuguProject:masterfrom
m1919810:master

Conversation

@m1919810

Copy link
Copy Markdown

Description

Code Changes

Related Issues

Checklist

  • [1 ] I have also tested the proposed changes with an addon.
  • [1 ] I followed the existing code standards and didn't mess up the formatting.
  • [1 ] I have added Nullable or Nonnull annotations to my methods
  • [1 ] I have added sufficient Unit Tests to cover my code.
  • [ 1] I updated the version in pom.xml according to semantic versioning.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request attempts to fix historical legacy issues by adding tick counting functionality to TickingMenuBlock, adding recipe unregistration support to MachineRecipeType, and adjusting the timing of a success message in CraftingBlock.

  • Added tick counting mechanism with tickCount, machineTickCount(), and uniqueTick() methods to TickingMenuBlock
  • Added unregister() method to MachineRecipeType for removing recipes
  • Modified register() in MachineRecipeType to call super.register()
  • Moved crafting success message in CraftingBlock to execute before item pushing and consumption

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
TickingMenuBlock.java Adds tick counting infrastructure with a tickCount field and related methods for tracking machine ticks
MachineRecipeType.java Adds unregister() method for recipe removal and calls parent register() method
CraftingBlock.java Reorders the crafting success message to appear before output pushing and input consumption

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

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

Comment on lines +56 to 58
p.sendMessage(ChatColor.GREEN + "已合成: " + ItemUtils.getItemName(output));
menu.pushItem(output, layout.outputSlots());
recipe.consume(input);

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导致最终输出的内容不正确

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants