Add Crafting Terminal texture/model

This commit is contained in:
Shadowfacts 2021-03-28 14:34:29 -04:00
parent 9d98481ba5
commit 12e055d645
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
6 changed files with 74 additions and 13 deletions

View File

@ -6,7 +6,7 @@ import net.minecraft.client.render.model.UnbakedModel
import net.minecraft.resource.ResourceManager
import net.minecraft.util.Identifier
import net.shadowfacts.phycon.PhysicalConnectivity
import net.shadowfacts.phycon.client.model.TerminalModel
import net.shadowfacts.phycon.client.model.ScreenDeviceModel
/**
* @author shadowfacts
@ -15,11 +15,13 @@ class PhyExtendedModelProvider(resourceManager: ResourceManager): ModelResourceP
companion object {
val TERMINAL = Identifier(PhysicalConnectivity.MODID, "block/terminal")
val CRAFTING_TERMINAL = Identifier(PhysicalConnectivity.MODID, "block/crafting_terminal")
}
override fun loadModelResource(resourceId: Identifier, context: ModelProviderContext): UnbakedModel? {
return when (resourceId) {
TERMINAL -> TerminalModel
TERMINAL -> ScreenDeviceModel(TERMINAL)
CRAFTING_TERMINAL -> ScreenDeviceModel(CRAFTING_TERMINAL)
else -> null
}
}

View File

@ -27,13 +27,18 @@ import java.util.function.Supplier
/**
* @author shadowfacts
*/
object TerminalModel: UnbakedModel, BakedModel, FabricBakedModel {
class ScreenDeviceModel(
screenTexture: Identifier,
): UnbakedModel, BakedModel, FabricBakedModel {
private val TERMINAL = SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, Identifier(PhysicalConnectivity.MODID, "block/terminal"))
private val CASING = SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, Identifier(PhysicalConnectivity.MODID, "block/casing"))
companion object {
private val CASING = SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, Identifier(PhysicalConnectivity.MODID, "block/casing"))
}
private val screenTexture = SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, screenTexture)
private lateinit var meshes: Array<Mesh>
private lateinit var terminalSprite: Sprite
private lateinit var screenSprite: Sprite
override fun getModelDependencies(): Collection<Identifier> {
return listOf()
@ -43,7 +48,7 @@ object TerminalModel: UnbakedModel, BakedModel, FabricBakedModel {
unbakedModelGetter: Function<Identifier, UnbakedModel>,
unresolvedTextureDependencies: MutableSet<Pair<String, String>>
): Collection<SpriteIdentifier> {
return listOf(TERMINAL, CASING)
return listOf(screenTexture, CASING)
}
override fun bake(
@ -53,7 +58,7 @@ object TerminalModel: UnbakedModel, BakedModel, FabricBakedModel {
modelId: Identifier
): BakedModel {
terminalSprite = textureGetter.apply(TERMINAL)
screenSprite = textureGetter.apply(screenTexture)
val casingSprite = textureGetter.apply(CASING)
val renderer = RendererAccess.INSTANCE.renderer!!
@ -67,25 +72,25 @@ object TerminalModel: UnbakedModel, BakedModel, FabricBakedModel {
for (dir in Direction.values()) {
if (dir == facing) {
emitter.square(facing, 0f, 0f, 1f, 1f, QuadEmitter.CULL_FACE_EPSILON * 10)
emitter.spriteBake(0, terminalSprite, MutableQuadView.BAKE_LOCK_UV)
emitter.spriteBake(0, screenSprite, MutableQuadView.BAKE_LOCK_UV)
emitter.spriteColor(0, -1, -1, -1, -1)
emitter.emit()
emitter.material(PhysicalConnectivityClient.screenMaterial)
emitter.square(facing, 3/16f, 2/16f, 13/16f, 3/16f, 0f)
emitter.spriteBake(0, terminalSprite, MutableQuadView.BAKE_LOCK_UV)
emitter.spriteBake(0, screenSprite, MutableQuadView.BAKE_LOCK_UV)
emitter.spriteColor(0, -1, -1, -1, -1)
emitter.emit()
emitter.material(PhysicalConnectivityClient.screenMaterial)
emitter.square(facing, 2/16f, 3/16f, 14/16f, 13/16f, 0f)
emitter.spriteBake(0, terminalSprite, MutableQuadView.BAKE_LOCK_UV)
emitter.spriteBake(0, screenSprite, MutableQuadView.BAKE_LOCK_UV)
emitter.spriteColor(0, -1, -1, -1, -1)
emitter.emit()
emitter.material(PhysicalConnectivityClient.screenMaterial)
emitter.square(facing, 3/16f, 13/16f, 13/16f, 14/16f, 0f)
emitter.spriteBake(0, terminalSprite, MutableQuadView.BAKE_LOCK_UV)
emitter.spriteBake(0, screenSprite, MutableQuadView.BAKE_LOCK_UV)
emitter.spriteColor(0, -1, -1, -1, -1)
emitter.emit()
} else {
@ -129,7 +134,7 @@ object TerminalModel: UnbakedModel, BakedModel, FabricBakedModel {
override fun isBuiltin() = false
override fun getSprite() = terminalSprite
override fun getSprite() = screenSprite
override fun getTransformation() = null

View File

@ -0,0 +1,27 @@
{
"variants": {
"facing=down": {
"model": "phycon:block/crafting_terminal",
"x": 90
},
"facing=up": {
"model": "phycon:block/crafting_terminal",
"x": 270
},
"facing=north": {
"model": "phycon:block/crafting_terminal"
},
"facing=south": {
"model": "phycon:block/crafting_terminal",
"y": 180
},
"facing=west": {
"model": "phycon:block/crafting_terminal",
"y": 270
},
"facing=east": {
"model": "phycon:block/crafting_terminal",
"y": 90
}
}
}

View File

@ -0,0 +1,14 @@
{
"parent": "block/cube",
"textures": {
"side": "phycon:block/casing",
"front": "phycon:block/crafting_terminal",
"particle": "#side",
"down": "#side",
"up": "#side",
"north": "#front",
"south": "#side",
"west": "#side",
"east": "#side"
}
}

View File

@ -0,0 +1,13 @@
{
"parent": "block/cube",
"textures": {
"side": "phycon:block/casing",
"front": "phycon:block/crafting_terminal",
"down": "#side",
"up": "#side",
"north": "#side",
"south": "#side",
"west": "#side",
"east": "#front"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB