adjust offsets and size

This commit is contained in:
2026-03-19 00:06:28 +01:00
parent 56b9a0d209
commit c3eedb8bdd
4 changed files with 39 additions and 14 deletions

View File

@@ -28,6 +28,16 @@ public class BlockEntityButterflyPinBoard : BlockEntityDisplay
private float RenderScale => Block?.Attributes?["renderScale"].AsFloat(0.18f) ?? 0.18f;
private float DisplayOriginX => GetDisplayFloat("displayOriginX", 0.31666666f);
private float DisplayOriginY => GetDisplayFloat("displayOriginY", 0.01333332f);
private float DisplayOriginZ => GetDisplayFloat("displayOriginZ", 0.47916666f);
private float DisplayStepX => GetDisplayFloat("displayStepX", -0.25f);
private float DisplayStepY => GetDisplayFloat("displayStepY", -0.25f);
private int ActiveSlotCount => Rows * Columns;
public BlockEntityButterflyPinBoard()
@@ -148,14 +158,14 @@ public class BlockEntityButterflyPinBoard : BlockEntityDisplay
);
}
private float GetDisplayFloat(string key, float defaultValue)
{
return Block?.Attributes?[key].AsFloat(defaultValue) ?? defaultValue;
}
protected override float[][] genTransformationMatrices()
{
float[][] matrices = new float[DisplayedItems][];
double cellWidth = (1 - (BoardMargin * 2)) / Columns;
double cellHeight = (1 - (BoardMargin * 2)) / Rows;
float stepX = 0.75f / Columns;
float stepY = 0.75f / Rows;
float yOffset = (Rows == 2 && Columns == 2 ? 1.0f : 0.75f) + 0.07f;
float boardRotationY = GetRotationY();
float itemRotationY = boardRotationY - GameMath.PIHALF;
@@ -164,19 +174,19 @@ public class BlockEntityButterflyPinBoard : BlockEntityDisplay
int row = slotIndex / Columns;
int column = slotIndex % Columns;
float x = (float)(1 - BoardMargin - (0.5 * cellWidth) - (column * stepX));
float y = (float)(BoardMargin + (0.5 * cellHeight) + ((Rows - 1 - row) * stepY));
float z = Columns == 2 ? -0/1f : -1/48f;
float xOffset = Columns == 2 ? 0.465f : 0.475f;
Vec3f off = new(x - xOffset, y - yOffset, z + 0.5f);
Vec3f off = new(
DisplayOriginX + (column * DisplayStepX),
DisplayOriginY + (row * DisplayStepY),
DisplayOriginZ
);
off = new Matrixf().RotateY(boardRotationY).TransformVector(off.ToVec4f(0)).XYZ;
matrices[slotIndex] = new Matrixf()
.Translate(off.X, off.Y, off.Z)
.Translate(0.5f, 0f, 0.5f)
.Translate(0.5f, 0.5f, 0.5f)
.RotateY(itemRotationY)
.Scale(RenderScale, RenderScale, RenderScale)
.Translate(-0.5f, 0f, -0.5f)
.Translate(-0.5f, -0.5f, -0.5f)
.Values;
}

View File

@@ -13,6 +13,11 @@
"rows": 2,
"columns": 2,
"renderScale": 0.85,
"displayOriginX": 0.25375,
"displayOriginY": -0.5075,
"displayOriginZ": 0.5,
"displayStepX": -0.375,
"displayStepY": -0.375,
"reinforcable": true
},
"creativeinventory": {

View File

@@ -12,7 +12,12 @@
"attributes": {
"rows": 3,
"columns": 3,
"renderScale": 0.675,
"renderScale": 0.85,
"displayOriginX": 0.33229166,
"displayOriginY": -0.40541668,
"displayOriginZ": 0.5,
"displayStepX": -0.25,
"displayStepY": -0.25,
"reinforcable": true
},
"creativeinventory": {