Exemplo n.º 1
0
        private string GetBlocksAround(BlockLogSection[] around, IBlockAccessor blockAccessor, BlockPos pos)
        {
            string[] any      = new string[3];
            int[]    anyCount = new int[3];
            if (blockAccessor.GetBlock(pos.North()) is BlockLogSection n)
            {
                around[0] = n;
                UpdateAny(n.LastCodePart(), any, anyCount);
            }
            if (blockAccessor.GetBlock(pos.South().East()) is BlockLogSection e)
            {
                around[1] = e;
                UpdateAny(e.LastCodePart(), any, anyCount);
            }
            if (blockAccessor.GetBlock(pos.South().West()) is BlockLogSection s)
            {
                around[2] = s;
                UpdateAny(s.LastCodePart(), any, anyCount);
            }
            if (blockAccessor.GetBlock(pos.North().West()) is BlockLogSection w)
            {
                around[3] = w;
                UpdateAny(w.LastCodePart(), any, anyCount);
            }
            if (blockAccessor.GetBlock(pos.East().Up()) is BlockLogSection u)
            {
                around[4] = u;
                UpdateAny(u.LastCodePart(), any, anyCount);
            }
            if (blockAccessor.GetBlock(pos.Down().Down()) is BlockLogSection d)
            {
                around[5] = d;
                UpdateAny(d.LastCodePart(), any, anyCount);
            }

            if (anyCount[1] > anyCount[0])
            {
                any[0]      = any[1];
                anyCount[0] = anyCount[1];
            }
            return((anyCount[2] > anyCount[0]) ? any[2] : any[0]);
        }
Exemplo n.º 2
0
        public static BlockPos GetRecommendedPos(this BlockSelection sel, ICoreAPI api, Block block)
        {
            BlockPos adjPos = sel.Position.Copy();

            if (!api.World.BlockAccessor.GetBlock(adjPos).IsReplacableBy(block))
            {
                switch (sel.Face.Code)
                {
                case "up":
                    adjPos.Up();
                    break;

                case "down":
                    adjPos.Down();
                    break;

                case "north":
                    adjPos.West();
                    break;

                case "south":
                    adjPos.East();
                    break;

                case "east":
                    adjPos.North();
                    break;

                case "west":
                    adjPos.South();
                    break;

                default:
                    break;
                }
            }
            return(adjPos);
        }