Exemple #1
0
        private static void SetPaint(Vector3i p3, Vector3i size, Dictionary <long, Chunk> modifiedChunks)
        {
            var texture = 0;

            if (Options.ContainsKey("t"))
            {
                if (!int.TryParse(Options["t"], out texture))
                {
                    SendOutput("Unable to parse texture value");

                    return;
                }
                if (BlockTextureData.list[texture] == null)
                {
                    SendOutput($"Unknown texture index {texture}");

                    return;
                }
            }

            var num = 0L;

            for (var face = 0; face < 6; face++)
            {
                var num2 = face * 8;
                num &= ~(255L << num2);
                num |= (long)(texture & 255) << num2;
            }
            var textureFull = num;

            const int clrIdx  = 0;
            var       counter = 0;

            for (var j = 0; j < size.y; j++)
            {
                for (var i = 0; i < size.x; i++)
                {
                    for (var k = 0; k < size.z; k++)
                    {
                        var p5         = new Vector3i(i + p3.x, j + p3.y, k + p3.z);
                        var blockValue = GameManager.Instance.World.GetBlock(clrIdx, p5);
                        if (blockValue.Block.shape.IsTerrain() || blockValue.Equals(BlockValue.Air))
                        {
                            continue;
                        }

                        GameManager.Instance.World.ChunkClusters[clrIdx].SetTextureFull(p5, textureFull);
                        counter++;
                    }
                }
            }

            SendOutput($"Painting {counter} blocks with texture '{BlockTextureData.GetDataByTextureID(texture)?.Name}' @ {p3} to {p3 + size}");
            SendOutput("Use bc-wblock /undo to revert the changes");
            Reload(modifiedChunks);
        }
Exemple #2
0
        private static void SetPaint(World world, Vector3i pos)
        {
            byte texture = 0;

            if (Options.ContainsKey("t"))
            {
                if (!byte.TryParse(Options["t"], out texture))
                {
                    SendOutput("Unable to parse texture value");

                    return;
                }
                if (BlockTextureData.list[texture] == null)
                {
                    SendOutput($"Unknown texture index {texture}");

                    return;
                }
            }

            var blockValue = world.GetBlock(pos);

            if (blockValue.Equals(BlockValue.Air))
            {
                SendOutput($"Target block is air @ {pos}");

                return;
            }
            if (blockValue.Block.shape.IsTerrain())
            {
                SendOutput($"Target block is terrain @ {pos}");

                return;
            }

            GameManager.Instance.SetBlockTextureServer(pos, BlockFace.None, texture, -1);
            SendOutput($"Painting block with texture '{BlockTextureData.GetDataByTextureID(texture)?.Name}' @ {pos}");
        }
