forked from Chocohead/OptiFabric
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slightly tentative, Fabric API's Block View API probably needs at least another mixin on `ChunkCacheOF` to fully support it Mod support beyond Fabric API is essentially untested
- Loading branch information
Showing
9 changed files
with
137 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/me/modmuss50/optifabric/compat/fabricblockview/BlockViewMixinPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package me.modmuss50.optifabric.compat.fabricblockview; | ||
|
||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
import org.spongepowered.asm.mixin.transformer.ClassInfo; | ||
|
||
import me.modmuss50.optifabric.compat.InterceptingMixinPlugin; | ||
import me.modmuss50.optifabric.util.MixinUtils; | ||
|
||
public class BlockViewMixinPlugin extends InterceptingMixinPlugin { | ||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
if ("ChunkRendererRegionBuilderMixin".equals(mixinInfo.getName())) { | ||
ClassInfo info = ClassInfo.forName(targetClassName); | ||
MixinUtils.completeClassInfo(info, targetClass.methods); | ||
} | ||
|
||
super.preApply(targetClassName, targetClass, mixinClassName, mixinInfo); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...me/modmuss50/optifabric/compat/fabricblockview/mixin/ChunkRendererRegionBuilderMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package me.modmuss50.optifabric.compat.fabricblockview.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import net.minecraft.class_6850; | ||
import net.minecraft.class_6850.class_6851; | ||
import net.minecraft.client.render.chunk.ChunkRendererRegion; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
import me.modmuss50.optifabric.compat.InterceptingMixin; | ||
import me.modmuss50.optifabric.compat.PlacatingSurrogate; | ||
import me.modmuss50.optifabric.compat.Shim; | ||
|
||
@Mixin(class_6850.class) | ||
@InterceptingMixin("net/fabricmc/fabric/mixin/blockview/client/ChunkRendererRegionBuilderMixin") | ||
abstract class ChunkRendererRegionBuilderMixin { | ||
@PlacatingSurrogate | ||
private void createDataMap(World world, BlockPos startPos, BlockPos endPos, int chunkRadius, CallbackInfoReturnable<ChunkRendererRegion> call) { | ||
} | ||
|
||
@Inject(at = @At("RETURN"), method = "createRegion", remap = false, locals = LocalCapture.CAPTURE_FAILHARD) | ||
private void createOF(World world, BlockPos startPos, BlockPos endPos, int offset, boolean checkEmpty, CallbackInfoReturnable<ChunkRendererRegion> call, int startX, int startZ, int endX, int endZ, class_6851[][] chunks) { | ||
createDataMap(world, startPos, endPos, offset, call, startX, endX, startZ, endZ, chunks); | ||
} | ||
|
||
@Shim | ||
private native void createDataMap(World world, BlockPos startPos, BlockPos endPos, int offset, CallbackInfoReturnable<ChunkRendererRegion> call, int startX, int startZ, int endX, int endZ, class_6851[][] chunks); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...in/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNew5erMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package me.modmuss50.optifabric.compat.fabricscreenapi.mixin; | ||
|
||
import me.modmuss50.optifabric.compat.InterceptingMixin; | ||
import me.modmuss50.optifabric.compat.PlacatingSurrogate; | ||
import me.modmuss50.optifabric.compat.Shim; | ||
import net.minecraft.client.gui.DrawableHelper; | ||
import net.minecraft.client.render.GameRenderer; | ||
import net.minecraft.client.util.Window; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import org.joml.Matrix4f; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.At.Shift; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
@Mixin(GameRenderer.class) | ||
@InterceptingMixin("net/fabricmc/fabric/mixin/screen/GameRendererMixin") | ||
abstract class GameRendererNew5erMixin { | ||
@Shim | ||
private native void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, boolean loaded, int mouseX, int mouseY, MatrixStack matrixstack, DrawableHelper drawContext); | ||
|
||
@PlacatingSurrogate | ||
private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, boolean loaded, int mouseX, int mouseY, Window window, float idk) { | ||
} | ||
|
||
@Inject(method = "render(FJZ)V", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/class_332;IIF)V", ordinal = 0), | ||
locals = LocalCapture.CAPTURE_FAILHARD, | ||
cancellable = true) | ||
private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, boolean loaded, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack matrixstack, float idk, DrawableHelper drawContext) { | ||
onBeforeRenderScreen(tickDelta, startTime, tick, call, loaded, mouseX, mouseY, matrixstack, drawContext); | ||
} | ||
|
||
@Shim | ||
private native void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, boolean loaded, int mouseX, int mouseY, MatrixStack matrixstack, DrawableHelper drawContext); | ||
|
||
@PlacatingSurrogate | ||
private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, boolean loaded, int mouseX, int mouseY, Window window, float idk) { | ||
} | ||
|
||
@Inject(method = "render(FJZ)V", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/class_332;IIF)V", shift = Shift.AFTER, ordinal = 0), | ||
locals = LocalCapture.CAPTURE_FAILHARD) | ||
private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, boolean loaded, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack matrixstack, float idk, DrawableHelper drawContext) { | ||
onAfterRenderScreen(tickDelta, startTime, tick, call, loaded, mouseX, mouseY, matrixstack, drawContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/resources/optifabric.compat.fabric-block-view-api.mixins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"parent": "optifabric.mixins.json", | ||
"package": "me.modmuss50.optifabric.compat.fabricblockview.mixin", | ||
"plugin": "me.modmuss50.optifabric.compat.fabricblockview.BlockViewMixinPlugin", | ||
"mixins": [ | ||
"ChunkRendererRegionBuilderMixin" | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/resources/optifabric.compat.fabric-screen-api.new5er-mixins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"parent": "optifabric.mixins.json", | ||
"package": "me.modmuss50.optifabric.compat.fabricscreenapi.mixin", | ||
"plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", | ||
"mixins": [ | ||
"GameRendererNew5erMixin" | ||
] | ||
} |