Posted April 12, 20232 yr 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 April 12, 20232 yr by sFXprt
April 12, 20232 yr 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.
April 12, 20232 yr 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
April 13, 20232 yr 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.