Render the computer cursor as emissive
- Split the front face of the computer model into two layers - one for the main texture, and one for the cursor. This is actually a simplification of what we had before, which is nice. - Make the cursor layer render as an emissive quad, meaning it glows in the dark. This is very easy on Forge (just some model JSON) and very hard on Fabric (requires a custom model loader).
@@ -37,6 +37,14 @@ import static net.minecraft.data.models.model.ModelLocationUtils.getModelLocatio
|
||||
import static net.minecraft.data.models.model.TextureMapping.getBlockTexture;
|
||||
|
||||
class BlockModelProvider {
|
||||
private static final TextureSlot CURSOR = TextureSlot.create("cursor");
|
||||
|
||||
private static final ModelTemplate COMPUTER_ON = new ModelTemplate(
|
||||
Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/computer_on")),
|
||||
Optional.empty(),
|
||||
TextureSlot.FRONT, TextureSlot.SIDE, TextureSlot.TOP, CURSOR
|
||||
);
|
||||
|
||||
private static final ModelTemplate MONITOR_BASE = new ModelTemplate(
|
||||
Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/monitor_base")),
|
||||
Optional.empty(),
|
||||
@@ -142,11 +150,18 @@ class BlockModelProvider {
|
||||
private static void registerComputer(BlockModelGenerators generators, ComputerBlock<?> block) {
|
||||
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(block)
|
||||
.with(createHorizontalFacingDispatch())
|
||||
.with(createModelDispatch(ComputerBlock.STATE, state -> ModelTemplates.CUBE_ORIENTABLE.createWithSuffix(
|
||||
block, "_" + state.getSerializedName(),
|
||||
TextureMapping.orientableCube(block).put(TextureSlot.FRONT, getBlockTexture(block, "_front" + state.getTexture())),
|
||||
generators.modelOutput
|
||||
)))
|
||||
.with(createModelDispatch(ComputerBlock.STATE, state -> switch (state) {
|
||||
case OFF -> ModelTemplates.CUBE_ORIENTABLE.createWithSuffix(
|
||||
block, "_" + state.getSerializedName(),
|
||||
TextureMapping.orientableCube(block),
|
||||
generators.modelOutput
|
||||
);
|
||||
case ON, BLINKING -> COMPUTER_ON.createWithSuffix(
|
||||
block, "_" + state.getSerializedName(),
|
||||
TextureMapping.orientableCube(block).put(CURSOR, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/computer" + state.getTexture())),
|
||||
generators.modelOutput
|
||||
);
|
||||
}))
|
||||
);
|
||||
generators.delegateItemModel(block, getModelLocation(block, "_blinking"));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"parent": "minecraft:block/block",
|
||||
"render_type": "cutout",
|
||||
"textures": {
|
||||
"particle": "#front"
|
||||
},
|
||||
"display": {
|
||||
"firstperson_righthand": {
|
||||
"rotation": [ 0, 135, 0 ],
|
||||
"translation": [ 0, 0, 0 ],
|
||||
"scale": [ 0.40, 0.40, 0.40 ]
|
||||
}
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [ 0, 0, 0 ],
|
||||
"to": [ 16, 16, 16 ],
|
||||
"faces": {
|
||||
"down": { "texture": "#top", "cullface": "down" },
|
||||
"up": { "texture": "#top", "cullface": "up" },
|
||||
"north": { "texture": "#front", "cullface": "north" },
|
||||
"south": { "texture": "#side", "cullface": "south" },
|
||||
"west": { "texture": "#side", "cullface": "west" },
|
||||
"east": { "texture": "#side", "cullface": "east" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [ 0, 0, 0 ],
|
||||
"to": [ 16, 16, 16 ],
|
||||
"faces": {
|
||||
"north": {
|
||||
"texture": "#cursor",
|
||||
"cullface": "north",
|
||||
"forge_data": {"block_light": 15, "sky_light": 15}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
|
||||
|
||||
SPDX-License-Identifier: MPL-2.0
|
||||
|
Before Width: | Height: | Size: 476 B |
|
Before Width: | Height: | Size: 417 B |
|
After Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 534 B |
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 8,
|
||||
"frames": [ 0, 1 ]
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 426 B |
|
Before Width: | Height: | Size: 214 B |
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 8,
|
||||
"frames": [ 0, 1 ]
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 199 B |
|
After Width: | Height: | Size: 89 B |