2021-03-06 20:32:38 +00:00
|
|
|
package net.shadowfacts.phycon.client.model
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockState
|
|
|
|
import net.minecraft.client.render.model.BakedModel
|
|
|
|
import net.minecraft.client.render.model.ModelLoader
|
|
|
|
import net.minecraft.client.texture.Sprite
|
2021-03-15 22:30:35 +00:00
|
|
|
import net.minecraft.client.util.SpriteIdentifier
|
2021-03-06 20:32:38 +00:00
|
|
|
import net.minecraft.util.Identifier
|
|
|
|
import net.shadowfacts.phycon.PhysicalConnectivity
|
|
|
|
import net.shadowfacts.phycon.block.FaceDeviceBlock
|
|
|
|
import net.shadowfacts.phycon.block.redstone_controller.RedstoneControllerBlock
|
2021-03-15 22:30:35 +00:00
|
|
|
import java.util.function.Function
|
2021-03-06 20:32:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author shadowfacts
|
|
|
|
*/
|
|
|
|
object RedstoneControllerModel: FaceDeviceModel() {
|
|
|
|
|
|
|
|
private val ON = Identifier(PhysicalConnectivity.MODID, "block/redstone_controller_side_on")
|
|
|
|
private val OFF = Identifier(PhysicalConnectivity.MODID, "block/redstone_controller_side_off")
|
|
|
|
private val onModels = Array<BakedModel?>(6) { null }
|
|
|
|
private val offModels = Array<BakedModel?>(6) { null }
|
|
|
|
|
|
|
|
override fun getSideModelIDs(): Collection<Identifier> {
|
|
|
|
return listOf(ON, OFF)
|
|
|
|
}
|
|
|
|
|
2021-03-15 22:30:35 +00:00
|
|
|
override fun bakeSideModels(loader: ModelLoader, textureGetter: Function<SpriteIdentifier, Sprite>) {
|
2021-03-06 20:32:38 +00:00
|
|
|
defaultRotations.forEachIndexed { i, rot ->
|
|
|
|
onModels[i] = loader.bake(ON, rot)
|
|
|
|
offModels[i] = loader.bake(OFF, rot)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getSideModel(state: BlockState): BakedModel? {
|
|
|
|
return if (state[RedstoneControllerBlock.POWERED]) {
|
|
|
|
onModels[state[FaceDeviceBlock.FACING].ordinal]
|
|
|
|
} else {
|
|
|
|
offModels[state[FaceDeviceBlock.FACING].ordinal]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-22 23:59:51 +00:00
|
|
|
override fun getParticleSprite(): Sprite {
|
|
|
|
return offModels.first()!!.particleSprite
|
2021-03-06 20:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|