FabricMC / fabric-loom

Gradle build system plugin used to automate the setup of a minecraft mod development environment.
MIT License
233 stars 201 forks source link

0.14.23 does not apply newly created injected interfaces, causing a NoSuchMethodError to be thrown whenever accessed #957

Closed ErrorCraft closed 10 months ago

ErrorCraft commented 11 months ago

Old injected interfaces seem to be fine, which is even stranger. The methods aren't recognised by the IDE either and reports it as an error, but it still compiles and can launch the game. This did not happen on version 0.14.22.

Crash report: crash-2023-10-07_10.52.46-client.txt Steps to reproduce:

  1. Add the following interface to class_4538 (net.minecraft.world.WorldView) using interface injection.
    public interface TestAccess {
    default String executeTestMethod() {
        return "hello there";
    }
    }
  2. Add the following mixin to net.minecraft.Block.
    @Mixin(Block.class)
    public class BlockExtender {
    @Inject(
        method = "getPickStack",
        at = @At("HEAD")
    )
    private void addTestMethod(WorldView world, BlockPos pos, BlockState state, CallbackInfoReturnable<ItemStack> info) {
        String s = world.executeTestMethod();
        System.out.println("value: " + s);
    }
    }
  3. Start a client and open a world.
  4. Try to 'pick block' a stone block. (I used a stone block here, but most other blocks are fine as long as they do not override the Block::getPickStack method)
  5. The game crashes with a NoSuchMethodError.
ErrorCraft commented 11 months ago

Wait I just realised I am on fabric-loom, not fabric-loader, grr

ErrorCraft commented 11 months ago

(I'll mention @modmuss50 as it was their comment on the other issue)

Have you got a mixin that implements your mixin on the target class?

If I go back to fabric loader version 0.14.22 and add the injected interface there, then update to fabric loader version 0.14.23 again it gets applied just fine and doesn't throw a NoSuchMethodError. However, if I add the interface when already on 0.14.23, I do get the error.

ErrorCraft commented 11 months ago

Also note that if the injected interface was already there in 0.14.22 and you try to remove it in 0.14.23, it fails to remove it too. In fact, the complete opposite happens from what is described above: the IDE doesn't report any errors until you try to build the project.

Juuxel commented 11 months ago

Have you refreshed your Gradle configuration in your IDE after modifying the access widener? Gradle needs to run for Loom to update the game jar.

ErrorCraft commented 11 months ago

That seems to solve the issue, but I didn't have to do that before. Previously a simple build would suffice. (Other than the occasional Windows "the process cannot access the file because it is being used by another process" shenanigans)

modmuss50 commented 10 months ago

You must refresh gradle after editing something like this so it can regenerate the minecraft jar.