internal void OnPick(Game game, int blockposX, int blockposY, int blockposZ, int blockposoldX, int blockposoldY, int blockposoldZ, float[] collisionPos, bool right) { float xfract = collisionPos[0] - game.MathFloor(collisionPos[0]); float zfract = collisionPos[2] - game.MathFloor(collisionPos[2]); int activematerial = game.MaterialSlots_(game.ActiveMaterial); int railstart = game.d_Data.BlockIdRailstart(); if (activematerial == railstart + RailDirectionFlags.TwoHorizontalVertical || activematerial == railstart + RailDirectionFlags.Corners) { RailDirection dirnew; if (activematerial == railstart + RailDirectionFlags.TwoHorizontalVertical) { dirnew = PickHorizontalVertical(xfract, zfract); } else { dirnew = PickCorners(xfract, zfract); } int dir = game.d_Data.Rail()[game.map.GetBlock(blockposoldX, blockposoldY, blockposoldZ)]; if (dir != 0) { blockposX = blockposoldX; blockposY = blockposoldY; blockposZ = blockposoldZ; } activematerial = railstart + (dir | DirectionUtils.ToRailDirectionFlags(dirnew)); } int x = game.platform.FloatToInt(blockposX); int y = game.platform.FloatToInt(blockposY); int z = game.platform.FloatToInt(blockposZ); int mode = right ? Packet_BlockSetModeEnum.Create : Packet_BlockSetModeEnum.Destroy; { if (game.IsAnyPlayerInPos(x, y, z) || activematerial == 151) // Compass { return; } Vector3IntRef v = Vector3IntRef.Create(x, y, z); Vector3IntRef oldfillstart = fillstart; Vector3IntRef oldfillend = fillend; if (mode == Packet_BlockSetModeEnum.Create) { if (game.blocktypes[activematerial].IsTool) { OnPickUseWithTool(game, blockposX, blockposY, blockposZ); return; } if (activematerial == game.d_Data.BlockIdCuboid()) { ClearFillArea(game); if (fillstart != null) { Vector3IntRef f = fillstart; if (!game.IsFillBlock(game.map.GetBlock(f.X, f.Y, f.Z))) { fillarea.Set(f.X, f.Y, f.Z, game.map.GetBlock(f.X, f.Y, f.Z)); } game.SetBlock(f.X, f.Y, f.Z, game.d_Data.BlockIdFillStart()); FillFill(game, v, fillstart); } if (!game.IsFillBlock(game.map.GetBlock(v.X, v.Y, v.Z))) { fillarea.Set(v.X, v.Y, v.Z, game.map.GetBlock(v.X, v.Y, v.Z)); } game.SetBlock(v.X, v.Y, v.Z, game.d_Data.BlockIdCuboid()); fillend = v; game.RedrawBlock(v.X, v.Y, v.Z); return; } if (activematerial == game.d_Data.BlockIdFillStart()) { ClearFillArea(game); if (!game.IsFillBlock(game.map.GetBlock(v.X, v.Y, v.Z))) { fillarea.Set(v.X, v.Y, v.Z, game.map.GetBlock(v.X, v.Y, v.Z)); } game.SetBlock(v.X, v.Y, v.Z, game.d_Data.BlockIdFillStart()); fillstart = v; fillend = null; game.RedrawBlock(v.X, v.Y, v.Z); return; } if (fillarea.ContainsKey(v.X, v.Y, v.Z))// && fillarea[v]) { game.SendFillArea(fillstart.X, fillstart.Y, fillstart.Z, fillend.X, fillend.Y, fillend.Z, activematerial); ClearFillArea(game); fillstart = null; fillend = null; return; } } else { if (game.blocktypes[activematerial].IsTool) { OnPickUseWithTool(game, blockposX, blockposY, blockposoldZ); return; } //delete fill start if (fillstart != null && fillstart.X == v.X && fillstart.Y == v.Y && fillstart.Z == v.Z) { ClearFillArea(game); fillstart = null; fillend = null; return; } //delete fill end if (fillend != null && fillend.X == v.X && fillend.Y == v.Y && fillend.Z == v.Z) { ClearFillArea(game); fillend = null; return; } } game.SendSetBlockAndUpdateSpeculative(activematerial, x, y, z, mode); } }