Compare commits

...

5 Commits

Author SHA1 Message Date
f7f32a07e9 make pin board woodtyped 2026-03-19 02:19:51 +01:00
44ea336e61 fix sounds 2026-03-19 02:08:38 +01:00
e48580f10a blockinfo 2026-03-19 02:06:07 +01:00
7f02401df4 fix wrong horizontal selection for north/south variants 2026-03-19 01:56:55 +01:00
1d418ec614 adjust modinfo, icon, modid, add license 2026-03-19 01:56:21 +01:00
12 changed files with 124 additions and 44 deletions

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Text;
using Vintagestory.API.Client; using Vintagestory.API.Client;
using Vintagestory.API.Common; using Vintagestory.API.Common;
using Vintagestory.API.Datastructures; using Vintagestory.API.Datastructures;
@@ -110,6 +111,46 @@ public class BlockEntityButterflyPinBoard : BlockEntityDisplay
} }
} }
public override void GetBlockInfo(IPlayer forPlayer, StringBuilder dsc)
{
int highlightedSlot = -1;
BlockSelection? selection = forPlayer?.CurrentBlockSelection;
if (selection?.Position != null && selection.Position.Equals(Pos))
highlightedSlot = GetSlotIndex(selection.HitPosition);
AppendContentsBlockInfo(dsc, highlightedSlot);
}
public bool AppendContentsBlockInfo(StringBuilder builder, int highlightedSlot)
{
int initialLength = builder.Length;
for (int slotIndex = 0; slotIndex < ActiveSlotCount; slotIndex++)
{
ItemStack? stack = inventory[slotIndex].Itemstack;
if (stack == null)
continue;
if (builder.Length > initialLength)
builder.AppendLine();
else if (initialLength > 0)
builder.AppendLine();
string itemName = stack.GetName();
if (slotIndex == highlightedSlot)
{
builder.Append("<font color=\"#00ffff\">");
builder.Append(itemName);
builder.Append("</font>");
continue;
}
builder.Append(itemName);
}
return builder.Length > initialLength;
}
public int GetSlotIndex(Vec3d hitPosition) public int GetSlotIndex(Vec3d hitPosition)
{ {
Vec3d local = ToBaseOrientation(hitPosition); Vec3d local = ToBaseOrientation(hitPosition);
@@ -120,6 +161,9 @@ public class BlockEntityButterflyPinBoard : BlockEntityDisplay
double height = (1 - (BoardMargin * 2)) / Rows; double height = (1 - (BoardMargin * 2)) / Rows;
int column = GameMath.Clamp((int)((local.X - BoardMargin) / width), 0, Columns - 1); int column = GameMath.Clamp((int)((local.X - BoardMargin) / width), 0, Columns - 1);
if (IsNorthSouthVariant())
column = (Columns - 1) - column;
int rowFromBottom = GameMath.Clamp((int)((local.Y - BoardMargin) / height), 0, Rows - 1); int rowFromBottom = GameMath.Clamp((int)((local.Y - BoardMargin) / height), 0, Rows - 1);
int rowFromTop = Rows - 1 - rowFromBottom; int rowFromTop = Rows - 1 - rowFromBottom;
@@ -205,6 +249,12 @@ public class BlockEntityButterflyPinBoard : BlockEntityDisplay
}; };
} }
private bool IsNorthSouthVariant()
{
string side = Block?.Variant?["side"] ?? "south";
return side is "north" or "south";
}
public float GetRenderScale() public float GetRenderScale()
{ {
return RenderScale; return RenderScale;

View File

@@ -1,4 +0,0 @@
{
"block-pinboard2x2-*": "Butterfly Pin Board (2x2)",
"block-pinboard3x3-*": "Butterfly Pin Board (3x3)"
}

View File

@@ -7,6 +7,7 @@
{ "name": "Lockable" } { "name": "Lockable" }
], ],
"variantgroups": [ "variantgroups": [
{ "code": "wood", "loadFromProperties": "block/wood" },
{ "code": "side", "loadFromProperties": "abstract/horizontalorientation" } { "code": "side", "loadFromProperties": "abstract/horizontalorientation" }
], ],
"attributes": { "attributes": {
@@ -21,14 +22,17 @@
"reinforcable": true "reinforcable": true
}, },
"creativeinventory": { "creativeinventory": {
"general": ["pinboard2x2-south"], "general": ["pinboard2x2-oak-north"],
"decorative": ["pinboard2x2-south"] "decorative": ["pinboard2x2-oak-north"]
},
"textures": {
"wood": { "base": "game:block/wood/debarked/{wood}" }
}, },
"shapebytype": { "shapebytype": {
"*-north": { "base": "butterflypins:block/pinboard-2x2", "rotateY": 180 }, "*-*-north": { "base": "dusiulkaspinboard:block/pinboard-2x2", "rotateY": 180 },
"*-east": { "base": "butterflypins:block/pinboard-2x2", "rotateY": 90 }, "*-*-east": { "base": "dusiulkaspinboard:block/pinboard-2x2", "rotateY": 90 },
"*-south": { "base": "butterflypins:block/pinboard-2x2", "rotateY": 0 }, "*-*-south": { "base": "dusiulkaspinboard:block/pinboard-2x2", "rotateY": 0 },
"*-west": { "base": "butterflypins:block/pinboard-2x2", "rotateY": 270 } "*-*-west": { "base": "dusiulkaspinboard:block/pinboard-2x2", "rotateY": 270 }
}, },
"blockmaterial": "Wood", "blockmaterial": "Wood",
"drawtype": "json", "drawtype": "json",
@@ -47,10 +51,10 @@
"y2": 0.9375, "y2": 0.9375,
"z2": 1.0, "z2": 1.0,
"rotateYByType": { "rotateYByType": {
"*-north": 180, "*-*-north": 180,
"*-east": 90, "*-*-east": 90,
"*-south": 0, "*-*-south": 0,
"*-west": 270 "*-*-west": 270
} }
}, },
"selectionbox": { "selectionbox": {
@@ -61,10 +65,10 @@
"y2": 0.9375, "y2": 0.9375,
"z2": 1.0, "z2": 1.0,
"rotateYByType": { "rotateYByType": {
"*-north": 180, "*-*-north": 180,
"*-east": 90, "*-*-east": 90,
"*-south": 0, "*-*-south": 0,
"*-west": 270 "*-*-west": 270
} }
}, },
"combustibleProps": { "combustibleProps": {
@@ -72,9 +76,9 @@
"burnDuration": 20 "burnDuration": 20
}, },
"sounds": { "sounds": {
"place": "block/planks", "place": "game:block/planks",
"break": "block/planks", "break": "game:block/planks",
"hit": "block/planks" "hit": "game:block/planks"
}, },
"materialDensity": 400, "materialDensity": 400,
"guiTransform": { "guiTransform": {

View File

@@ -7,6 +7,7 @@
{ "name": "Lockable" } { "name": "Lockable" }
], ],
"variantgroups": [ "variantgroups": [
{ "code": "wood", "loadFromProperties": "block/wood" },
{ "code": "side", "loadFromProperties": "abstract/horizontalorientation" } { "code": "side", "loadFromProperties": "abstract/horizontalorientation" }
], ],
"attributes": { "attributes": {
@@ -21,14 +22,17 @@
"reinforcable": true "reinforcable": true
}, },
"creativeinventory": { "creativeinventory": {
"general": ["pinboard3x3-south"], "general": ["pinboard3x3-oak-north"],
"decorative": ["pinboard3x3-south"] "decorative": ["pinboard3x3-oak-north"]
},
"textures": {
"wood": { "base": "game:block/wood/debarked/{wood}" }
}, },
"shapebytype": { "shapebytype": {
"*-north": { "base": "butterflypins:block/pinboard-3x3", "rotateY": 180 }, "*-*-north": { "base": "dusiulkaspinboard:block/pinboard-3x3", "rotateY": 180 },
"*-east": { "base": "butterflypins:block/pinboard-3x3", "rotateY": 90 }, "*-*-east": { "base": "dusiulkaspinboard:block/pinboard-3x3", "rotateY": 90 },
"*-south": { "base": "butterflypins:block/pinboard-3x3", "rotateY": 0 }, "*-*-south": { "base": "dusiulkaspinboard:block/pinboard-3x3", "rotateY": 0 },
"*-west": { "base": "butterflypins:block/pinboard-3x3", "rotateY": 270 } "*-*-west": { "base": "dusiulkaspinboard:block/pinboard-3x3", "rotateY": 270 }
}, },
"blockmaterial": "Wood", "blockmaterial": "Wood",
"drawtype": "json", "drawtype": "json",
@@ -47,10 +51,10 @@
"y2": 0.9375, "y2": 0.9375,
"z2": 1.0, "z2": 1.0,
"rotateYByType": { "rotateYByType": {
"*-north": 180, "*-*-north": 180,
"*-east": 90, "*-*-east": 90,
"*-south": 0, "*-*-south": 0,
"*-west": 270 "*-*-west": 270
} }
}, },
"selectionbox": { "selectionbox": {
@@ -61,10 +65,10 @@
"y2": 0.9375, "y2": 0.9375,
"z2": 1.0, "z2": 1.0,
"rotateYByType": { "rotateYByType": {
"*-north": 180, "*-*-north": 180,
"*-east": 90, "*-*-east": 90,
"*-south": 0, "*-*-south": 0,
"*-west": 270 "*-*-west": 270
} }
}, },
"combustibleProps": { "combustibleProps": {
@@ -72,9 +76,9 @@
"burnDuration": 25 "burnDuration": 25
}, },
"sounds": { "sounds": {
"place": "block/planks", "place": "game:block/planks",
"break": "block/planks", "break": "game:block/planks",
"hit": "block/planks" "hit": "game:block/planks"
}, },
"materialDensity": 400, "materialDensity": 400,
"guiTransform": { "guiTransform": {

View File

@@ -0,0 +1,4 @@
{
"block-pinboard2x2-*-*": "Butterfly Pin Board (2x2)",
"block-pinboard3x3-*-*": "Butterfly Pin Board (3x3)"
}

View File

@@ -1,7 +1,7 @@
{ {
"ingredientPattern": "_S_\tSBS\t_S_", "ingredientPattern": "_S_\tSBS\t_S_",
"ingredients": { "ingredients": {
"S": { "type": "item", "code": "game:stick" }, "S": { "type": "item", "code": "game:plank-*", "name": "wood" },
"B": { "B": {
"type": "item", "type": "item",
"code": "game:*-butterflypin-*" "code": "game:*-butterflypin-*"
@@ -9,5 +9,5 @@
}, },
"width": 3, "width": 3,
"height": 3, "height": 3,
"output": { "type": "block", "code": "pinboard2x2-north" } "output": { "type": "block", "code": "pinboard2x2-{wood}-north" }
} }

View File

@@ -1,7 +1,7 @@
{ {
"ingredientPattern": "S_S\t_B_\tS_S", "ingredientPattern": "S_S\t_B_\tS_S",
"ingredients": { "ingredients": {
"S": { "type": "item", "code": "game:stick" }, "S": { "type": "item", "code": "game:plank-*", "name": "wood" },
"B": { "B": {
"type": "item", "type": "item",
"code": "game:*-butterflypin-*" "code": "game:*-butterflypin-*"
@@ -9,5 +9,5 @@
}, },
"width": 3, "width": 3,
"height": 3, "height": 3,
"output": { "type": "block", "code": "pinboard3x3-north" } "output": { "type": "block", "code": "pinboard3x3-{wood}-north" }
} }

BIN
ButterflyPins/modicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@@ -1,7 +1,7 @@
{ {
"$schema": "https://moddbcdn.vintagestory.at/schema/modinfo.latest.json", "$schema": "https://moddbcdn.vintagestory.at/schema/modinfo.latest.json",
"type": "Code", "type": "Code",
"modid": "butterflypins", "modid": "dusiulkaspinboard",
"name": "Butterfly Pins", "name": "Butterfly Pins",
"authors": [ "authors": [
"OrekiWoof" "OrekiWoof"
@@ -11,5 +11,6 @@
"dependencies": { "dependencies": {
"game": "1.21.0" "game": "1.21.0"
}, },
"side": "Universal" "requiredOnServer": true,
"requiredOnClient": true
} }

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 OrekiWoof
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.