Closed BluXDragon closed 11 years ago
Wouldn't it be better to just have a wrapper for villagers and their trades and then edit them onEntityRightClick()? Then you could remove / add trades then.
WWOL
Well that pretty much already exists, and I already have a plugin that does that kind of stuff (with the minor difference that you punch them with an emerald instead), except if I set a villager to have specific non-legit trades he can still get normal trades via unlocking them.
I'm talking specifically about the modification/denial of new trades as they are unlocked (new trades are unlocked when you buy things from villagers), as we can't do that right now. In a way we could, but it would involve storing data of every villager and checking it each time they are rightclicked-
Edit: Actually, just realized that won't work either, since the new trade will be available until the player closes the trade window.
EditEdit: Accidently clicked "close and comment". My bad.
I still don't get it (haven't really used the villagers) how come you can't remove the new trades each time the player clicks on the villager? I should probably play minecraft more because I don't know how any of the new stuff works. :P
WWOL
Here's what happens: the player opens up the trading gui, onEntityRightClick is called. The player then makes a trade. This unlocks a new trade and adds it to the Villager. All this happens without ever closing the gui.
Precisely as greg says. Plus, like I said, to deny/alter new trades as they are unlocked without a hook for it would require storing data on the villagers and all that. Even disregarding the issue that greg explains, the hook would make altering new unlocked trades so much smoother.
Ah got it thanks. I wonder if you can update the villager GUI on the client reliable though.
WWOL
Well if the hook is called before the new trade is added, then when it actually happens it should automatically update the GUI correctly with the changes, right?
It wasn't possible to make onVillagerTradeUnlock return a VillagerTrade? Edit: I guess it's not really necessary, can just add them manually. Nevermind ._.
Modifying the VillagerTrade will change the trade. That's why I added VillagerTrade.set methods.
Oh okay, that's better. Good job ^^
I'd like to request this hook;
public VillagerTrade onVillagerTradeUnlock(Villager villager, VillagerTrade trade, Player player)
Preferrably, you can alter (or create a new) trade and return that. Although it would be nice to be able to deny it completely, so perhaps returning null in that case?
I'm not sure if getting the Player would be possible, but it would be nice.