Jump to content

1.19.3 Cant Set Custom Xp Cost in AnvilUpdateEvent


sFXprt

Recommended Posts

As the title states, I cant set the maximum xp spent on repair to 30.

@SubscribeEvent
    public static void onAnvilUpdate(AnvilUpdateEvent e){
        if(e.getCost() > 30){
            e.setCost(30);
        }
    }

Before people ask, I tried it two ways, one with just how it is above and one with setting e.setOutput to e.getOutput and nothing works. I even downloaded an external mod that fixes Anvil Repair Costs but that didnt work either.

EDIT: Ive done debugging and realized the cost is always 0 when unenchanted and once enough enchantments are put it then return 1 for e.getCost(), I am so confused how do I get it to set to a max cost of 30 xp level??

 

EDIT #2: I now realize that anvil repair cost depends on each individual enchantment cost defined in their classes. Which we cant change that so what can I do to change the overall cost? Im gonna look through vanilla code to figure this out.

EDIT #3: After looking through vanilla code, ive seen that the itemstacks hold repaircost, ive tried to set cost to 30 if its over 30 and it still isnt working, ive tried this on both AnvilRepair and AnvilUpdate Event...

Edited by sFXprt
Link to comment
Share on other sites

  • sFXprt changed the title to 1.19.3 Cant Set Custom Xp Cost in AnvilUpdateEvent
8 hours ago, ChampionAsh5357 said:

The purpose of AnvilUpdateEvent is for when you would like to add an output between two items, not a general usecase. There is no event that exists which specifies the maximum amount of levels an anvil will take from the player unless you determine the output manually for every item and mod item.

Thanks, I understand, I found a mod that does what I want anyways so no need. But on the topic what do you mean by determining the output. Would it be by their super class? Or by ItemStack#getRepairCosr

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.