Move MinecraftMixin to platforms

This commit is contained in:
Kneelawk 2024-04-17 18:55:08 -07:00 committed by Jozufozu
parent 70a72209d2
commit 6e0702aa0b
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
package com.jozufozu.flywheel.impl.mixin;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import com.jozufozu.flywheel.api.event.EndClientResourceReloadEvent;
import net.minecraftforge.fml.ModLoader;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.Minecraft;
import net.minecraft.server.packs.resources.ReloadableResourceManager;
@Mixin(Minecraft.class)
abstract class MinecraftMixin {
@Shadow
@Final
private ReloadableResourceManager resourceManager;
@Inject(method = "method_24040", at = @At("HEAD"))
private void flywheel$onEndInitialResourceReload(Optional<Throwable> error, CallbackInfo ci) {
ModLoader.get().postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, true, error));
}
@Inject(method = "method_24228", at = @At("HEAD"))
private void flywheel$onEndManualResourceReload(boolean recovery, CompletableFuture<Void> future, Optional<Throwable> error, CallbackInfo ci) {
ModLoader.get().postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, false, error));
}
}