Small lathe update / Moved some render function helper

This commit is contained in:
2025-09-02 22:03:54 +02:00
parent ac7e2a8789
commit d56daa5779
20 changed files with 120 additions and 62 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -22,7 +22,6 @@ import com.google.common.collect.MapMaker;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.cache.object.GeoBone;
import software.bernie.geckolib.core.animatable.GeoAnimatable;
import software.bernie.geckolib.renderer.GeoRenderer;
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
@@ -68,8 +67,7 @@ public final class IndicatorTintLayer<T extends BlockEntity & GeoAnimatable> ext
if (a <= 0.001f) return;
// Hide everything except the target bone
List<GeoBone> toggled = new ArrayList<>();
for (GeoBone root : model.topLevelBones()) hideAllExcept(root, boneName, toggled);
var toggled = RenderUtil.hideAllExcept(model, boneName);
// Re-render only that bone, tinted
var tex = getRenderer().getTextureLocation(animatable);
@@ -89,17 +87,7 @@ public final class IndicatorTintLayer<T extends BlockEntity & GeoAnimatable> ext
r, g, b, a);
// Restore visibility
for (GeoBone bone : toggled) bone.setHidden(false);
}
private static void hideAllExcept(GeoBone node, String target, List<GeoBone> toggled) {
if (!node.getName().equals(target)) {
if (!node.isHidden()) {
node.setHidden(true);
toggled.add(node);
}
for (GeoBone c : node.getChildBones()) hideAllExcept(c, target, toggled);
}
RenderUtil.restoreVisibility(toggled);
}
private int resolveColor(T be) {
@@ -160,7 +148,7 @@ public final class IndicatorTintLayer<T extends BlockEntity & GeoAnimatable> ext
if (px < 0 || px >= w) continue;
int abgr = sprite.getPixelRGBA(0, px, py);
int argb = abgrToArgb(abgr);
int argb = RenderUtil.abgrToArgb(abgr);
int a = (argb >>> 24) & 0xFF;
if (a == 0) continue;
@@ -182,14 +170,6 @@ public final class IndicatorTintLayer<T extends BlockEntity & GeoAnimatable> ext
return (a << 24) | (r << 16) | (g << 8) | b;
}
private static int abgrToArgb(int abgr) {
int a = (abgr >>> 24) & 0xFF;
int b = (abgr >>> 16) & 0xFF;
int g = (abgr >>> 8) & 0xFF;
int r = abgr & 0xFF;
return (a << 24) | (r << 16) | (g << 8) | b;
}
private static int materialTintOrZero(Item item, int layerIndex) {
if (item == null) return 0;
var ms = ChemicalHelper.getMaterialStack(item);

View File

@@ -0,0 +1,49 @@
package com.imbgt.ibg.block.entity.client.renderLayer;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.cache.object.GeoBone;
import java.util.ArrayList;
import java.util.List;
/**
* Small helpers shared by render layers to reduce duplication.
*/
public final class RenderUtil {
private RenderUtil() {}
/**
* Hides all bones except the target and returns a list of bones whose hidden
* state was toggled, so it can be restored afterwards.
*/
public static List<GeoBone> hideAllExcept(BakedGeoModel model, String targetBoneName) {
List<GeoBone> toggled = new ArrayList<>();
for (GeoBone root : model.topLevelBones()) hideAllExcept(root, targetBoneName, toggled);
return toggled;
}
/** Restores visibility for bones previously toggled by {@link #hideAllExcept}. */
public static void restoreVisibility(List<GeoBone> toggled) {
for (GeoBone bone : toggled) bone.setHidden(false);
}
private static void hideAllExcept(GeoBone node, String target, List<GeoBone> toggled) {
if (!node.getName().equals(target)) {
if (!node.isHidden()) {
node.setHidden(true);
toggled.add(node);
}
for (GeoBone c : node.getChildBones()) hideAllExcept(c, target, toggled);
}
}
/** Utility to convert ABGR pixel to ARGB. */
public static int abgrToArgb(int abgr) {
int a = (abgr >>> 24) & 0xFF;
int b = (abgr >>> 16) & 0xFF;
int g = (abgr >>> 8) & 0xFF;
int r = abgr & 0xFF;
return (a << 24) | (r << 16) | (g << 8) | b;
}
}

View File

@@ -139,10 +139,10 @@
"vector": [65, 0, 0]
},
"3.25": {
"vector": ["65*5", 0, 0]
"vector": ["45*5", 0, 0]
},
"3.2917": {
"vector": ["65*5", 0, 0]
"vector": ["45*5", 0, 0]
},
"4.0": {
"vector": [0, 0, 0]

View File

@@ -51,7 +51,7 @@
"north": {"uv": [51, 41], "uv_size": [16, 1]},
"east": {"uv": [37, 33], "uv_size": [2, 1]},
"south": {"uv": [53, 21], "uv_size": [16, 1]},
"west": {"uv": [51, 60], "uv_size": [2, 1]},
"west": {"uv": [38, 61], "uv_size": [2, 1]},
"up": {"uv": [45, 35], "uv_size": [16, 2]}
}
},
@@ -110,12 +110,12 @@
"pivot": [16.5, 9.3636, 0.07071],
"rotation": [45, 0, 0],
"uv": {
"north": {"uv": [59, 54], "uv_size": [3, 1]},
"east": {"uv": [43, 61], "uv_size": [1, 1]},
"south": {"uv": [60, 40], "uv_size": [3, 1]},
"west": {"uv": [45, 61], "uv_size": [1, 1]},
"up": {"uv": [60, 55], "uv_size": [3, 1]},
"down": {"uv": [60, 57], "uv_size": [3, -1]}
"north": {"uv": [60, 40], "uv_size": [3, 1]},
"east": {"uv": [12, 62], "uv_size": [1, 1]},
"south": {"uv": [61, 35], "uv_size": [3, 1]},
"west": {"uv": [14, 62], "uv_size": [1, 1]},
"up": {"uv": [61, 36], "uv_size": [3, 1]},
"down": {"uv": [61, 38], "uv_size": [3, -1]}
}
},
{
@@ -142,7 +142,7 @@
"pivot": [-6.675, 7.37474, 0.91064],
"rotation": [-178, 0, 0],
"uv": {
"up": {"uv": [13, 61], "uv_size": [1, 2]}
"up": {"uv": [57, 61], "uv_size": [1, 2]}
}
},
{
@@ -151,7 +151,7 @@
"pivot": [-6.675, 7.3179, -0.68835],
"rotation": [-40.5, 0, 0],
"uv": {
"up": {"uv": [20, 61], "uv_size": [1, 2]}
"up": {"uv": [6, 62], "uv_size": [1, 2]}
}
},
{
@@ -160,7 +160,7 @@
"pivot": [-6.675, 8.37203, -1.97829],
"rotation": [92, 0, 0],
"uv": {
"up": {"uv": [21, 61], "uv_size": [1, 2]}
"up": {"uv": [7, 62], "uv_size": [1, 2]}
}
},
{
@@ -169,7 +169,7 @@
"pivot": [-6.675, 11.29634, -0.94438],
"rotation": [-130.5, 0, 0],
"uv": {
"up": {"uv": [28, 61], "uv_size": [1, 2]}
"up": {"uv": [8, 62], "uv_size": [1, 2]}
}
},
{
@@ -187,7 +187,7 @@
"pivot": [-6.675, 15.24636, 8.32941],
"rotation": [-41, 0, 0],
"uv": {
"up": {"uv": [61, 37], "uv_size": [1, 1]}
"up": {"uv": [59, 54], "uv_size": [1, 1]}
}
},
{
@@ -196,7 +196,7 @@
"pivot": [-6.675, 14.33763, 8.78352],
"rotation": [-86, 0, 0],
"uv": {
"up": {"uv": [38, 61], "uv_size": [1, 1]}
"up": {"uv": [61, 52], "uv_size": [1, 1]}
}
},
{
@@ -205,7 +205,7 @@
"pivot": [-6.675, 13.41911, 8.33982],
"rotation": [-133, 0, 0],
"uv": {
"up": {"uv": [39, 61], "uv_size": [1, 1]}
"up": {"uv": [11, 62], "uv_size": [1, 1]}
}
},
{
@@ -218,8 +218,8 @@
"east": {"uv": [36, 52], "uv_size": [2, 6]},
"south": {"uv": [4, 56], "uv_size": [1, 6]},
"west": {"uv": [22, 54], "uv_size": [2, 6]},
"up": {"uv": [29, 61], "uv_size": [1, 2]},
"down": {"uv": [61, 37], "uv_size": [1, -2]}
"up": {"uv": [9, 62], "uv_size": [1, 2]},
"down": {"uv": [10, 64], "uv_size": [1, -2]}
}
},
{
@@ -347,11 +347,11 @@
"pivot": [-6.65, 9.36396, 0],
"rotation": [70, 0, 0],
"uv": {
"north": {"uv": [41, 60], "uv_size": [1, 3]},
"south": {"uv": [42, 60], "uv_size": [1, 3]},
"north": {"uv": [13, 61], "uv_size": [1, 3]},
"south": {"uv": [20, 61], "uv_size": [1, 3]},
"west": {"uv": [50, 55], "uv_size": [3, 3]},
"up": {"uv": [49, 60], "uv_size": [1, 3]},
"down": {"uv": [50, 63], "uv_size": [1, -3]}
"up": {"uv": [21, 61], "uv_size": [1, 3]},
"down": {"uv": [28, 64], "uv_size": [1, -3]}
}
}
]
@@ -366,11 +366,11 @@
"pivot": [-6.7, 14.24264, 7.41421],
"rotation": [27.5, 0, 0],
"uv": {
"north": {"uv": [0, 61], "uv_size": [1, 2]},
"south": {"uv": [1, 61], "uv_size": [1, 2]},
"north": {"uv": [47, 61], "uv_size": [1, 2]},
"south": {"uv": [48, 61], "uv_size": [1, 2]},
"west": {"uv": [56, 38], "uv_size": [2, 2]},
"up": {"uv": [2, 61], "uv_size": [1, 2]},
"down": {"uv": [3, 63], "uv_size": [1, -2]}
"up": {"uv": [61, 50], "uv_size": [1, 2]},
"down": {"uv": [56, 63], "uv_size": [1, -2]}
}
},
{
@@ -379,11 +379,11 @@
"pivot": [-6.7, 14.24264, 7.41421],
"rotation": [70, 0, 0],
"uv": {
"north": {"uv": [16, 61], "uv_size": [1, 2]},
"south": {"uv": [17, 61], "uv_size": [1, 2]},
"north": {"uv": [58, 61], "uv_size": [1, 2]},
"south": {"uv": [59, 61], "uv_size": [1, 2]},
"west": {"uv": [56, 55], "uv_size": [2, 2]},
"up": {"uv": [18, 61], "uv_size": [1, 2]},
"down": {"uv": [19, 63], "uv_size": [1, -2]}
"up": {"uv": [4, 62], "uv_size": [1, 2]},
"down": {"uv": [5, 64], "uv_size": [1, -2]}
}
}
]
@@ -466,19 +466,19 @@
"origin": [15.5, 13.67357, 1.80628],
"size": [-1, 2, 2],
"uv": {
"north": {"uv": [54, 60], "uv_size": [1, 2]},
"north": {"uv": [29, 61], "uv_size": [1, 2]},
"east": {"uv": [32, 56], "uv_size": [2, 2]},
"south": {"uv": [55, 60], "uv_size": [1, 2]},
"south": {"uv": [43, 61], "uv_size": [1, 2]},
"west": {"uv": [34, 56], "uv_size": [2, 2]},
"up": {"uv": [60, 57], "uv_size": [1, 2]},
"down": {"uv": [60, 61], "uv_size": [1, -2]}
"up": {"uv": [45, 61], "uv_size": [1, 2]},
"down": {"uv": [46, 63], "uv_size": [1, -2]}
}
},
{
"origin": [11.93333, 15.98125, 1.91771],
"size": [1, 1, 0],
"uv": {
"south": {"uv": [46, 61], "uv_size": [1, 1]}
"south": {"uv": [62, 14], "uv_size": [1, 1]}
}
},
{
@@ -487,14 +487,14 @@
"pivot": [12.43333, 15.58125, 4.71771],
"rotation": [90, 0, 0],
"uv": {
"south": {"uv": [48, 61], "uv_size": [1, 1]}
"south": {"uv": [62, 15], "uv_size": [1, 1]}
}
},
{
"origin": [13.03333, 13.58125, -0.18229],
"size": [0, 1, 1],
"uv": {
"east": {"uv": [47, 61], "uv_size": [1, 1]}
"east": {"uv": [15, 62], "uv_size": [1, 1]}
}
},
{
@@ -503,7 +503,7 @@
"pivot": [13.03333, 11.58125, 3.31771],
"rotation": [-90, 0, 0],
"uv": {
"east": {"uv": [61, 50], "uv_size": [1, 1]}
"east": {"uv": [22, 62], "uv_size": [1, 1]}
}
},
{
@@ -609,6 +609,18 @@
"up": {"uv": [59, 50], "uv_size": [2, 2]},
"down": {"uv": [56, 61], "uv_size": [2, -2]}
}
},
{
"origin": [12.71802, 14.65202, 1.7184],
"size": [2, 2, 2],
"uv": {
"north": {"uv": [41, 60], "uv_size": [2, 2]},
"east": {"uv": [49, 60], "uv_size": [2, 2]},
"south": {"uv": [51, 60], "uv_size": [2, 2]},
"west": {"uv": [54, 60], "uv_size": [2, 2]},
"up": {"uv": [60, 54], "uv_size": [2, 2]},
"down": {"uv": [60, 58], "uv_size": [2, -2]}
}
}
]
},
@@ -630,6 +642,23 @@
}
}
]
},
{
"name": "led",
"pivot": [-7, 3, -7],
"cubes": [
{
"origin": [-7.6, 1.4, -7.32],
"size": [2, 2, 2],
"uv": {
"north": {"uv": [60, 58], "uv_size": [2, 2]},
"east": {"uv": [60, 60], "uv_size": [2, 2]},
"south": {"uv": [0, 61], "uv_size": [2, 2]},
"west": {"uv": [2, 61], "uv_size": [2, 2]},
"up": {"uv": [16, 61], "uv_size": [2, 2]}
}
}
]
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB