2021-06-16 20:19:33 +02:00
|
|
|
package com.jozufozu.flywheel.mixin;
|
2021-01-14 22:59:26 +01:00
|
|
|
|
2021-02-18 19:43:22 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2021-05-05 06:00:55 +02:00
|
|
|
import com.jozufozu.flywheel.backend.Backend;
|
2021-07-13 00:02:08 +02:00
|
|
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
2021-02-18 19:43:22 +01:00
|
|
|
|
2021-01-14 22:59:26 +01:00
|
|
|
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
@Mixin(ChunkRenderDispatcher.CompiledChunk.class)
|
|
|
|
public class CancelTileEntityRenderMixin {
|
|
|
|
|
2021-04-08 19:22:11 +02:00
|
|
|
/**
|
|
|
|
* JUSTIFICATION: when instanced rendering is enabled, many tile entities no longer need
|
|
|
|
* to be processed by the normal game renderer. This method is only called to retrieve the
|
|
|
|
* list of tile entities to render. By filtering the output here, we prevent the game from
|
|
|
|
* doing unnecessary light lookups and frustum checks.
|
|
|
|
*/
|
2021-07-15 20:51:57 +02:00
|
|
|
@Inject(at = @At("RETURN"), method = "getRenderableBlockEntities", cancellable = true)
|
2021-04-08 19:22:11 +02:00
|
|
|
private void noRenderInstancedTiles(CallbackInfoReturnable<List<TileEntity>> cir) {
|
2021-06-30 21:43:54 +02:00
|
|
|
if (Backend.getInstance()
|
|
|
|
.canUseInstancing()) {
|
2021-04-08 19:22:11 +02:00
|
|
|
List<TileEntity> tiles = cir.getReturnValue();
|
2021-02-07 23:15:52 +01:00
|
|
|
|
2021-07-09 22:24:26 +02:00
|
|
|
InstancedRenderRegistry r = InstancedRenderRegistry.getInstance();
|
|
|
|
tiles.removeIf(r::shouldSkipRender);
|
2021-04-08 19:22:11 +02:00
|
|
|
}
|
|
|
|
}
|
2021-01-14 22:59:26 +01:00
|
|
|
}
|