aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/mixin/MixinTessellator.java
blob: 15f71da96f5c2b8bfbbcd042cf75a411e67b040e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package makamys.neodymium.mixin;

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;

import makamys.neodymium.ducks.ITessellator;
import makamys.neodymium.renderer.ChunkMesh;
import net.minecraft.client.renderer.Tessellator;

@Mixin(Tessellator.class)
abstract class MixinTessellator implements ITessellator {
    
    private boolean nd$captureMeshes;
    
    @Inject(method = "draw", at = @At(value = "HEAD"))
    private void preDraw(CallbackInfoReturnable<Integer> cir) {
        if(nd$captureMeshes) {
            ChunkMesh.preTessellatorDraw((Tessellator)(Object)this);
        }
    }
    
    @Override
    public void enableMeshCapturing(boolean enable) {
        nd$captureMeshes = enable;
    }
    
}