Solved Custom name and xp cost in anvil event

Discussion in 'Plugin Development' started by knokko, Nov 2, 2018.

Thread Status:
Not open for further replies.
  1. My plug-in needs to mess around with the anvil behavior. I found the PrepareAnvilEvent, but it seems a bit limited because I can't find a way to get/set the xp cost and get the name the player tries to rename the item in the contents slot to.

    Does anybody know a way to get and set the xp cost for the action and/or how to get the custom name the player tries to rename the item to?
     
  2. Offline

    The_Spaceman

    as far as I know it isn't possible, I've checked once if I could chance the anvil name (even looked in NMS) and I could not find it...
     
  3. @knokko,
    in PrepareAnvilEvent cast e.getInventory() to AnvilInventory. You can then use the methods getRenameText() and getRepairCost() (and also for each one the setter)
     
    knokko likes this.
  4. @DerDonut
    It looks like I don't even need to cast event.getInventory() to AnvilInventory, it already is guaranteed to be an AnvilInventory (at least in mc 1.12).
    When I searched myself, I was searching directly in event :oops:

    @The_Spaceman
    In case you would still need this, DerDonut just told how to.
     
  5. Offline

    The_Spaceman

    I mis read it… I was thinking that you wanted to change the name of the inventory
     
Thread Status:
Not open for further replies.

Share This Page