Shadows-of-Fire / FastSuite

A mod that increases recipe performance globally
MIT License
12 stars 3 forks source link

FastSuite interferes with Pestle and Mortar from the Hexerei mod #28

Closed dimon7147 closed 1 year ago

dimon7147 commented 1 year ago

After installing FastSuite, Pestle and Mortar from the Hexerei mod stops working. Pestle and Mortar just hangs and does not craft. After uninstalling FastSuite everything works as it should.

Modpack: Enigmatica 9: Expert v1.12.1 FastSuite: 1.19.2 v4.1.1 Forge: v43.2.14

SiverDX commented 1 year ago

The recipe gets looked up every tick from the tile entity (^ I'd recommend asking the hexerei dev to reconsider this approach) And when it checks if the recipe is present, it's not there (This implementation is probably not suited for multi-threading (I don't know how recipes work though))

You can add the recipe type to the fastsuite.cfg to fix it:

    S:"Single Threaded Recipe Types" <
        hexerei:pestle_and_mortar
     >

(value taken from kubejs recipe type dump)


public void tick() {
        if (this.f_58857_ instanceof ServerLevel) {
            this.craft();
        }

        if (this.crafting) {
            if (this.grindingTime <= 0) {
                new Random();
                if (this.f_58857_ instanceof ServerLevel) {
                    this.craftTheItem(this.output);
                }

                this.crafted = true;
                this.crafting = false;
                this.m_6596_();
(...)
    public void craft() {
        SimpleContainer inv = new SimpleContainer(5);

        for(int i = 0; i < 5; ++i) {
            inv.m_6836_(i, (ItemStack)this.items.get(i));
        }

        Optional<PestleAndMortarRecipe> recipe = this.f_58857_.m_7465_().m_44015_(Type.INSTANCE, inv, this.f_58857_);
        BlockEntity blockEntity = this.f_58857_.m_7702_(this.f_58858_);
        AtomicBoolean matches = new AtomicBoolean(false);
        if (blockEntity instanceof PestleAndMortarTile pestleAndMortarTile) {
            recipe.ifPresent(iRecipe -> {
                this.output = iRecipe.m_8043_();
                matches.set(true);
                if (pestleAndMortarTile.getItemInSlot(5) == Items.f_41852_ && !this.crafting) {
                    this.crafting = true;
                    this.grindingTimeMax = iRecipe.getGrindingTime();
                    this.grindingTime = this.grindingTimeMax;
                    this.m_6596_();
                }
            });
        }

        if (!matches.get() && this.crafting) {
            this.crafting = false;
            this.m_6596_();
        }
    }
Shadows-of-Fire commented 1 year ago

Solution here is just to blacklist the type, or have Hexerei ensure their matches() functions are threadsafe w.r.t. eachother - the matching once per tick is wasteful but not the root-cause here, the problem is something that one of the recipes does in matches() (such as pulling a tile entity from the world off-thread, or modifying state).