blockinfo
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Vintagestory.API.Client;
|
||||
using Vintagestory.API.Common;
|
||||
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)
|
||||
{
|
||||
Vec3d local = ToBaseOrientation(hitPosition);
|
||||
|
||||
Reference in New Issue
Block a user