Skip to content

Commit

Permalink
change: prevent culling entities inside of mob spawners
Browse files Browse the repository at this point in the history
  • Loading branch information
Sychic committed Jan 2, 2023
1 parent b645953 commit 4ef964f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package club.sk1er.patcher.mixins.performance;

import club.sk1er.patcher.util.world.render.culling.EntityCulling;
import net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer;
import net.minecraft.tileentity.MobSpawnerBaseLogic;
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.CallbackInfo;

@Mixin(TileEntityMobSpawnerRenderer.class)
public class TileEntityMobSpawnerRendererMixin_EntityCulling {
//#if MC<11200
private static final String patcher$renderEntity = "Lnet/minecraft/client/renderer/entity/RenderManager;renderEntityWithPosYaw(Lnet/minecraft/entity/Entity;DDDFF)Z";
//#else if MC >=11200
//$$ private static final String patcher$renderEntity = "Lnet/minecraft/client/renderer/entity/RenderManager;doRenderEntity(Lnet/minecraft/entity/Entity;DDDFFZ)V";
//#endif

@Inject(method = "renderMob", at = @At(value = "INVOKE", target = patcher$renderEntity))
private static void patcher$captureRenderingPre(CallbackInfo ci) {
EntityCulling.renderingSpawnerEntity = true;
}

@Inject(method = "renderMob", at = @At(value = "INVOKE", target = patcher$renderEntity, shift = At.Shift.AFTER))
private static void patcher$captureRenderingPost(CallbackInfo ci) {
EntityCulling.renderingSpawnerEntity = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class EntityCulling {
private static final boolean SUPPORT_NEW_GL = GLContext.getCapabilities().OpenGL33;
public static boolean shouldPerformCulling = false;
private int destroyTimer;
public static boolean renderingSpawnerEntity = false;

/**
* Used for checking if the entities' nametag can be rendered if the user still wants
Expand Down Expand Up @@ -171,6 +172,7 @@ private static int getQuery() {
* @return true if the entity rendering should be skipped
*/
private static boolean checkEntity(Entity entity) {
if (renderingSpawnerEntity) return false;
OcclusionQuery query = queries.computeIfAbsent(entity.getUniqueID(), OcclusionQuery::new);
if (query.refresh) {
query.nextQuery = getQuery();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/patcher.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"performance.RenderGlobalMixin_LimitVisGraphScan",
"performance.ResourcePackRepositoryMixin_FasterSearching",
"performance.TexturedQuadMixin_BatchDraw",
"performance.TileEntityMobSpawnerRendererMixin_EntityCulling",
"performance.VisGraphMixin_LimitScan",
"performance.WorldClientMixin_AnimationTick",
"performance.WorldMixin_Optimization",
Expand Down

0 comments on commit 4ef964f

Please sign in to comment.