FallenMoonNetwork / CanaryMod

Server administration mod and API for Minecraft beta multiplayer server
http://canarymod.net
GNU Lesser General Public License v3.0
20 stars 14 forks source link

Hook Request; onVillagerTradeUnlock #74

Closed BluXDragon closed 11 years ago

BluXDragon commented 11 years ago

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.

WWOL commented 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

BluXDragon commented 11 years ago

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.

WWOL commented 11 years ago

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

gregcarlin commented 11 years ago

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.

BluXDragon commented 11 years ago

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.

WWOL commented 11 years ago

Ah got it thanks. I wonder if you can update the villager GUI on the client reliable though.

WWOL

BluXDragon commented 11 years ago

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?

BluXDragon commented 11 years ago

It wasn't possible to make onVillagerTradeUnlock return a VillagerTrade? Edit: I guess it's not really necessary, can just add them manually. Nevermind ._.

gregcarlin commented 11 years ago

Modifying the VillagerTrade will change the trade. That's why I added VillagerTrade.set methods.

BluXDragon commented 11 years ago

Oh okay, that's better. Good job ^^