Merge pull request #2722 from Pryaxis/fix/nettile

Fix NetTile IndexOutOfRangeException
This commit is contained in:
Lucas Nicodemus 2022-10-12 22:16:34 -07:00 committed by GitHub
commit 23c3a9d133
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View file

@ -38,6 +38,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Allow Blood Butcherer and Shimmer buffs to be applied to NPCs by players. (@drunderscore)
* In OTAPI 3.1.11-alpha, chest stacking was fixed. (@SignatureBeef)
* In OTAPI 3.1.12-alpha, "server world deletions" were fixed. (@SignatureBeef)
* Fixed NetTile errors by implementing new packet read/write data. (@SignatureBeef)
## TShock 4.5.18
* Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@PotatoCider)

View file

@ -463,11 +463,15 @@ namespace TShockAPI.Handlers
if ((updateType & TileDataType.TilePaint) != 0)
{
tile.color(newTile.TileColor);
tile.fullbrightBlock(newTile.FullbrightBlock);
tile.invisibleBlock(newTile.InvisibleBlock);
}
if ((updateType & TileDataType.WallPaint) != 0)
{
tile.wallColor(newTile.WallColor);
tile.fullbrightWall(newTile.FullbrightWall);
tile.invisibleWall(newTile.InvisibleWall);
}
if ((updateType & TileDataType.Liquid) != 0)

View file

@ -45,6 +45,10 @@ namespace TShockAPI.Net
public bool Slope1 { get; set; }
public bool Slope2 { get; set; }
public bool Slope3 { get; set; }
public bool FullbrightBlock { get; set; }
public bool FullbrightWall { get; set; }
public bool InvisibleBlock { get; set; }
public bool InvisibleWall { get; set; }
public byte Slope
{
@ -172,6 +176,22 @@ namespace TShockAPI.Net
stream.WriteByte(bits);
bits = new BitsByte();
if (FullbrightBlock)
bits[0] = true;
if (FullbrightWall)
bits[1] = true;
if (InvisibleBlock)
bits[2] = true;
if (InvisibleWall)
bits[3] = true;
stream.WriteByte(bits);
if (HasColor)
{
stream.WriteByte(TileColor);
@ -206,6 +226,7 @@ namespace TShockAPI.Net
{
var flags = (BitsByte) stream.ReadInt8();
var flags2 = (BitsByte)stream.ReadInt8();
var flags3 = (BitsByte)stream.ReadInt8();
Wire2 = flags2[0];
Wire3 = flags2[1];
@ -214,6 +235,11 @@ namespace TShockAPI.Net
Slope3 = flags2[6];
Wire4 = flags2[7];
FullbrightBlock = flags3[0];
FullbrightWall = flags3[1];
InvisibleBlock = flags3[2];
InvisibleWall = flags3[3];
if (flags2[2])
{
TileColor = stream.ReadInt8();