Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supplementaries Red Merchant Isnt Effected By Trade Edits #13

Closed
Z3R0Presence opened this issue Apr 28, 2024 · 4 comments
Closed

Supplementaries Red Merchant Isnt Effected By Trade Edits #13

Z3R0Presence opened this issue Apr 28, 2024 · 4 comments

Comments

@Z3R0Presence
Copy link

Z3R0Presence commented Apr 28, 2024

Minecraft Version

1.20.1

Mod Version

MoreJS: 0.9.0
Supplementaries: 2.8.10

Describe the bug!

Modifying Villager Trades, while correctly working when interacting with villagers through the MoreJSEvents.playerStartTrading() event, do not effect the Supplementaries Red Merchant.

Seems Related to #12 (comment) where supplementaries trades are not implemented/injected in a general method resulting in the modded trades added to the mod not being correctly modifed.

Regular Villager with my code: (working)
image

Wandering Trader with code: (working)
image

Goblin Trader with code: (working)
image

Red Merchant with code: (not working)
image

If needed i can supply the entire code, but to my knowledge and based on the alternate trade tests, nothing is incorrect regarding the code.

Crash Report

No response

Log

No response

Additions and Modifications

Yes

Additions and Modifications Description

Private Modded Pack, lots of mods, but doesnt seem like a modpack issue as all other trades are working as intended.

Main code interacting with the event is:

MoreJSEvents.playerStartTrading(e => {
    global.villagerTradeEdit(e);
});

/**
 * @param {Internal.StartTradingEventJS} e 
 */
global.villagerTradeEdit = (e) => {
    e.forEachOffers((o, i) => {
       // All This is, is a greedy algorithm that translates emeralds and diamonds to a modded coin, as seen in images previously
        let coin = global.minExchange([o.firstInput, o.secondInput], 1);
        let returnAmount = global.minExchange([o.output], 1);
        if (coin) {
            if (global.isCurrency(o.firstInput) || o.firstInput.isEmpty()) o.setFirstInput(coin.shift());
            if (global.isCurrency(o.secondInput) || o.secondInput.isEmpty()) o.setSecondInput(coin.shift());
        };
        if (returnAmount) o.setOutput(returnAmount.shift())
    });
};

Did the issue happen in singleplayer or on a server?

Singleplayer

@LLytho
Copy link
Member

LLytho commented Apr 28, 2024

playerStartTrading triggers when the MerchantMenu is created. It's the screen the player sees when interacting with villager entities. Supplementaries uses their own screen, menu handling and entity interacting for the Red Merchant. The only solution would be, that I mixin into their code and atm I don't really want to do it. With 1.20.5+ MoreJS will be NeoForge only and then I will take a second look into it as I also refactor some stuff.

If you find other mods where this does not work, let me know please so I can make a list.

@Z3R0Presence
Copy link
Author

Thanks for the explanation, will lyk if I find any other mods that are similar. I’m guessing that no other event for the red merchant would work as of the current version?

@LLytho
Copy link
Member

LLytho commented Apr 28, 2024

I’m guessing that no other event for the red merchant would work as of the current version?

Can't say 100%. Requires testing for each event as it depends how modders implement their villager typed entities. AbstractVillager comes with default behavior how offers are generated from trades. But some modders override this.

There is a util which can be used on server start or trade event for some cases but it may not cover all.
https://github.com/AlmostReliable/morejs/wiki/VillagerUtils#update-abstract-trades-from-other-mods-119-only

GitHub
A Minecraft mod to extend KubeJS with additional events. - AlmostReliable/morejs

@Z3R0Presence
Copy link
Author

Ok, thanks for the quick reply. I’ll look into this, thanks

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

No branches or pull requests

2 participants