Fix BBW block preview showing on all GT tools#5
Conversation
Summary of ChangesHello @tier940, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the block preview functionality from Better Builder's Wands was erroneously active on all GregTech tools, regardless of whether they were actual wands. The changes introduce a mechanism to correctly identify wand tools and suppress the preview for non-wand GT tools, thereby improving user experience and preventing unintended visual clutter. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
このプルリクエストは、Better Builder's Wandsのブロックプレビューがワンドだけでなく、すべてのGregTechツールで表示されてしまう問題を正しく修正しています。ItemGTToolWandMixinの変更は、ワンドではないツールに対してダミーのIWand実装を返すことで、プレビューを効果的に抑制しており、適切な修正です。
レビューでは、ItemGTToolWandMixin.javaに対して2つの改善提案をさせていただきました。1つ目は、リポジトリのスタイルガイドに準拠するためのコメントのスタイル修正です。2つ目は、パフォーマンス向上のため、繰り返し生成されるオブジェクトを静的な定数に置き換える提案です。
src/main/java/com/github/gtexpert/gtmt/mixins/bbw/ItemGTToolWandMixin.java
Show resolved
Hide resolved
| return new IWand() { | ||
|
|
||
| @Override | ||
| public int getMaxBlocks(ItemStack itemStack) { | ||
| return 0; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean placeBlock(ItemStack itemStack, EntityLivingBase entity) { | ||
| return false; | ||
| } | ||
| }; |
There was a problem hiding this comment.
この実装では、getWand()が非ワンドツールに対して呼び出されるたびに、新しい無名クラスのインスタンスが生成されます。このメソッドはプレビューのレンダリングなどで頻繁に呼び出される可能性があるため、パフォーマンスに影響を与える可能性があります。
このダミーのIWandはステートレスなので、static finalな定数として一度だけインスタンス化し、それを返すようにリファクタリングすることで、不要なオブジェクト生成を避けることができます。
例:
public abstract class ItemGTToolWandMixin implements IWandItem {
private static final IWand DUMMY_WAND = new IWand() {
@Override
public int getMaxBlocks(ItemStack itemStack) { return 0; }
@Override
public boolean placeBlock(ItemStack itemStack, EntityLivingBase entity) { return false; }
};
// ...
@Override
public IWand getWand() {
if (!gtexpert$isWandTool()) {
return DUMMY_WAND;
}
// ...
}
}
No description provided.