Exemple #3
0
        private static void SetPaintFace(Vector3i p3, Vector3i size, Dictionary <long, Chunk> modifiedChunks)
        {
            byte texture = 0;

            if (Options.ContainsKey("t"))
            {
                if (!byte.TryParse(Options["t"], out texture))
                {
                    SendOutput("Unable to parse texture value");

                    return;
                }
                if (BlockTextureData.list[texture] == null)
                {
                    SendOutput($"Unknown texture index {texture}");

                    return;
                }
            }
            uint setFace = 0;

            if (Options.ContainsKey("face"))
            {
                if (!uint.TryParse(Options["face"], out setFace))
                {
                    SendOutput("Unable to parse face value");

                    return;
                }
            }
            if (setFace > 5)
            {
                SendOutput("Face must be between 0 and 5");

                return;
            }

            const int clrIdx  = 0;
            var       counter = 0;

            for (var j = 0; j < size.y; j++)
            {
                for (var i = 0; i < size.x; i++)
                {
                    for (var k = 0; k < size.z; k++)
                    {
                        var p5         = new Vector3i(i + p3.x, j + p3.y, k + p3.z);
                        var blockValue = GameManager.Instance.World.GetBlock(clrIdx, p5);
                        if (blockValue.Equals(BlockValue.Air))
                        {
                            continue;
                        }

                        GameManager.Instance.World.ChunkClusters[clrIdx].SetBlockFaceTexture(p5, (BlockFace)setFace, texture);
                        counter++;
                    }
                }
            }

            SendOutput($"Painting {counter} blocks on face '{((BlockFace)setFace).ToString()}' with texture '{BlockTextureData.GetDataByTextureID(texture)?.Name}' @ {p3} to {p3 + size}");
            SendOutput("Use bc-wblock /undo to revert the changes");
            Reload(modifiedChunks);
        }
        private static void SetPaint(Vector3i p3, Vector3i size)
        {
            var texture = 0;

            if (Options.ContainsKey("t"))
            {
                if (!int.TryParse(Options["t"], out texture))
                {
                    SendOutput("Unable to parse texture value");

                    return;
                }
                if (BlockTextureData.list[texture] == null)
                {
                    SendOutput(string.Format("Unknown texture index {0}", texture));

                    return;
                }
            }

            var num = 0L;

            for (var face = 0; face < 6; face++)
            {
                var num2 = face * 8;
                num &= ~(255L << num2);
                num |= (long)(texture & 255) << num2;
            }
            var textureFull = num;

            const int clrIdx  = 0;
            var       counter = 0;

            for (var j = 0; j < size.y; j++)
            {
                for (var i = 0; i < size.x; i++)
                {
                    for (var k = 0; k < size.z; k++)
                    {
                        var p5         = new Vector3i(i + p3.x, j + p3.y, k + p3.z);
                        var blockValue = GameManager.Instance.World.GetBlock(clrIdx, p5);
                        if (blockValue.Block.shape.IsTerrain() || blockValue.Equals(BlockValue.Air))
                        {
                            continue;
                        }

                        GameManager.Instance.World.ChunkClusters[clrIdx].SetTextureFull(p5, textureFull);
                        counter++;
                    }
                }
            }

            var textureName = "";

            if (BlockTextureData.GetDataByTextureID(texture) != null)
            {
                textureName = BlockTextureData.GetDataByTextureID(texture).Name;
            }

            SendOutput(string.Format("Painting {0} blocks with texture '{1}' @ {2} to {3}", counter,
                                     textureName, p3, p3 + size));
        }
        private static void SetPaintFace(Vector3i p3, Vector3i size)
        {
            byte texture = 0;

            if (Options.ContainsKey("t"))
            {
                if (!byte.TryParse(Options["t"], out texture))
                {
                    SendOutput("Unable to parse texture value");

                    return;
                }
                if (BlockTextureData.list[texture] == null)
                {
                    SendOutput(string.Format("Unknown texture index {0}", texture));

                    return;
                }
            }
            uint setFace = 0;

            if (Options.ContainsKey("face"))
            {
                if (!uint.TryParse(Options["face"], out setFace))
                {
                    SendOutput("Unable to parse face value");

                    return;
                }
            }
            if (setFace > 5)
            {
                SendOutput("Face must be between 0 and 5");

                return;
            }

            const int clrIdx  = 0;
            var       counter = 0;

            for (var j = 0; j < size.y; j++)
            {
                for (var i = 0; i < size.x; i++)
                {
                    for (var k = 0; k < size.z; k++)
                    {
                        var p5         = new Vector3i(i + p3.x, j + p3.y, k + p3.z);
                        var blockValue = GameManager.Instance.World.GetBlock(clrIdx, p5);
                        if (blockValue.Equals(BlockValue.Air))
                        {
                            continue;
                        }

                        GameManager.Instance.World.ChunkClusters[clrIdx].SetBlockFaceTexture(p5, (BlockFace)setFace, texture);
                        counter++;
                    }
                }
            }
            var textureName = "";

            if (BlockTextureData.GetDataByTextureID(texture) != null)
            {
                textureName = BlockTextureData.GetDataByTextureID(texture).Name;
            }

            SendOutput(string.Format("Painting {0} blocks on face '{1}' with texture '{2}' @ {3} to {4}", counter,
                                     ((BlockFace)setFace).ToString(), textureName, p3, p3 + size));
        }
