Mojmixins

This commit is contained in:
Jozufozu 2021-07-15 11:51:57 -07:00
parent 2238a00bac
commit fdf839cd02
11 changed files with 35 additions and 35 deletions

View file

@ -25,7 +25,7 @@ public class CancelTileEntityRenderMixin {
* list of tile entities to render. By filtering the output here, we prevent the game from
* doing unnecessary light lookups and frustum checks.
*/
@Inject(at = @At("RETURN"), method = "getTileEntities", cancellable = true)
@Inject(at = @At("RETURN"), method = "getRenderableBlockEntities", cancellable = true)
private void noRenderInstancedTiles(CallbackInfoReturnable<List<TileEntity>> cir) {
if (Backend.getInstance()
.canUseInstancing()) {

View file

@ -20,7 +20,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
@Mixin(WorldRenderer.class)
public class FixFabulousDepthMixin {
@Inject(method = "render", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;render(F)V"))
@Inject(method = "renderLevel", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;process(F)V"))
private void disableTransparencyShaderDepth(MatrixStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) {
GlStateManager._depthMask(false);
}

View file

@ -12,7 +12,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
@Mixin(GlStateManager.class)
public class FogColorTrackerMixin {
@Inject(at = @At("TAIL"), method = "fog")
@Inject(at = @At("TAIL"), method = "_fog")
private static void copyFogColor(int pname, float[] params, CallbackInfo ci) {
if (pname == GL11.GL_FOG_COLOR) {
GlFog.FOG_COLOR = params;

View file

@ -35,11 +35,11 @@ import net.minecraftforge.common.MinecraftForge;
public class RenderHooksMixin {
@Shadow
private ClientWorld world;
private ClientWorld level;
@Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.updateChunks(J)V"), method = "render")
@Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.compileChunksUntil(J)V"), method = "renderLevel")
private void setupFrame(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_, CallbackInfo ci) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(world, stack, info, gameRenderer, lightTexture));
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, stack, info, gameRenderer, lightTexture));
}
/**
@ -47,7 +47,7 @@ public class RenderHooksMixin {
* layer-correct custom rendering. RenderWorldLast is not refined enough for rendering world objects.
* This should probably be a forge event.
*/
@Inject(at = @At("TAIL"), method = "renderLayer")
@Inject(at = @At("TAIL"), method = "renderChunkLayer")
private void renderLayer(RenderType type, MatrixStack stack, double camX, double camY, double camZ, CallbackInfo ci) {
Matrix4f view = stack.last()
.pose();
@ -55,22 +55,22 @@ public class RenderHooksMixin {
viewProjection.multiplyBackward(Backend.getInstance()
.getProjectionMatrix());
MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(world, type, viewProjection, camX, camY, camZ));
MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(level, type, viewProjection, camX, camY, camZ));
if (!OptifineHandler.usingShaders()) GL20.glUseProgram(0);
}
@Inject(at = @At("TAIL"), method = "loadRenderers")
@Inject(at = @At("TAIL"), method = "allChanged")
private void refresh(CallbackInfo ci) {
Backend.getInstance()
.refresh();
MinecraftForge.EVENT_BUS.post(new ReloadRenderersEvent(world));
MinecraftForge.EVENT_BUS.post(new ReloadRenderersEvent(level));
}
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;checkEmpty(Lcom/mojang/blaze3d/matrix/MatrixStack;)V", ordinal = 2 // after the game renders the breaking overlay normally
), method = "render")
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;checkPoseStack(Lcom/mojang/blaze3d/matrix/MatrixStack;)V", ordinal = 2 // after the game renders the breaking overlay normally
), method = "renderLevel")
private void renderBlockBreaking(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_, CallbackInfo ci) {
if (!Backend.getInstance()
.available()) return;
@ -82,16 +82,16 @@ public class RenderHooksMixin {
.getProjectionMatrix());
Vector3d cameraPos = info.getPosition();
CrumblingRenderer.renderBreaking(world, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
CrumblingRenderer.renderBreaking(level, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
if (!OptifineHandler.usingShaders()) GL20.glUseProgram(0);
}
// Instancing
@Inject(at = @At("TAIL"), method = "scheduleBlockRerenderIfNeeded")
@Inject(at = @At("TAIL"), method = "setBlockDirty(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)V")
private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) {
InstancedRenderDispatcher.getTiles(world)
.update(world.getBlockEntity(pos));
InstancedRenderDispatcher.getTiles(level)
.update(level.getBlockEntity(pos));
}
}

View file

@ -19,12 +19,12 @@ public class ShaderCloseMixin {
@Shadow
@Nullable
public Screen currentScreen;
public Screen screen;
@Inject(at = @At("HEAD"), method = "displayGuiScreen")
@Inject(at = @At("HEAD"), method = "setScreen")
private void whenScreenChanges(Screen screen, CallbackInfo info) {
if (OptifineHandler.optifineInstalled() && screen instanceof VideoSettingsScreen) {
Screen old = this.currentScreen;
Screen old = this.screen;
if (old != null && old.getClass()
.getName()
.startsWith(OptifineHandler.SHADER_PACKAGE)) {

View file

@ -22,12 +22,12 @@ public abstract class StoreProjectionMatrixMixin {
* We only want to copy the projection matrix if it is going to be used to render the world.
* We don't care about the mat for your hand.
*/
@Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;loadProjectionMatrix(Lnet/minecraft/util/math/vector/Matrix4f;)V"))
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lnet/minecraft/util/math/vector/Matrix4f;)V"))
private void projectionMatrixReady(float p_228378_1_, long p_228378_2_, MatrixStack p_228378_4_, CallbackInfo ci) {
shouldCopy = true;
}
@Inject(method = "loadProjectionMatrix", at = @At("TAIL"))
@Inject(method = "resetProjectionMatrix", at = @At("TAIL"))
private void onProjectionMatrixLoad(Matrix4f projection, CallbackInfo ci) {
if (shouldCopy) {
Backend.getInstance()

View file

@ -19,11 +19,11 @@ public class TileRemoveMixin {
@Shadow
@Nullable
protected World world;
protected World level;
@Inject(at = @At("TAIL"), method = "remove")
@Inject(at = @At("TAIL"), method = "setRemoved")
private void onRemove(CallbackInfo ci) {
if (world instanceof ClientWorld) InstancedRenderDispatcher.getTiles(this.world)
if (level instanceof ClientWorld) InstancedRenderDispatcher.getTiles(this.level)
.remove((TileEntity) (Object) this);
}
}

View file

@ -26,15 +26,15 @@ public class TileWorldHookMixin {
@Shadow
@Final
public boolean isRemote;
public boolean isClientSide;
@Shadow
@Final
protected Set<TileEntity> tileEntitiesToBeRemoved;
protected Set<TileEntity> blockEntitiesToUnload;
@Inject(at = @At("TAIL"), method = "addTileEntity")
@Inject(at = @At("TAIL"), method = "addBlockEntity")
private void onAddTile(TileEntity te, CallbackInfoReturnable<Boolean> cir) {
if (isRemote) {
if (isClientSide) {
InstancedRenderDispatcher.getTiles(self)
.queueAdd(te);
}
@ -45,9 +45,9 @@ public class TileWorldHookMixin {
*/
@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities")
private void onChunkUnload(CallbackInfo ci) {
if (isRemote) {
if (isClientSide) {
InstanceManager<TileEntity> kineticRenderer = InstancedRenderDispatcher.getTiles(self);
for (TileEntity tile : tileEntitiesToBeRemoved) {
for (TileEntity tile : blockEntitiesToUnload) {
kineticRenderer.remove(tile);
}
}

View file

@ -19,14 +19,14 @@ import net.minecraft.util.ResourceLocation;
public abstract class AtlasDataMixin {
@Shadow
public abstract ResourceLocation getId();
public abstract ResourceLocation location();
@Inject(method = "stitch", at = @At("RETURN"))
@Inject(method = "prepareToStitch", at = @At("RETURN"))
public void stealAtlasData(IResourceManager resourceManager, Stream<ResourceLocation> locationStream, IProfiler profiler, int mipMapLevels, CallbackInfoReturnable<AtlasTexture.SheetData> cir) {
AtlasTexture.SheetData value = cir.getReturnValue();
SheetDataAccessor dataAccessor = (SheetDataAccessor) value;
AtlasInfo.setAtlasData(getId(), dataAccessor);
AtlasInfo.setAtlasData(location(), dataAccessor);
}
}

View file

@ -33,7 +33,7 @@ public abstract class LightUpdateMixin extends AbstractChunkProvider {
* the rendering system that it needs to redraw a chunk. It does all that work asynchronously,
* and we should too.
*/
@Inject(at = @At("HEAD"), method = "markLightChanged")
@Inject(at = @At("HEAD"), method = "onLightUpdate")
private void onLightUpdate(LightType type, SectionPos pos, CallbackInfo ci) {
ClientChunkProvider thi = ((ClientChunkProvider) (Object) this);
ClientWorld world = (ClientWorld) thi.getLevel();

View file

@ -24,7 +24,7 @@ import net.minecraft.world.chunk.Chunk;
@Mixin(ClientPlayNetHandler.class)
public class NetworkLightUpdateMixin {
@Inject(at = @At("TAIL"), method = "handleUpdateLight")
@Inject(at = @At("TAIL"), method = "handleLightUpdatePacked")
private void onLightPacket(SUpdateLightPacket packet, CallbackInfo ci) {
RenderWork.enqueue(() -> {
ClientWorld world = Minecraft.getInstance().level;