mastery3 / sharpness6

Extended enchantment levels for OP weapons.
Other
4 stars 3 forks source link

Port to 1.21 #10

Closed Cam396 closed 3 months ago

Cam396 commented 3 months ago

https://fabricmc.net/2024/05/31/121.html 1.21 Changes many things on the backend and also changes how enchants are structured. Please read the link on the top of this issue to see all of the changes. There are a few fabric api changes that are also mentioned there.

mastery3 commented 3 months ago

1.21 is still displaying as a release candidate on my end, so I'm gonna wait a little.

Cam396 commented 3 months ago

1.21 was released and both fabric (https://fabricmc.net/2024/05/31/121.html) and Minecraft (https://feedback.minecraft.net/hc/en-us/articles/27547857163917-Minecraft-Java-Edition-1-21-Tricky-Trials) have confirmed that enchants have changed and easier to use with a datapack

mastery3 commented 3 months ago

There appears to be some problems with the datapack method:

  1. I would need to override all Minecraft enchantment files just to change their maximum levels, meaning that a) compatibility with other datapacks that change anything at all about vanilla enchantments is out the window, and b) I would need to copy paste everything from the Minecraft jar data/minecraft/enchantment directory into my mod.
  2. Datapacks don't support reading anything in the /config directory, meaning I would have to, at minimum, somehow write something to either dynamically create datapacks, or modify the datapack loader to edit some values (which are both as difficult, if not more so, than the current implementation)

Datapacks seem to be unsuitable for the "change arbitrary enchantment's maximum level to arbitrary values" use case, which is what this mod needs.

Cam396 commented 3 months ago

hmm ig make a test branch to test stuff to see if it can be used as a mod. just update dependencies and gradle and the simply change the version.

mastery3 commented 3 months ago

There's a separate issue that somehow no mixins work when trying to update to 1.21.

Cam396 commented 3 months ago

ok so what do we do then. do we code a mod that just links the mixins to a datapack or something?

mastery3 commented 3 months ago

I need to debug that mixin issue before I can create any 1.21 update.

Cam396 commented 3 months ago

ok is that minecraft wide for all mixins, even things other then enchants, or is it just the mod?

mastery3 commented 3 months ago

It affects only my mod, but everything in it. Wondering if it's something with gradle.

Cam396 commented 3 months ago

hmm maybe try updating gradle and dependencies to the latest versions?

Cam396 commented 3 months ago

oh also they removed basically all of the classes your mod relies on. 1.20.6 https://maven.fabricmc.net/docs/yarn-1.20.6+build.1/net/minecraft/enchantment/Enchantment.html 1.21 https://maven.fabricmc.net/docs/yarn-1.21+build.1/net/minecraft/enchantment/Enchantment.html look at the changes between the two, as that is probably why your mod isn't working.

mastery3 commented 3 months ago

I already figured out why my mixins weren't working (it was what you mentioned, and I additionally got unlucky with the Fabric Example Mixin which is why I thought the whole mod wasn't working).

Good news is that I found the method that would need to be mixined. Bad news is that the method is RegistryLoader.parseAndAdd. [Datapack method would be even harder to pull off, so that's not an option]

Cam396 commented 3 months ago

oh no, i might be able to help but I don't code too much java and js, so you'll have to make a example and then ill be able to do the rest basing it on thee example.

Cam396 commented 3 months ago

i know enough for what you're doing, but I need to see one example of it first is what I mean

mastery3 commented 3 months ago

I need to put a mixin in the middle of the parseAndAdd function. You're probably going to need to know how to read bytecode to figure this out.

[deleted example just in case I accidentally infringed on copyright]

Cam396 commented 3 months ago

k i will look at it if i have time

mastery3 commented 3 months ago

I'll probably just look at Fabric Mixin Examples to figure it out.

mastery3 commented 3 months ago

Well, there's a fourth issue: I get a Critical Injection Failure whenever I try to use a value="INVOKE", and only that specific type of mixin. The error message I get in the logs provides no relevant info.

Cam396 commented 3 months ago

maybe start from scratch with the fabric example project in a new fork? use gradle 8.8, java 22 GraalVM (if possible, otherwise use java 21) and all latest versions of everything. sometimes when I'm debugging it is something you wouldn't think of at all, like a old file from a previous version that is somehow affecting it. make a new branch and Ill try to help but I'm going to be somewhere next week.

mastery3 commented 3 months ago

I had already restarted from fabric example project, so it can't possibly be that.

mastery3 commented 3 months ago

I did some crazy hack to get the mixin working correctly. I'm creating a github branch right now.

Cam396 commented 3 months ago

ok got it i will test it on my server

Cam396 commented 3 months ago

have you pushed the hack yet?

mastery3 commented 3 months ago

I pushed 1.21 as a new branch.

Cam396 commented 3 months ago

alright nice now it just needs to be cleaned up a bit and the readme and stuff needs to be fixed

mastery3 commented 3 months ago

A lot of stuff needs to be fixed.

mastery3 commented 3 months ago

Problem #1 at the moment is getting rid of the hack I just did with RegistryLoader.mixin.java

Cam396 commented 3 months ago

what is the hack

Cam396 commented 3 months ago

wait before you tell me will my braincells pack their bags and leave when they see it because of how dumb it is

mastery3 commented 3 months ago

It's not that dumb lol, but it definitely adds a ton of problems

Cam396 commented 3 months ago

alright what is it though

Cam396 commented 3 months ago

like which file?

mastery3 commented 3 months ago

src/main/java/mastery3/sharpness6/mixin/RegistryLoader.mixin.java

mastery3 commented 3 months ago

I'm trying to get it to a @Inject(at = @At(value = "INVOKE"), ...) that only adds the code between // Start of injection and // End of injection without overwriting the entire function, but attempting that somehow causes a Critical Injection Error

Cam396 commented 3 months ago

hmm will test but i have to go to bed

mastery3 commented 3 months ago

The problems that the hack imposes is that it denies compatibility with any other mods that need to change that function

Cam396 commented 3 months ago

yeah so thats a interesting method of doing it but whatever works works ig

mastery3 commented 3 months ago

See if you can figure out why the Critical Injection Errors occur

Cam396 commented 3 months ago

ok

Cam396 commented 3 months ago

ima sleep now

mastery3 commented 3 months ago

see you tomorrow

sternschnaube commented 3 months ago

Looking forward to the update - thank you! 😄

mastery3 commented 3 months ago

Update is almost done. Last problem is figuring out how to conditionally edit minecraft:unbreaking without getting the original minecraft:unbreaking deleted when the condition is not satisfied. (Yes, fabric:load_conditions is that dumb.)

mastery3 commented 3 months ago

Update is done