|
7 | 7 | */ |
8 | 8 | package net.wurstclient.mixin; |
9 | 9 |
|
| 10 | +import java.util.List; |
| 11 | + |
10 | 12 | import org.spongepowered.asm.mixin.Mixin; |
11 | 13 | import org.spongepowered.asm.mixin.injection.At; |
12 | 14 | import org.spongepowered.asm.mixin.injection.Constant; |
13 | 15 | import org.spongepowered.asm.mixin.injection.ModifyConstant; |
14 | 16 |
|
15 | 17 | import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
16 | 18 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
| 19 | +import com.mojang.blaze3d.vertex.PoseStack; |
| 20 | +import com.mojang.blaze3d.vertex.VertexConsumer; |
17 | 21 |
|
18 | 22 | import net.minecraft.client.renderer.block.ModelBlockRenderer; |
| 23 | +import net.minecraft.client.renderer.block.model.BakedQuad; |
| 24 | +import net.minecraft.client.renderer.block.model.BlockModelPart; |
19 | 25 | import net.minecraft.core.BlockPos; |
20 | 26 | import net.minecraft.core.Direction; |
21 | 27 | import net.minecraft.world.level.BlockAndTintGetter; |
@@ -72,4 +78,28 @@ private float modifyOpacity(float original) |
72 | 78 | { |
73 | 79 | return currentOpacity.get(); |
74 | 80 | } |
| 81 | + |
| 82 | + /** |
| 83 | + * Hides blocks like grass and snow when neither Sodium nor Indigo are |
| 84 | + * running. |
| 85 | + */ |
| 86 | + @WrapOperation( |
| 87 | + at = @At(value = "INVOKE", |
| 88 | + target = "Ljava/util/List;isEmpty()Z", |
| 89 | + ordinal = 1), |
| 90 | + method = "tesselateWithoutAO(Lnet/minecraft/world/level/BlockAndTintGetter;Ljava/util/List;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZI)V") |
| 91 | + private boolean pretendEmptyToStopSecondRenderModelFaceFlatCall( |
| 92 | + List<BakedQuad> instance, Operation<Boolean> original, |
| 93 | + BlockAndTintGetter world, List<BlockModelPart> list, BlockState state, |
| 94 | + BlockPos pos, PoseStack poseStack, VertexConsumer vertexConsumer, |
| 95 | + boolean cull, int light) |
| 96 | + { |
| 97 | + ShouldDrawSideEvent event = new ShouldDrawSideEvent(state, pos); |
| 98 | + EventManager.fire(event); |
| 99 | + |
| 100 | + if(Boolean.FALSE.equals(event.isRendered())) |
| 101 | + return true; |
| 102 | + |
| 103 | + return original.call(instance); |
| 104 | + } |
75 | 105 | } |
0 commit comments