blob: 2d15d3cb7f7440a0c13102b5522f2072dd324081 (
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
30
31
32
33
34
35
36
37
38
39
|
package at.hannibal2.skyhanni.mixins.hooks
import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor
import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor.CommissionBlock.Companion.onColor
import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor.replaceBlocksMapCache
import at.hannibal2.skyhanni.features.mining.OreType.Companion.isOreType
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraft.block.state.IBlockState
import net.minecraft.client.renderer.BlockRendererDispatcher
import net.minecraft.client.resources.model.IBakedModel
import net.minecraft.util.BlockPos
import net.minecraft.world.IBlockAccess
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
// Taken and modified from Skytils
fun modifyGetModelFromBlockState(
blockRendererDispatcher: BlockRendererDispatcher,
state: IBlockState?,
worldIn: IBlockAccess,
pos: BlockPos?,
cir: CallbackInfoReturnable<IBakedModel>,
) {
if (state == null || pos == null) return
var returnState: IBlockState = state
if (!LorenzUtils.inSkyBlock) return
if (MiningCommissionsBlocksColor.enabled && MiningCommissionsBlocksColor.active) {
returnState = replaceBlocksMapCache.getOrPut(state) {
MiningCommissionsBlocksColor.CommissionBlock.entries.firstOrNull {
state.isOreType(it.oreType)
}?.onColor(state) ?: state
}
}
if (returnState !== state) {
cir.returnValue = blockRendererDispatcher.blockModelShapes.getModelForState(returnState)
}
}
|