aboutsummaryrefslogtreecommitdiff
path: root/src/texturePacks/java/moe/nea/firmament/mixins/custommodels/ReplaceFallbackBlockModel.java
blob: 53ab74a23dfe24fddb922e3411fd0e9d377553b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package moe.nea.firmament.mixins.custommodels;

import moe.nea.firmament.features.texturepack.CustomBlockTextures;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.block.BlockModels;
import net.minecraft.client.render.model.BakedModel;
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;

@Mixin(BlockModels.class)
public class ReplaceFallbackBlockModel {
    // TODO: add check to BlockDustParticle
    @Inject(method = "getModel", at = @At("HEAD"), cancellable = true)
    private void getModel(BlockState state, CallbackInfoReturnable<BakedModel> cir) {
        var replacement = CustomBlockTextures.getReplacementModel(state, null);
        if (replacement != null)
            cir.setReturnValue(replacement);
    }
}