senseiwells / EssentialClient

EssentialClient is a client side mod originally forked from Carpet Client for 1.15.2 that implements new client side features
MIT License
77 stars 14 forks source link

Add trade forcing + adds myself to authors #79

Closed aria1th closed 2 years ago

aria1th commented 2 years ago

this situation explains the need for this

sleep(1500);
screen = player.getCurrentScreen();
screen.selectTrade(0);
screen.tradeSelected(false);

It won't trade, because screen is not synced. However since we know server will have something in their screen, we can safely click output slot even if we don't see something. It enables much faster trading. We can do same thing for "selecting Trade" because selecting trade packet does not require any screen handler reference.

It also means trading can be 'instant' - you can omit waiting process.

senseiwells commented 2 years ago

This is not a good solution. The reason for this issue is that you are running off-thread and this issue will be fixed when you run on the main thread. The client knows what items the villager is selling already so it doesn't need the server to tell it so, I read the code and it does this. tradeSelected will work right after selectTrade if you run on the main thread.

There are also a few issues with your code but I won't review because I won't merge this anyways.