Skip to content

Commit

Permalink
Fix resize
Browse files Browse the repository at this point in the history
  • Loading branch information
hackermdch committed Sep 22, 2024
1 parent eda1cf6 commit 781d575
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import com.primogemstudio.advancedfmk.flutter.Shaders.POST_BLUR
import net.minecraft.client.Minecraft
import java.lang.ref.Cleaner

class FlutterInstance(assets: String?, val rect: FlutterRect, var width: Int, var height: Int): AutoCloseable {
class FlutterInstance(assets: String?, val rect: FlutterRect, var width: Int, var height: Int) : AutoCloseable {
companion object {
val ITARGET = TextureTarget(1, 1, false, false).apply {
setClearColor(0f, 0f, 0f, 0f)
clear(false)
}
}

private val cleaner: Cleaner.Cleanable
val handle: Long = FlutterNative.createInstance(assets)
var pressed: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.primogemstudio.advancedfmk.flutter.FlutterInstance;
import com.primogemstudio.advancedfmk.flutter.FlutterRect;
import com.primogemstudio.advancedfmk.flutter.FlutterViewEvent;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -11,15 +13,16 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GameRenderer.class)
public abstract class RenderSystemMixin {
public abstract class GameRendererMixin {
@Unique
private static FlutterInstance instance;

@Inject(method = "render", at = @At(value = "RETURN"))
private void flipFrame(DeltaTracker deltaTracker, boolean renderLevel, CallbackInfo ci) {
if (instance == null) {
var window = Minecraft.getInstance().getWindow();
instance = new FlutterInstance("jar://app", new FlutterRect(), 600, 800);
instance.sendSizeEvent();
FlutterViewEvent.INSTANCE.resize(window.getWidth(), window.getHeight());
instance.getComposeData().setBlurType(1);
instance.getComposeData().setBlurRadius(8);
instance.getComposeData().setNoise(0.005f);
Expand Down
4 changes: 2 additions & 2 deletions flutter-ui/src/main/resources/advancedfmk.flutter.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"compatibilityLevel": "JAVA_21",
"client": [
"FlutterWindowMixin",
"GameRendererMixin",
"KeyboardHandlerMixin",
"MinecraftMixin",
"MouseHandlerMixin",
"RenderSystemMixin"
"MouseHandlerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 781d575

Please sign in to comment.