Exemple #6
0
        private static void SetPaintFace(World world, Vector3i pos)
        {
            byte texture = 0;

            if (Options.ContainsKey("t"))
            {
                if (!byte.TryParse(Options["t"], out texture))
                {
                    SendOutput("Unable to parse texture value");

                    return;
                }
                if (BlockTextureData.list[texture] == null)
                {
                    SendOutput($"Unknown texture index {texture}");

                    return;
                }
            }
            uint setFace = 0;

            if (Options.ContainsKey("face"))
            {
                if (!uint.TryParse(Options["face"], out setFace))
                {
                    SendOutput("Unable to parse face value");

                    return;
                }
            }
            if (setFace > 5)
            {
                SendOutput("Face must be between 0 and 5");

                return;
            }

            var blockValue = world.GetBlock(pos);

            if (blockValue.Equals(BlockValue.Air))
            {
                SendOutput($"Target block is air @ {pos}");

                return;
            }
            if (blockValue.Block.shape.IsTerrain())
            {
                SendOutput($"Target block is terrain @ {pos}");

                return;
            }

            GameManager.Instance.SetBlockTextureServer(pos, (BlockFace)setFace, texture, -1);
            SendOutput($"Painting block on face '{((BlockFace)setFace).ToString()}' with texture '{BlockTextureData.GetDataByTextureID(texture)?.Name}' @ {pos}");
        }
Exemple #7
0
        private static void SetBlock(World world, Vector3i pos, BlockValue targetbv)
        {
            sbyte density = 0;

            if (Options.ContainsKey("d") && sbyte.TryParse(Options["d"], out density))
            {
                SendOutput($"Using density {density}");
            }

            byte texture = 0;

            if (Options.ContainsKey("t"))
            {
                if (!byte.TryParse(Options["t"], out texture))
                {
                    SendOutput("Unable to parse texture index");

                    return;
                }

                if (BlockTextureData.list[texture] == null)
                {
                    SendOutput($"Unknown texture index {texture}");

                    return;
                }

                SendOutput($"Using texture '{BlockTextureData.GetDataByTextureID(texture)?.Name}'");
            }

            if (Options.ContainsKey("delmulti"))
            {
                return;
            }

            var bvCurrent = world.GetBlock(pos);

            //REMOVE PARENT OF MULTIDIM
            if (bvCurrent.Block.isMultiBlock && bvCurrent.ischild)
            {
                var parentPos = bvCurrent.Block.multiBlockPos.GetParentPos(pos, bvCurrent);
                var parent    = world.GetBlock(parentPos);
                if (parent.ischild || parent.type != bvCurrent.type)
                {
                    return;
                }

                world.ChunkClusters[0].SetBlock(parentPos, BlockValue.Air, false, false);
            }
            if (Options.ContainsKey("delmulti"))
            {
                return;
            }

            //REMOVE LCB's
            if (bvCurrent.Block.IndexName == "lpblock")
            {
                GameManager.Instance.persistentPlayers.RemoveLandProtectionBlock(pos);
            }

            var chunkSync = world.GetChunkFromWorldPos(pos.x, pos.y, pos.z) as Chunk;

            if (targetbv.Equals(BlockValue.Air))
            {
                density = MarchingCubes.DensityAir;

                if (world.GetTerrainHeight(pos.x, pos.z) > pos.y)
                {
                    chunkSync?.SetTerrainHeight(pos.x & 15, pos.z & 15, (byte)pos.y);
                }
            }
            else if (targetbv.Block.shape.IsTerrain())
            {
                density = MarchingCubes.DensityTerrain;

                if (world.GetTerrainHeight(pos.x, pos.z) < pos.y)
                {
                    chunkSync?.SetTerrainHeight(pos.x & 15, pos.z & 15, (byte)pos.y);
                }
            }
            else
            {
                //SET TEXTURE
                GameManager.Instance.SetBlockTextureServer(pos, BlockFace.None, texture, -1);
            }

            //SET BLOCK
            world.SetBlockRPC(pos, targetbv, density);
        }