Skip to content

Commit c005b99

Browse files
committed
no render block entities
1 parent 86ff0ce commit c005b99

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.render;
19+
20+
import com.lambda.module.modules.render.NoRender;
21+
import net.minecraft.block.entity.BlockEntity;
22+
import net.minecraft.client.render.VertexConsumerProvider;
23+
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
24+
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
25+
import net.minecraft.client.util.math.MatrixStack;
26+
import net.minecraft.util.math.Vec3d;
27+
import org.spongepowered.asm.mixin.Mixin;
28+
import org.spongepowered.asm.mixin.injection.At;
29+
import org.spongepowered.asm.mixin.injection.Inject;
30+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31+
32+
@Mixin(BlockEntityRenderDispatcher.class)
33+
public class BlockEntityRenderDispatcherMixin {
34+
@Inject(method = "render(Lnet/minecraft/client/render/block/entity/BlockEntityRenderer;Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/util/math/Vec3d;)V", at = @At("HEAD"), cancellable = true)
35+
private static void injectRender(BlockEntityRenderer<BlockEntity> renderer, BlockEntity blockEntity, float tickProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, Vec3d cameraPos, CallbackInfo ci) {
36+
if (NoRender.shouldOmitBlockEntity(blockEntity)) ci.cancel();
37+
}
38+
}

src/main/kotlin/com/lambda/module/modules/render/NoRender.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.lambda.module.Module
2121
import com.lambda.module.tag.ModuleTag
2222
import com.lambda.util.reflections.scanResult
2323
import io.github.classgraph.ClassInfo
24+
import net.minecraft.block.entity.BlockEntity
2425
import net.minecraft.client.particle.Particle
2526
import net.minecraft.client.render.BackgroundRenderer.StatusEffectFogModifier
2627
import net.minecraft.entity.Entity
@@ -38,6 +39,7 @@ object NoRender : Module(
3839
.filter { !it.isAbstract && it.name.startsWith("net.minecraft") }
3940

4041
private val particleMap = createParticleNameMap()
42+
private val blockEntityMap = createBlockEntityNameMap()
4143
private val playerEntityMap = createEntityNameMap("net.minecraft.client.network.")
4244
private val bossEntityMap = createEntityNameMap("net.minecraft.entity.boss.")
4345
private val decorationEntityMap = createEntityNameMap("net.minecraft.entity.decoration.")
@@ -63,6 +65,7 @@ object NoRender : Module(
6365
private val projectileEntities by setting("Projectile Entities", projectileEntityMap.values.toSet(), emptySet(), "Projectile entities to omit from rendering")
6466
private val vehicleEntities by setting("Vehicle Entities", vehicleEntityMap.values.toSet(), emptySet(), "Vehicle entities to omit from rendering")
6567
private val miscEntities by setting("Misc Entities", miscEntityMap.values.toSet(), emptySet(), "Miscellaneous entities to omit from rendering")
68+
private val blockEntities by setting("Block Entities", blockEntityMap.values.toSet(), emptySet(), "Block entities to omit from rendering")
6669

6770
private fun createParticleNameMap(): Map<String, String> {
6871
val subClasses = scanResult
@@ -75,6 +78,13 @@ object NoRender : Module(
7578
return createNameMap(entities, directory, "Entity", strictDir)
7679
}
7780

81+
private fun createBlockEntityNameMap(): Map<String, String> {
82+
val subClasses = scanResult
83+
.getSubclasses(BlockEntity::class.java)
84+
.filter { !it.isAbstract }
85+
return createNameMap(subClasses.asSequence(), "net.minecraft.block.entity", "BlockEntity")
86+
}
87+
7888
private fun createNameMap(
7989
items: Sequence<ClassInfo>,
8090
directory: String,
@@ -109,7 +119,7 @@ object NoRender : Module(
109119
@JvmStatic
110120
fun shouldOmitEntity(entity: Entity): Boolean {
111121
val simpleName = entity.javaClass.simpleName
112-
return when (entity.type.spawnGroup) {
122+
return isEnabled && when (entity.type.spawnGroup) {
113123
SpawnGroup.MISC ->
114124
miscEntityMap[simpleName] in miscEntities ||
115125
playerEntityMap[simpleName] in playerEntities ||
@@ -129,6 +139,10 @@ object NoRender : Module(
129139
}
130140
}
131141

142+
@JvmStatic
143+
fun shouldOmitBlockEntity(blockEntity: BlockEntity) =
144+
isEnabled && blockEntityMap[blockEntity.javaClass.simpleName] in blockEntities
145+
132146
@JvmStatic
133147
fun shouldAcceptFog(modifier: StatusEffectFogModifier) =
134148
when {

src/main/resources/lambda.mixins.common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"network.LoginHelloC2SPacketMixin",
2929
"network.LoginKeyC2SPacketMixin",
3030
"render.BackgroundRendererMixin",
31+
"render.BlockEntityRenderDispatcherMixin",
3132
"render.BlockRenderManagerMixin",
3233
"render.CameraMixin",
3334
"render.CapeFeatureRendererMixin",

0 commit comments

Comments
 (0)