Browse Source

Make BlockColor.Index a property and other fixes

tags/v1.6.0
NorbiPeti 4 years ago
parent
commit
4701b3577d
2 changed files with 6 additions and 6 deletions
  1. +4
    -5
      GamecraftModdingAPI/Blocks/BlockColor.cs
  2. +2
    -1
      GamecraftModdingAPI/Blocks/TextBlock.cs

+ 4
- 5
GamecraftModdingAPI/Blocks/BlockColor.cs View File

@@ -7,7 +7,10 @@ namespace GamecraftModdingAPI.Blocks
{
public BlockColors Color;
public byte Darkness;
public byte Index;

public byte Index => Color == BlockColors.Default
? byte.MaxValue
: (byte) (Darkness * 10 + Color);

public BlockColor(byte index)
{
@@ -23,8 +26,6 @@ namespace GamecraftModdingAPI.Blocks
Color = (BlockColors) (index % 10);
Darkness = (byte) (index / 10);
}

Index = index;
}

public BlockColor(BlockColors color, byte darkness)
@@ -33,8 +34,6 @@ namespace GamecraftModdingAPI.Blocks
throw new ArgumentOutOfRangeException(nameof(darkness), "Darkness must be 0-9 where 0 is default.");
Color = color;
Darkness = darkness;
if (color == BlockColors.Default) Index = byte.MaxValue;
else Index = (byte) (darkness * 10 + color);
}

public float4 RGBA => Block.BlockEngine.ConvertBlockColor(Index);


+ 2
- 1
GamecraftModdingAPI/Blocks/TextBlock.cs View File

@@ -31,9 +31,9 @@ namespace GamecraftModdingAPI.Blocks

set
{
if (value == null) value = "";
BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
{
if (val == null) val = "";
tbds.textCurrent.Set(val);
tbds.textStored.Set(val);
}, value);
@@ -51,6 +51,7 @@ namespace GamecraftModdingAPI.Blocks

set
{
if (value == null) value = "";
BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
tbds.textBlockID.Set(val), value);
BlockEngine.SetBlockInfo(this,


Loading…
Cancel
Save