Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • sFXprt changed the title to 1.19.3 Cant Set Custom Xp Cost in AnvilUpdateEvent

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.

  • Author
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

15 hours ago, sFXprt said:

But on the topic what do you mean by determining the output.

You would have to calculate the output given the input and the catalyst to the anvil for every item if you wanted to use the event in the capacity you described previously.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.