Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v1.1.2
- Fix BBW block preview showing on all GT tools.

* * *

# v1.1.1
- Fix aluminum recipe conflicts with Chisel.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,21 @@ public void nextFluidMode(ItemStack itemStack, EntityPlayer player) {

@Override
public IWand getWand() {
// Return a GT-aware IWand for BBW's preview rendering and other IWand consumers
if (!gtexpert$isWandTool()) {
// Non-wand GT tools: return IWand with 0 maxBlocks to suppress preview
return new IWand() {

@Override
public int getMaxBlocks(ItemStack itemStack) {
return 0;
}

@Override
public boolean placeBlock(ItemStack itemStack, EntityLivingBase entity) {
return false;
}
};
Comment on lines +79 to +90
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

この実装では、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;
        }
        // ...
    }
}

}
return new IWand() {

@Override
Expand Down
Loading