Upload from upload_mods.ps1
This commit is contained in:
82
Scripts/Network/NetPackageCheckBlockPositionRebirth.cs
Normal file
82
Scripts/Network/NetPackageCheckBlockPositionRebirth.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
public class NetPackageCheckBlockPositionRebirth : NetPackage
|
||||
{
|
||||
int clrIdx = 0;
|
||||
Vector3i blockPos;
|
||||
String blockName = "";
|
||||
int lightOpacity = 0;
|
||||
int blockID = 0;
|
||||
ulong tickRate = 0;
|
||||
|
||||
public NetPackageCheckBlockPositionRebirth Setup(int _clrIdx, Vector3i _blockPos, String _blockName, int _lightOpacity, int _blockID, ulong _tickRate)
|
||||
{
|
||||
//Log.Out("NetPackageCheckBlockPositionRebirth-Setup START");
|
||||
this.clrIdx = _clrIdx;
|
||||
this.blockPos = _blockPos;
|
||||
this.blockName = _blockName;
|
||||
this.lightOpacity = _lightOpacity;
|
||||
this.blockID = _blockID;
|
||||
this.tickRate = _tickRate;
|
||||
|
||||
/*Log.Out("NetPackageCheckBlockPositionRebirth-Setup this.clrIdx: " + this.clrIdx);
|
||||
Log.Out("NetPackageCheckBlockPositionRebirth-Setup this.blockPos: " + this.blockPos);
|
||||
Log.Out("NetPackageCheckBlockPositionRebirth-Setup this.blockName: " + this.blockName);*/
|
||||
//Log.Out("NetPackageCheckBlockPositionRebirth-Setup this.lightOpacity: " + this.lightOpacity);
|
||||
/*Log.Out("NetPackageCheckBlockPositionRebirth-Setup this.blockID: " + this.blockID);
|
||||
Log.Out("NetPackageCheckBlockPositionRebirth-Setup this.tickRate: " + this.tickRate);*/
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void read(PooledBinaryReader _br)
|
||||
{
|
||||
this.blockPos = new Vector3i((float)_br.ReadInt32(), (float)_br.ReadInt32(), (float)_br.ReadInt32());
|
||||
this.clrIdx = _br.ReadInt32();
|
||||
this.lightOpacity = _br.ReadInt32();
|
||||
this.blockName = _br.ReadString();
|
||||
this.blockID = _br.ReadInt32();
|
||||
this.tickRate = _br.ReadUInt64();
|
||||
}
|
||||
|
||||
public override void write(PooledBinaryWriter _bw)
|
||||
{
|
||||
base.write(_bw);
|
||||
_bw.Write((int)this.blockPos.x);
|
||||
_bw.Write((int)this.blockPos.y);
|
||||
_bw.Write((int)this.blockPos.z);
|
||||
_bw.Write(this.clrIdx);
|
||||
_bw.Write(this.lightOpacity);
|
||||
_bw.Write(this.blockName);
|
||||
_bw.Write(this.blockID);
|
||||
_bw.Write(this.tickRate);
|
||||
}
|
||||
|
||||
public override int GetLength()
|
||||
{
|
||||
return 32 + (this.blockName.Length * 2);
|
||||
}
|
||||
|
||||
public override void ProcessPackage(World _world, GameManager _callbacks)
|
||||
{
|
||||
//Log.Out("NetPackageCheckBlockPositionRebirth-ProcessPackage START");
|
||||
if (_world == null)
|
||||
{
|
||||
//Log.Out("NetPackageCheckBlockPositionRebirth-ProcessPackage 1");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
BlockValue block = GameManager.Instance.World.GetBlock(this.clrIdx, this.blockPos);
|
||||
block.Block.lightOpacity = this.lightOpacity;
|
||||
//Log.Out("NetPackageCheckBlockPositionRebirth-ProcessPackage CLIENT block.Block.lightOpacity: " + block.Block.lightOpacity);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue block = GameManager.Instance.World.GetBlock(this.clrIdx, this.blockPos);
|
||||
block.Block.lightOpacity = this.lightOpacity;
|
||||
//Log.Out("NetPackageCheckBlockPositionRebirth-ProcessPackage SERVER block.Block.lightOpacity: " + block.Block.lightOpacity);
|
||||
_world.GetWBT().AddScheduledBlockUpdate(this.clrIdx, this.blockPos, this.blockID, this.tickRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user